@Test public void testGetDDMStructure() throws Exception { DDMForm ddmForm = DDMFormTestUtil.createDDMForm("Text1", "Text2", "Text3"); DDMStructure ddmStructure = DDMStructureTestUtil.addStructure( _group.getGroupId(), DDLRecordSet.class.getName(), ddmForm); DDLRecordSet recordSet = _ddlRecordSetTestHelper.addRecordSet(ddmStructure); ddmForm = DDMFormTestUtil.createDDMForm("Text2", "Text3"); DDMTemplate template = DDMTemplateTestUtil.addTemplate( _group.getGroupId(), ddmStructure.getStructureId(), PortalUtil.getClassNameId(DDLRecordSet.class), "json", DDMFormJSONSerializerUtil.serialize(ddmForm), LocaleUtil.US); Set<String> fieldNames = ddmStructure.getFieldNames(); DDMStructure recordSetDDMStructure = recordSet.getDDMStructure(template.getTemplateId()); if (fieldNames.equals(recordSetDDMStructure.getFieldNames())) { Assert.fail(); } recordSetDDMStructure = recordSet.getDDMStructure(); if (!fieldNames.equals(recordSetDDMStructure.getFieldNames())) { Assert.fail(); } }
@Override protected Map<String, List<StagedModel>> addDependentStagedModelsMap(Group group) throws Exception { Map<String, List<StagedModel>> dependentStagedModelsMap = new LinkedHashMap<>(); DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(group.getGroupId(), DDLRecordSet.class.getName()); DDMTemplate ddmTemplate1 = DDMTemplateTestUtil.addTemplate( group.getGroupId(), ddmStructure.getStructureId(), PortalUtil.getClassNameId(DDLRecordSet.class)); addDependentStagedModel(dependentStagedModelsMap, DDMTemplate.class, ddmTemplate1); DDMTemplate ddmTemplate2 = DDMTemplateTestUtil.addTemplate( group.getGroupId(), ddmStructure.getStructureId(), PortalUtil.getClassNameId(DDLRecordSet.class)); addDependentStagedModel(dependentStagedModelsMap, DDMTemplate.class, ddmTemplate2); addDependentStagedModel(dependentStagedModelsMap, DDMStructure.class, ddmStructure); return dependentStagedModelsMap; }
@Override protected BaseModel<?> addBaseModelWithDDMStructure( BaseModel<?> parentBaseModel, String keywords, ServiceContext serviceContext) throws Exception { String content = DDMStructureTestUtil.getSampleStructuredContent(keywords); DDMForm ddmForm = DDMStructureTestUtil.getSampleDDMForm("name"); DDMStructure ddmStructure = DDMStructureTestUtil.addStructure( serviceContext.getScopeGroupId(), JournalArticle.class.getName(), ddmForm); DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate( serviceContext.getScopeGroupId(), ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class)); return addArticleWithXmlContent( parentBaseModel, content, ddmStructure, ddmTemplate, serviceContext); }
@Override protected BaseModel<?> addSearchableAssetEntry( String fieldValue, BaseModel<?> parentBaseModel, DDMStructure ddmStructure, DDMTemplate ddmTemplate, ServiceContext serviceContext) throws Exception { String content = DDMStructureTestUtil.getSampleStructuredContent(fieldValue); return addArticleWithXmlContent( parentBaseModel, content, ddmStructure, ddmTemplate, serviceContext); }
@Override protected void updateDDMStructure(ServiceContext serviceContext) throws Exception { DDMForm ddmForm = DDMStructureTestUtil.getSampleDDMForm("title"); DDMFormLayout ddmFormLayout = DDMUtil.getDefaultDDMFormLayout(ddmForm); DDMStructureLocalServiceUtil.updateStructure( _ddmStructure.getUserId(), _ddmStructure.getStructureId(), _ddmStructure.getParentStructureId(), _ddmStructure.getNameMap(), _ddmStructure.getDescriptionMap(), ddmForm, ddmFormLayout, serviceContext); }
@Override protected BaseModel<?> addSearchableAssetEntryRepeatable( String[] fieldValues, BaseModel<?> parentBaseModel, DDMStructure ddmStructure, DDMTemplate ddmTemplate, ServiceContext serviceContext) throws Exception { ArrayList<Map<Locale, String>> contents = new ArrayList<>(fieldValues.length); for (String fieldValue : fieldValues) { Map<Locale, String> map = new HashMap<>(); map.put(Locale.US, fieldValue); contents.add(map); } String content = DDMStructureTestUtil.getSampleStructuredContent("name", contents, "en_US"); return addArticleWithXmlContent( parentBaseModel, content, ddmStructure, ddmTemplate, serviceContext); }