@Override public com.liferay.dynamic.data.mapping.model.DDMTemplateLink addTemplateLink( long classNameId, long classPK, long templateId) { return _ddmTemplateLinkLocalService.addTemplateLink(classNameId, classPK, templateId); }
public static com.liferay.dynamic.data.mapping.model.DDMTemplateLink addTemplateLink( long classNameId, long classPK, long templateId) { return getService().addTemplateLink(classNameId, classPK, templateId); }
protected void addDDMTemplateLinks() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer()) { long ddmStructureClassNameId = PortalUtil.getClassNameId( DDMStructure.class.getName()); long journalArticleClassNameId = PortalUtil.getClassNameId( JournalArticle.class.getName()); StringBundler sb = new StringBundler(6); sb.append("select DDMTemplate.templateId, JournalArticle.id_ "); sb.append("from JournalArticle inner join DDMTemplate on ("); sb.append("DDMTemplate.groupId = JournalArticle.groupId and "); sb.append("DDMTemplate.templateKey = "); sb.append("JournalArticle.DDMTemplateKey and "); sb.append("JournalArticle.classNameId != ?)"); try (PreparedStatement ps = connection.prepareStatement( sb.toString())) { ps.setLong(1, ddmStructureClassNameId); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { long templateId = rs.getLong("templateId"); long id = rs.getLong("id_"); _ddmTemplateLinkLocalService.addTemplateLink( journalArticleClassNameId, id, templateId); } } } } }
protected void updateDDMLinks( long id, long groupId, String ddmStructureKey, String ddmTemplateKey, boolean incrementVersion) throws PortalException { DDMStructure ddmStructure = ddmStructureLocalService.getStructure( PortalUtil.getSiteGroupId(groupId), classNameLocalService.getClassNameId(JournalArticle.class), ddmStructureKey, true); DDMTemplate ddmTemplate = ddmTemplateLocalService.getTemplate( PortalUtil.getSiteGroupId(groupId), classNameLocalService.getClassNameId(DDMStructure.class), ddmTemplateKey, true); if (incrementVersion) { ddmStorageLinkLocalService.addStorageLink( ddmStructure.getClassNameId(), id, ddmStructure.getStructureId(), new ServiceContext()); ddmTemplateLinkLocalService.addTemplateLink( classNameLocalService.getClassNameId(JournalArticle.class), id, ddmTemplate.getTemplateId()); } else { DDMStorageLink ddmStorageLink = ddmStorageLinkLocalService.getClassStorageLink(id); ddmStorageLink.setStructureId(ddmStructure.getStructureId()); ddmStorageLinkLocalService.updateDDMStorageLink(ddmStorageLink); ddmTemplateLinkLocalService.updateTemplateLink( classNameLocalService.getClassNameId(JournalArticle.class), id, ddmTemplate.getTemplateId()); } }