Skip to content

Commit

Permalink
LPS-31852 Use categorization instead of entity field "type" for Calen…
Browse files Browse the repository at this point in the history
…darResource
  • Loading branch information
fabiopezzutto authored and brianchandotcom committed Dec 20, 2012
1 parent c2cc314 commit cfd6a81
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 176 deletions.
5 changes: 4 additions & 1 deletion portlets/calendar-portlet/docroot/WEB-INF/service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
<column name="code" type="String" />
<column name="name" type="String" localized="true" />
<column name="description" type="String" localized="true" />
<column name="type" type="String" />
<column name="active" type="boolean" />

<!-- Order -->
Expand Down Expand Up @@ -203,6 +202,10 @@
<finder-column name="name" comparator="LIKE" />
<finder-column name="active" />
</finder>

<!-- References -->

<reference package-path="com.liferay.portlet.asset" entity="AssetEntry" />
</entity>
<exceptions>
<exception>CalendarBookingDuration</exception>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ protected void importCalendarResource(
calendarResource.getCode(),
calendarResource.getNameMap(),
calendarResource.getDescriptionMap(),
calendarResource.getType(),
calendarResource.getActive(), serviceContext);
}
else {
Expand All @@ -590,7 +589,6 @@ protected void importCalendarResource(
existingCalendarResource.getCalendarResourceId(),
calendarResource.getNameMap(),
calendarResource.getDescriptionMap(),
calendarResource.getType(),
calendarResource.getActive(), serviceContext);
}
}
Expand All @@ -602,8 +600,7 @@ protected void importCalendarResource(
calendarResource.getClassUuid(), calendarResource.getCode(),
calendarResource.getNameMap(),
calendarResource.getDescriptionMap(),
calendarResource.getType(), calendarResource.getActive(),
serviceContext);
calendarResource.getActive(), serviceContext);
}

portletDataContext.importClassedModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ public void updateCalendarResource(
actionRequest, "name");
Map<Locale, String> descriptionMap =
LocalizationUtil.getLocalizationMap(actionRequest, "description");
String type = ParamUtil.getString(actionRequest, "type");
boolean active = ParamUtil.getBoolean(actionRequest, "active");

