@Override public Object getFromCache(ProceedingJoinPoint pjp) throws Throwable { try{ //Return a copy so that if the data is mutated the original remains Metadata result = (Metadata) super.getFromCache(pjp); return new Metadata(result); }catch(ClassCastException e){ throw new RuntimeException("This cache should only be used on methods that return Metadata", e); } }
this.childProperties = new HashMap<String, Metadata>(); for(Map.Entry<String, Metadata> childProperty : toClone.childProperties.entrySet()) { this.childProperties.put(childProperty.getKey(), new Metadata(childProperty.getValue()));
/** * This method gets the metadata for the given object key * * @param objectKey * @param type * @param state * @return */ @SuppressWarnings("unchecked") public Metadata getMetadata(String objectKey, String type, String state){ if (metadataRepository == null || metadataRepository.get(objectKey) == null){ return getMetadataFromDictionaryService(objectKey, type, state); } else { Metadata metadata = new Metadata (); metadata.setWriteAccess(WriteAccess.ALWAYS); metadata.setOnChangeRefreshMetadata(false); metadata.setDataType(DataType.DATA); metadata.setProperties((Map<String, Metadata>)metadataRepository.get(objectKey)); //return the clone return new Metadata(metadata); } }
endInstAdminMeta.getConstraints().get(0).setMinOccurs(1); previousVersionMetadata = new Metadata(); previousVersionMetadata.setDataType(DataType.DATA);
/** * This invokes the appropriate dictionary service to get the object structure and then converts it to a metadata * structure. * * @param objectKey * @param type * @param state * @param documentTypeName * @return */ protected Metadata getMetadataFromDictionaryService(String objectKey, String type, String state, String nextState, String workflowNode, String documentTypeName) { Metadata metadata = new Metadata(); ObjectStructureDefinition objectStructure = getObjectStructure(objectKey); //FIXME/TODO: documentTypeName is only passed here, because it is eventually used in ProgramMetadataServiceImpl's getConstraints() method metadata.setProperties(getProperties(objectStructure, type, state, nextState, workflowNode, new RecursionCounter(), documentTypeName)); metadata.setWriteAccess(WriteAccess.ALWAYS); metadata.setDataType(DataType.DATA); addLookupstoMetadata(objectKey, metadata, type); return metadata; }
Metadata descMeta = new Metadata(); descMeta = metadata.getProperties().get("plain");
/** * This invokes the appropriate dictionary service to get the object structure and then * converts it to a metadata structure. * * @param objectKey * @param type * @param state * @return */ protected Metadata getMetadataFromDictionaryService(String objectKey, String type, String state){ Metadata metadata = new Metadata(); ObjectStructure objectStructure = getObjectStructure(objectKey); State objectState = getObjectState(objectStructure, type, state); ConstraintDescriptor constraintDescriptor = objectState.getConstraintDescriptor(); metadata.setNonServerConstraints(copyConstraints(constraintDescriptor)); List<Field> fields = objectState.getField(); metadata.setProperties(getProperties(fields, type, state)); metadata.setWriteAccess(WriteAccess.ALWAYS); metadata.setDataType(DataType.DATA); return metadata; }
Metadata modelDefinitionMetadata = new Metadata(); modelDefinitionMetadata.setCanView(true); modelDefinitionMetadata.setDataType(Data.DataType.DATA);