protected HashMap<String, DDMFormValues> getDDMFormValuesMap( ServiceContext serviceContext, long fileEntryTypeId) throws PortalException { HashMap<String, DDMFormValues> ddmFormValuesMap = new HashMap<>(); if (fileEntryTypeId <= 0) { return ddmFormValuesMap; } DLFileEntryType fileEntryType = DLFileEntryTypeLocalServiceUtil.getFileEntryType(fileEntryTypeId); List<DDMStructure> ddmStructures = fileEntryType.getDDMStructures(); for (DDMStructure ddmStructure : ddmStructures) { String namespace = String.valueOf(ddmStructure.getStructureId()); DDMFormValues ddmFormValues = (DDMFormValues) serviceContext.getAttribute( DDMFormValues.class.getName() + ddmStructure.getStructureId()); if (ddmFormValues == null) { ddmFormValues = StorageEngineManagerUtil.getDDMFormValues( ddmStructure.getStructureId(), namespace, serviceContext); } ddmFormValuesMap.put(ddmStructure.getStructureKey(), ddmFormValues); } return ddmFormValuesMap; }
protected ServiceContext getServiceContext() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); serviceContext.setAttribute("fileEntryTypeId", _contractDLFileEntryTypeId); Map<String, Serializable> expandoBridgeAttributes = serviceContext.getExpandoBridgeAttributes(); expandoBridgeAttributes.put(_EXPANDO_ATTRIBUTE_NAME, StringPool.BLANK); serviceContext.setExpandoBridgeAttributes(expandoBridgeAttributes); DLFileEntryType fileEntryType = DLFileEntryTypeLocalServiceUtil.getFileEntryType(_contractDLFileEntryTypeId); List<DDMStructure> ddmStructures = fileEntryType.getDDMStructures(); for (DDMStructure ddmStructure : ddmStructures) { DDMFormValues ddmFormValues = createDDMFormValues(ddmStructure.getDDMForm()); for (String fieldName : ddmStructure.getFieldNames()) { DDMFormFieldValue ddmFormFieldValue = createDDMFormFieldValue(fieldName); ddmFormValues.addDDMFormFieldValue(ddmFormFieldValue); } serviceContext.setAttribute( DDMFormValues.class.getName() + ddmStructure.getStructureId(), ddmFormValues); } return serviceContext; }
@Override public List<DDMStructure> getDDMStructures() throws PortalException { DLFileEntryType dlFileEntryType = DLFileEntryTypeLocalServiceUtil.getFileEntryType(getFileEntryTypeId()); return dlFileEntryType.getDDMStructures(); }
protected void updateServiceContext(String expando, long fileEntryTypeId, String metadata) throws PortalException { Map<String, Serializable> expandoBridgeAttributes = _serviceContext.getExpandoBridgeAttributes(); expandoBridgeAttributes.put(_EXPANDO_ATTRIBUTE_NAME, expando); _serviceContext.setExpandoBridgeAttributes(expandoBridgeAttributes); _serviceContext.setAttribute("fileEntryTypeId", fileEntryTypeId); if (fileEntryTypeId <= 0) { return; } DLFileEntryType fileEntryType = DLFileEntryTypeLocalServiceUtil.getFileEntryType(fileEntryTypeId); List<DDMStructure> ddmStructures = fileEntryType.getDDMStructures(); for (DDMStructure ddmStructure : ddmStructures) { DDMFormValues ddmFormValues = (DDMFormValues) _serviceContext.getAttribute( DDMFormValues.class.getName() + ddmStructure.getStructureId()); for (DDMFormFieldValue ddmFormFieldValue : ddmFormValues.getDDMFormFieldValues()) { String fieldType = ddmStructure.getFieldType(ddmFormFieldValue.getName()); if (fieldType.equals("text")) { LocalizedValue localizedValue = new LocalizedValue(LocaleUtil.US); localizedValue.addString(LocaleUtil.US, metadata); ddmFormFieldValue.setValue(localizedValue); } } _serviceContext.setAttribute( DDMFormValues.class.getName() + ddmStructure.getStructureId(), ddmFormValues); } }