ServiceContext serviceContext = ServiceContextFactory.getInstance(
Expand All @@ -339,12 +338,12 @@ public void updateCalendarResource(
if (calendarResourceId <= 0) {
CalendarResourceServiceUtil.addCalendarResource(
serviceContext.getScopeGroupId(), null, 0,
PortalUUIDUtil.generate(), code, nameMap, descriptionMap, type,
PortalUUIDUtil.generate(), code, nameMap, descriptionMap,
active, serviceContext);
}
else {
CalendarResourceServiceUtil.updateCalendarResource(
calendarResourceId, nameMap, descriptionMap, type, active,
calendarResourceId, nameMap, descriptionMap, active,
serviceContext);

if (defaultCalendarId > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public class CalendarResourceDisplayTerms extends DisplayTerms {

public static final String SCOPE = "scope";

public static final String TYPE = "type";

public CalendarResourceDisplayTerms(PortletRequest portletRequest) {
super(portletRequest);

Expand All @@ -45,7 +43,6 @@ public CalendarResourceDisplayTerms(PortletRequest portletRequest) {
description = ParamUtil.getString(portletRequest, DESCRIPTION);
name = ParamUtil.getString(portletRequest, NAME);
scope = ParamUtil.getLong(portletRequest, SCOPE);
type = ParamUtil.getString(portletRequest, TYPE);
}

public String getCode() {
Expand All @@ -64,10 +61,6 @@ public long getScope() {
return scope;
}

public String getType() {
return type;
}

public boolean isActive() {
return active;
}
Expand All @@ -77,6 +70,5 @@ public boolean isActive() {
protected String description;
protected String name;
protected long scope;
protected String type;

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class CalendarResourceSearch extends SearchContainer<CalendarResource> {
headerNames.add("code");
headerNames.add("name");
headerNames.add("description");
headerNames.add("type");
headerNames.add("active");

orderableHeaders.put("code", "code");
Expand Down Expand Up @@ -82,8 +81,6 @@ portletRequest, new CalendarResourceDisplayTerms(portletRequest),
iteratorURL.setParameter(
CalendarResourceDisplayTerms.SCOPE,
String.valueOf(displayTerms.getScope()));
iteratorURL.setParameter(
CalendarResourceDisplayTerms.TYPE, displayTerms.getType());

try {
PortalPreferences preferences =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public CalendarResourceSearchTerms(PortletRequest portletRequest) {
description = DAOParamUtil.getLike(portletRequest, DESCRIPTION);
name = DAOParamUtil.getLike(portletRequest, NAME);
scope = DAOParamUtil.getLong(portletRequest, SCOPE);
type = DAOParamUtil.getString(portletRequest, TYPE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.CharPool;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.Group;
Expand All @@ -50,7 +51,7 @@ public class CalendarResourceLocalServiceImpl
public CalendarResource addCalendarResource(
long userId, long groupId, String className, long classPK,
String classUuid, String code, Map<Locale, String> nameMap,
Map<Locale, String> descriptionMap, String type, boolean active,
Map<Locale, String> descriptionMap, boolean active,
ServiceContext serviceContext)
throws PortalException, SystemException {

Expand Down Expand Up @@ -110,7 +111,6 @@ public CalendarResource addCalendarResource(
calendarResource.setCode(code);
calendarResource.setNameMap(nameMap);
calendarResource.setDescriptionMap(descriptionMap);
calendarResource.setType(type);
calendarResource.setActive(active);

calendarResourcePersistence.update(calendarResource);
Expand All @@ -120,6 +120,13 @@ public CalendarResource addCalendarResource(
resourceLocalService.addModelResources(
calendarResource, serviceContext);

// Asset

updateAsset(
calendarResource.getUserId(), calendarResource,
serviceContext.getAssetCategoryIds(),
serviceContext.getAssetTagNames());

// Calendar

serviceContext.setAddGroupPermissions(true);
Expand Down Expand Up @@ -212,14 +219,14 @@ public List<CalendarResource> getCalendarResources(long groupId)

public List<CalendarResource> search(
long companyId, long[] groupIds, long[] classNameIds, String code,
String name, String description, String type, boolean active,
String name, String description, boolean active,
boolean andOperator, int start, int end,
OrderByComparator orderByComparator)
throws SystemException {

return calendarResourceFinder.findByC_G_C_C_N_D_T_A(
companyId, groupIds, classNameIds, code, name, description, type,
active, andOperator, start, end, orderByComparator);
return calendarResourceFinder.findByC_G_C_C_N_D_A(
companyId, groupIds, classNameIds, code, name, description, active,
andOperator, start, end, orderByComparator);
}

public List<CalendarResource> searchByKeywords(
Expand All @@ -244,18 +251,35 @@ public int searchCount(

public int searchCount(
long companyId, long[] groupIds, long[] classNameIds, String code,
String name, String description, String type, boolean active,
String name, String description, boolean active,
boolean andOperator)
throws SystemException {

return calendarResourceFinder.countByC_G_C_C_N_D_T_A(
companyId, groupIds, classNameIds, code, name, description, type,
active, andOperator);
return calendarResourceFinder.countByC_G_C_C_N_D_A(
companyId, groupIds, classNameIds, code, name, description, active,
andOperator);
}

public void updateAsset(
long userId, CalendarResource calendarResource,
long[] assetCategoryIds, String[] assetTagNames)
throws PortalException, SystemException {

assetEntryLocalService.updateEntry(
userId, calendarResource.getGroupId(),
calendarResource.getCreateDate(),
calendarResource.getModifiedDate(),
CalendarResource.class.getName(),
calendarResource.getCalendarResourceId(),
calendarResource.getUuid(), 0, assetCategoryIds,
assetTagNames, true, null, null, null, ContentTypes.TEXT,
calendarResource.getName(), calendarResource.getDescription(), null,
null, null, 0, 0, null, false);
}

public CalendarResource updateCalendarResource(
long calendarResourceId, Map<Locale, String> nameMap,
Map<Locale, String> descriptionMap, String type, boolean active,
Map<Locale, String> descriptionMap, boolean active,
ServiceContext serviceContext)
throws PortalException, SystemException {

Expand All @@ -267,7 +291,6 @@ public CalendarResource updateCalendarResource(
calendarResource.setModifiedDate(serviceContext.getModifiedDate(null));
calendarResource.setNameMap(nameMap);
calendarResource.setDescriptionMap(descriptionMap);
calendarResource.setType(type);
calendarResource.setActive(active);

calendarResourcePersistence.update(calendarResource);
Expand All @@ -277,6 +300,13 @@ public CalendarResource updateCalendarResource(
resourceLocalService.updateModelResources(
calendarResource, serviceContext);

// Asset

updateAsset(
calendarResource.getUserId(), calendarResource,
serviceContext.getAssetCategoryIds(),
serviceContext.getAssetTagNames());

return calendarResource;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class CalendarResourceServiceImpl
public CalendarResource addCalendarResource(
long groupId, String className, long classPK, String classUuid,
String code, Map<Locale, String> nameMap,
Map<Locale, String> descriptionMap, String type, boolean active,
Map<Locale, String> descriptionMap, boolean active,
ServiceContext serviceContext)
throws PortalException, SystemException {

Expand All @@ -48,7 +48,7 @@ public CalendarResource addCalendarResource(

return calendarResourceLocalService.addCalendarResource(
getUserId(), groupId, className, classPK, classUuid, code, nameMap,
descriptionMap, type, active, serviceContext);
descriptionMap, active, serviceContext);
}

public CalendarResource deleteCalendarResource(long calendarResourceId)
Expand Down Expand Up @@ -100,14 +100,14 @@ public List<CalendarResource> search(

public List<CalendarResource> search(
long companyId, long[] groupIds, long[] classNameIds, String code,
String name, String description, String type, boolean active,
String name, String description, boolean active,
boolean andOperator, int start, int end,
OrderByComparator orderByComparator)
throws SystemException {

return calendarResourceFinder.filterFindByC_G_C_C_N_D_T_A(
companyId, groupIds, classNameIds, code, name, description, type,
active, andOperator, start, end, orderByComparator);
return calendarResourceFinder.filterFindByC_G_C_C_N_D_A(
companyId, groupIds, classNameIds, code, name, description, active,
andOperator, start, end, orderByComparator);
}

public int searchCount(
Expand All @@ -121,26 +121,26 @@ public int searchCount(

public int searchCount(
long companyId, long[] groupIds, long[] classNameIds, String code,
String name, String description, String type, boolean active,
String name, String description, boolean active,
boolean andOperator)
throws SystemException {

return calendarResourceFinder.filterCountByC_G_C_C_N_D_T_A(
companyId, groupIds, classNameIds, code, name, description, type,
active, andOperator);
return calendarResourceFinder.filterCountByC_G_C_C_N_D_A(
companyId, groupIds, classNameIds, code, name, description, active,
andOperator);
}

public CalendarResource updateCalendarResource(
long calendarResourceId, Map<Locale, String> nameMap,
Map<Locale, String> descriptionMap, String type, boolean active,
Map<Locale, String> descriptionMap, boolean active,
ServiceContext serviceContext)
throws PortalException, SystemException {

CalendarResourcePermission.check(
getPermissionChecker(), calendarResourceId, ActionKeys.UPDATE);

return calendarResourceLocalService.updateCalendarResource(
calendarResourceId, nameMap, descriptionMap, type, active,
calendarResourceId, nameMap, descriptionMap, active,
serviceContext);
}

Expand Down
Loading

0 comments on commit cfd6a81

Please sign in to comment.