use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.
the class KBTemplateLocalServiceImpl method updateKBTemplate.
@Override
public KBTemplate updateKBTemplate(long kbTemplateId, String title, String content, ServiceContext serviceContext) throws PortalException, SystemException {
// KB template
validate(title, content);
KBTemplate kbTemplate = kbTemplatePersistence.findByPrimaryKey(kbTemplateId);
kbTemplate.setModifiedDate(serviceContext.getModifiedDate(null));
kbTemplate.setTitle(title);
kbTemplate.setContent(content);
kbTemplatePersistence.update(kbTemplate);
if ((serviceContext.getGroupPermissions() != null) || (serviceContext.getGuestPermissions() != null)) {
updateKBTemplateResources(kbTemplate, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
}
// Social
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
extraDataJSONObject.put("title", kbTemplate.getTitle());
socialActivityLocalService.addActivity(kbTemplate.getUserId(), kbTemplate.getGroupId(), KBTemplate.class.getName(), kbTemplateId, AdminActivityKeys.UPDATE_KB_TEMPLATE, extraDataJSONObject.toString(), 0);
return kbTemplate;
}
use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.
the class KBTemplateModelImpl method equals.
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof KBTemplate)) {
return false;
}
KBTemplate kbTemplate = (KBTemplate) obj;
long primaryKey = kbTemplate.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
} else {
return false;
}
}
use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.
the class KBCommentLocalServiceImpl method putTitle.
protected void putTitle(JSONObject jsonObject, KBComment kbComment) {
KBArticle kbArticle = null;
KBTemplate kbTemplate = null;
String className = kbComment.getClassName();
try {
if (className.equals(KBArticle.class.getName())) {
kbArticle = KBArticleLocalServiceUtil.getLatestKBArticle(kbComment.getClassPK(), WorkflowConstants.STATUS_APPROVED);
jsonObject.put("title", kbArticle.getTitle());
} else if (className.equals(KBTemplate.class.getName())) {
kbTemplate = KBTemplateLocalServiceUtil.getKBTemplate(kbComment.getClassPK());
jsonObject.put("title", kbTemplate.getTitle());
}
} catch (Exception e) {
_log.error(e);
}
}
use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.
the class KBTemplateLocalServiceImpl method deleteKBTemplates.
@Override
public void deleteKBTemplates(long[] kbTemplateIds) throws PortalException, SystemException {
for (long kbTemplateId : kbTemplateIds) {
KBTemplate kbTemplate = null;
try {
kbTemplate = kbTemplatePersistence.findByPrimaryKey(kbTemplateId);
} catch (NoSuchTemplateException nste) {
continue;
}
kbTemplateLocalService.deleteKBTemplate(kbTemplate);
}
}
use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.
the class KBTemplateServiceImpl method getKBTemplateSearchDisplay.
@Override
public KBTemplateSearchDisplay getKBTemplateSearchDisplay(long groupId, String title, String content, Date startDate, Date endDate, boolean andOperator, int[] curStartValues, int cur, int delta, OrderByComparator orderByComparator) throws PortalException, SystemException {
// See LPS-9546
int start = 0;
if (curStartValues.length > (cur - SearchContainer.DEFAULT_CUR)) {
start = curStartValues[cur - SearchContainer.DEFAULT_CUR];
curStartValues = ArrayUtil.subset(curStartValues, 0, cur - SearchContainer.DEFAULT_CUR + 1);
} else {
cur = SearchContainer.DEFAULT_CUR;
curStartValues = new int[] { 0 };
}
int end = start + _INTERVAL;
List<KBTemplate> kbTemplates = new ArrayList<KBTemplate>();
int curStartValue = 0;
while (curStartValue == 0) {
List<KBTemplate> curKBTemplates = kbTemplateLocalService.search(groupId, title, content, startDate, endDate, andOperator, start, end, orderByComparator);
if (curKBTemplates.isEmpty()) {
break;
}
for (int i = 0; i < curKBTemplates.size(); i++) {
KBTemplate curKBTemplate = curKBTemplates.get(i);
if (!KBTemplatePermission.contains(getPermissionChecker(), curKBTemplate, ActionKeys.VIEW)) {
continue;
}
if (kbTemplates.size() == delta) {
curStartValue = start + i;
break;
}
kbTemplates.add(curKBTemplate);
}
start = start + _INTERVAL;
end = start + _INTERVAL;
}
int total = ((cur - 1) * delta) + kbTemplates.size();
if (curStartValue > 0) {
curStartValues = ArrayUtil.append(curStartValues, curStartValue);
total = total + 1;
}
return new KBTemplateSearchDisplayImpl(kbTemplates, total, curStartValues);
}
Aggregations