public static List<ClassificationType> getClassifications(RegistryObjectType ro, String scheme) { List<ClassificationType> result = new ArrayList<ClassificationType>(); List<ClassificationType> classifications = ro.getClassification(); for (int i = 0, len = classifications.size() ; i < len ; i++) { if (classifications.get(i).getClassificationScheme().equals(scheme)) { result.add(classifications.get(i)); } } return result; }
public static ClassificationType removeClassification(RegistryObjectType ro, String id) { List<ClassificationType> list = ro.getClassification(); for (int i = 0, len = list.size() ; i < len ; i++) { if (list.get(i).getId().equals(id)) { return list.remove(i); } } return null; }
public static ClassificationType createClassification(String id, String classificationNode, String classifiedObject) { ClassificationType cl = rimFactory.createClassificationType(); cl.setId(id); cl.setClassificationNode(classificationNode); cl.setClassifiedObject(classifiedObject); cl.setObjectType(OBJECT_TYPE_CLASSIFICATION); return cl; } public static ClassificationType removeClassification(RegistryObjectType ro, String id) {
public static ClassificationType createClassification(String id, String classificationScheme, String classifiedObject, String nodeRepresentation) { ClassificationType cl = rimFactory.createClassificationType(); cl.setId(id); cl.setClassificationScheme(classificationScheme); cl.setClassifiedObject(classifiedObject); cl.setObjectType(OBJECT_TYPE_CLASSIFICATION); cl.setNodeRepresentation(nodeRepresentation); return cl; }
public Classification toClassification(ClassificationType clType) throws XDSException { Classification cl = new Classification(); toPersistenceObj(clType, cl); cl.setNodeRepresentation(clType.getNodeRepresentation()); log.debug("######clType.getClassificationScheme:{}",clType.getClassificationScheme()); if (clType.getClassificationScheme() != null) { RegistryObject obj = getRegistryObject(clType.getClassificationScheme()); if (obj == null) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_ERROR, "Classification Scheme ("+clType.getClassificationScheme()+ ") missing! Classification id:"+clType.getId(), null); } else if (obj instanceof ClassificationScheme) { cl.setClassificationScheme((ClassificationScheme) obj); } else { throw new XDSException(XDSException.XDS_ERR_REGISTRY_ERROR, "Referenced ClassificationScheme ("+clType.getClassificationScheme()+ ") is not a ClassificationScheme! (objType:"+obj.getObjectType()+", class:"+obj.getClass().getSimpleName()+ ") Classification id:"+clType.getId(), null); } else if (clType.getClassificationNode() != null) { RegistryObject obj = getRegistryObject(clType.getClassificationNode()); if (obj == null) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_ERROR, "Classification Node ("+clType.getClassificationNode()+ ") missing! Classification id:"+clType.getId(), null); } else if (obj instanceof ClassificationNode) { cl.setClassificationNode((ClassificationNode) obj); } else { throw new XDSException(XDSException.XDS_ERR_REGISTRY_ERROR, "Referenced ClassificationNode ("+clType.getClassificationScheme()+
private ClassificationType toClassificationType(Classification cl) { ClassificationType clType = factory.createClassificationType(); toEbXmlObj(cl, clType); clType.setNodeRepresentation(cl.getNodeRepresentation()); if (cl.getClassificationScheme() != null) { clType.setClassificationScheme(cl.getClassificationScheme().getId()); } else if (cl.getClassificationNode() != null) { clType.setClassificationNode(cl.getClassificationNode().getId()); } else { log.error("Missing ClassificationNode and ClassificationScheme! Classification id:"+cl.getId()); clType.setClassificationScheme("urn:willi:987-abc-456"); } if (cl.getClassifiedObject() != null) { clType.setClassifiedObject(cl.getClassifiedObject().getId()); } else { log.error("Missing ClassifiedObject! Classification id:"+cl.getId()); clType.setClassifiedObject("urn:willi:987-abc-789"); } return clType; }
private static void checkCodes(RegistryObjectType roType, List<String> requiredCodes) throws XDSException { List<ClassificationType> clList = roType.getClassification(); String objId = roType.getId(); for (ClassificationType cl : clList) { if( objId.equals(cl.getClassifiedObject())) { if (requiredCodes.remove(cl.getClassificationScheme())) { if (cl.getName() == null || cl.getName().getLocalizedString() == null || cl.getName().getLocalizedString().isEmpty()) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_METADATA_ERROR, "Missing code display name in code '"+cl.getNodeRepresentation()+ "(code classification:"+cl.getClassificationScheme(), null); } } } } if (requiredCodes.size() > 0) throw new XDSException(XDSException.XDS_ERR_REGISTRY_METADATA_ERROR, "Missing code values in '"+objId+"'! codes:"+requiredCodes, null); }
public XDSCode getXDSCode(ClassificationType clType, boolean createMissing) throws XDSException { String scheme = clType.getClassificationScheme(); String codeValue = clType.getNodeRepresentation(); String codeDesignator = clType.getSlot().get(0).getValueList().getValue().get(0); if (!createMissing) { if (!adCodes.isClassSchemeCodeDefined(scheme, codeValue, codeDesignator)) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_METADATA_ERROR, "Unknown code:"+ codeValue+"^^"+codeDesignator+" ("+scheme+")", null); } } XDSCode code = new XDSCode(codeValue, codeDesignator, clType.getName().getLocalizedString().get(0).getValue(), scheme); try { return (XDSCode) em.createNamedQuery(XDSCode.FIND_BY_CODE_VALUE) .setParameter(1, codeValue) .setParameter(2, codeDesignator) .setParameter(3, scheme) .getSingleResult(); } catch (NoResultException x) { log.info("Store new XDS Code! code:"+code); em.persist(code); return code; } }
public static RegistryPackageType getRegistryPackage(SubmitObjectsRequest sor, String classificationUUID) { List<JAXBElement<? extends IdentifiableType>> list = sor.getRegistryObjectList().getIdentifiable(); String id = null; IdentifiableType identifiable; if ( classificationUUID != null ) { ClassificationType ct; for ( int i = 0, len = list.size() ; i < len ; i++) { identifiable = list.get(i).getValue(); if ( identifiable instanceof ClassificationType) { ct = (ClassificationType) identifiable; if ( classificationUUID.equals( ct.getClassificationNode())) { id = ct.getClassifiedObject(); break; } } } } RegistryPackageType rp; for ( int i = 0, len = list.size() ; i < len ; i++ ) { identifiable = list.get(i).getValue(); if ( identifiable instanceof RegistryPackageType) { rp = (RegistryPackageType) identifiable; if ( id == null || id.equals( rp.getId())) { return rp; } } } return null; }
public static ClassificationType createCodeClassification(String id, String classifiedObjectID, String type, Code code) { ClassificationType cl = createClassification(id, type, classifiedObjectID, code.getValue()); LocalizedStringType lst = rimFactory.createLocalizedStringType(); lst.setValue(code.getMeaning()); InternationalStringType is = rimFactory.createInternationalStringType(); is.getLocalizedString().add(lst); cl.setName(is); cl.getSlot().add(createSlot("codingScheme", null, code.getDesignator())); return cl; }
private boolean isXDSCode(ClassificationType cl) { List<SlotType1> slots = cl.getSlot(); return slots != null && slots.size() == 1 && "codingScheme".equals(slots.get(0).getName()); }
/** * Create an instance of {@link ClassificationType } * */ public ClassificationType createClassificationType() { return new ClassificationType(); }