Search in sources :

Example 1 with ClassificationType

use of com.google.cloud.automl.v1.ClassificationType in project nhin-d by DirectProject.

the class DirectDocuments method getSubmitObjectsRequest.

/**
     * Get the metadata represented as a SubmitObjectsRequest object.
     */
public SubmitObjectsRequest getSubmitObjectsRequest() {
    RegistryPackageType registryPackageType = submissionSet.generateRegistryPackageType();
    ClassificationType classificationType = submissionSet.generateClassificationType();
    QName qname = null;
    // Generate ExtrinsicObjectType objects for each document
    qname = new QName(SubmitObjectsRequestEnum.EXTRINSIC_OBJECT.getNamespaceUri(), SubmitObjectsRequestEnum.EXTRINSIC_OBJECT.getName());
    List<JAXBElement<ExtrinsicObjectType>> jaxb_extrinsicObjectTypes = new ArrayList<JAXBElement<ExtrinsicObjectType>>();
    for (DirectDocument2 document : documents) {
        ExtrinsicObjectType extrinsicObjectType = document.getMetadata().generateExtrinsicObjectType();
        JAXBElement<ExtrinsicObjectType> jaxb_extrinsicObjectType = new JAXBElement<ExtrinsicObjectType>(qname, ExtrinsicObjectType.class, extrinsicObjectType);
        jaxb_extrinsicObjectTypes.add(jaxb_extrinsicObjectType);
    }
    // Generate the RegistryPakageType (SubmissionSet) for the group of
    // documents
    qname = new QName(SubmitObjectsRequestEnum.REGISTRY_PACKAGE.getNamespaceUri(), SubmitObjectsRequestEnum.REGISTRY_PACKAGE.getName());
    JAXBElement<RegistryPackageType> jaxb_registryPackageType = new JAXBElement<RegistryPackageType>(qname, RegistryPackageType.class, registryPackageType);
    // Generate the ClassificationType object
    qname = new QName(SubmitObjectsRequestEnum.CLASSIFICATION.getNamespaceUri(), SubmitObjectsRequestEnum.CLASSIFICATION.getName());
    JAXBElement<ClassificationType> jaxb_classificationType = new JAXBElement<ClassificationType>(qname, ClassificationType.class, classificationType);
    // Generate AssociationType1 objects for each document
    qname = new QName(SubmitObjectsRequestEnum.ASSOCIATION.getNamespaceUri(), SubmitObjectsRequestEnum.ASSOCIATION.getName());
    List<JAXBElement<AssociationType1>> jaxb_associationType1s = new ArrayList<JAXBElement<AssociationType1>>();
    for (DirectDocument2 document : documents) {
        AssociationType1 associationType = submissionSet.generateAssociationType(document.getMetadata().getId(), document.getMetadata().getSubmissionSetStatus());
        JAXBElement<AssociationType1> jaxb_AssociationType1 = new JAXBElement<AssociationType1>(qname, AssociationType1.class, associationType);
        jaxb_associationType1s.add(jaxb_AssociationType1);
    }
    SubmitObjectsRequest submitObjectsRequest = new SubmitObjectsRequest();
    RegistryObjectListType registryObjectListType = new RegistryObjectListType();
    List<JAXBElement<? extends IdentifiableType>> elements = registryObjectListType.getIdentifiable();
    elements.addAll(jaxb_extrinsicObjectTypes);
    elements.add(jaxb_registryPackageType);
    elements.add(jaxb_classificationType);
    elements.addAll(jaxb_associationType1s);
    submitObjectsRequest.setRegistryObjectList(registryObjectListType);
    return submitObjectsRequest;
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) IdentifiableType(oasis.names.tc.ebxml_regrep.xsd.rim._3.IdentifiableType) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) AssociationType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) JAXBElement(javax.xml.bind.JAXBElement) ClassificationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType) SubmitObjectsRequest(oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest)

Example 2 with ClassificationType

use of com.google.cloud.automl.v1.ClassificationType in project nhin-d by DirectProject.

the class DirectDocuments method setValues.

public void setValues(SubmitObjectsRequest submitObjectsRequest) throws MetadataException {
    RegistryObjectListType rol = submitObjectsRequest.getRegistryObjectList();
    List<JAXBElement<? extends IdentifiableType>> elements = rol.getIdentifiable();
    for (JAXBElement<? extends IdentifiableType> element : elements) {
        if (element.getValue() instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) {
            ExtrinsicObjectType eot = (ExtrinsicObjectType) element.getValue();
            DirectDocument2 document = new DirectDocument2();
            DirectDocument2.Metadata metadata = document.getMetadata();
            metadata.setValues(eot);
            documents.add(document);
        } else if (element.getValue() instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) {
            RegistryPackageType rpt = (RegistryPackageType) element.getValue();
            SubmissionSet submissionSet = new SubmissionSet();
            submissionSet.setValues(rpt);
            this.submissionSet = submissionSet;
        } else if (element.getValue() instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType) {
        // Empty in example
        }
    }
    for (JAXBElement<? extends IdentifiableType> element : elements) {
        if (element.getValue() instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) {
            AssociationType1 at = (AssociationType1) element.getValue();
            for (SlotType1 slot : at.getSlot()) {
                if (SlotType1Enum.SUBMISSION_SET_STATUS.matches(slot.getName())) {
                    if (slotNotEmpty(slot)) {
                        getDocumentById(at.getTargetObject()).getMetadata().setSubmissionSetStatus(slot.getName());
                    }
                }
            }
        }
    }
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) IdentifiableType(oasis.names.tc.ebxml_regrep.xsd.rim._3.IdentifiableType) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) AssociationType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) JAXBElement(javax.xml.bind.JAXBElement) ClassificationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1)

Example 3 with ClassificationType

use of com.google.cloud.automl.v1.ClassificationType in project ddf by codice.

the class RegistryPackageWebConverterTest method getFirstExtrinsicObject.

private ExtrinsicObjectType getFirstExtrinsicObject() {
    ExtrinsicObjectType extrinsicObject = RIM_FACTORY.createExtrinsicObjectType();
    // set default values
    extrinsicObject.setMimeType(extrinsicObject.getMimeType());
    extrinsicObject.setIsOpaque(extrinsicObject.isIsOpaque());
    extrinsicObject.setId("urn:registry:node");
    extrinsicObject.setObjectType("urn:registry:federation:node");
    extrinsicObject.getSlot().add(stHelper.create("liveDate", "2015-11-01T06:15:30-07:00", "xs:dateTime"));
    extrinsicObject.getSlot().add(stHelper.create("dataStartDate", "2015-11-01T13:15:30Z", "xs:dateTime"));
    extrinsicObject.getSlot().add(stHelper.create("dataEndDate", "2015-12-01T23:01:40Z", "xs:dateTime"));
    extrinsicObject.getSlot().add(stHelper.create("lastUpdated", "2016-01-26T17:16:34.996Z", "xs:dateTime"));
    extrinsicObject.getSlot().add(stHelper.create("links", "https://some/link/to/my/repo", "xs:string"));
    SlotType1 locationSlot = stHelper.create("location", (String) null, "urn:ogc:def:dataType:ISO-19107:2003:GM_Point");
    PointType point = GML_FACTORY.createPointType();
    point.setSrsDimension(BigInteger.valueOf(2));
    point.setSrsName("urn:ogc:def:crs:EPSG::4326");
    DirectPositionType directPosition = GML_FACTORY.createDirectPositionType();
    directPosition.getValue().add(112.267472);
    directPosition.getValue().add(33.467944);
    point.setPos(directPosition);
    ValueListType valueList = WRS_FACTORY.createValueListType();
    AnyValueType anyValue = WRS_FACTORY.createAnyValueType();
    anyValue.getContent().add(GML_FACTORY.createPoint(point));
    valueList.getAnyValue().add(anyValue);
    locationSlot.setValueList(RIM_FACTORY.createValueList(valueList));
    extrinsicObject.getSlot().add(locationSlot);
    SlotType1 boundsSlot = stHelper.create("bounds", (String) null, "urn:ogc:def:dataType:ISO-19107:2003:GM_Envelope");
    EnvelopeType bounds = GML_FACTORY.createEnvelopeType();
    bounds.setSrsName("urn:ogc:def:crs:EPSG::4326");
    directPosition = GML_FACTORY.createDirectPositionType();
    directPosition.getValue().add(112.267472);
    directPosition.getValue().add(33.467944);
    bounds.setUpperCorner(directPosition);
    directPosition = GML_FACTORY.createDirectPositionType();
    directPosition.getValue().add(110.267472);
    directPosition.getValue().add(30.467944);
    bounds.setLowerCorner(directPosition);
    valueList = WRS_FACTORY.createValueListType();
    anyValue = WRS_FACTORY.createAnyValueType();
    anyValue.getContent().add(GML_FACTORY.createEnvelope(bounds));
    valueList.getAnyValue().add(anyValue);
    boundsSlot.setValueList(RIM_FACTORY.createValueList(valueList));
    extrinsicObject.getSlot().add(boundsSlot);
    extrinsicObject.getSlot().add(stHelper.create("region", "USA", "urn:ogc:def:ebRIM-ClassificationScheme:UNSD:GlobalRegions"));
    List<String> values = new ArrayList<>();
    values.add("youtube");
    values.add("myCamera");
    extrinsicObject.getSlot().add(stHelper.create("inputDataSources", values, "xs:string"));
    values = new ArrayList<>();
    values.add("video");
    values.add("sensor");
    extrinsicObject.getSlot().add(stHelper.create("dataTypes", values, "xs:string"));
    extrinsicObject.getSlot().add(stHelper.create("securityLevel", "role=guest", "xs:string"));
    extrinsicObject.setName(istHelper.create("Node Name"));
    extrinsicObject.setDescription(istHelper.create("A little something describing this node in less than 1024 characters"));
    extrinsicObject.setVersionInfo(getVersionInfo("2.9.x"));
    ClassificationType classification = RIM_FACTORY.createClassificationType();
    classification.setId("urn:classification:id0");
    classification.setClassifiedObject("classifiedObjectId");
    extrinsicObject.getClassification().add(classification);
    return extrinsicObject;
}
Also used : EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType) ValueListType(net.opengis.cat.wrs.v_1_0_2.ValueListType) ArrayList(java.util.ArrayList) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) PointType(net.opengis.gml.v_3_1_1.PointType) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) ClassificationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType)

Example 4 with ClassificationType

use of com.google.cloud.automl.v1.ClassificationType in project ddf by codice.

the class RegistryPackageWebConverterTest method getFirstOrganization.

private OrganizationType getFirstOrganization() {
    OrganizationType organization = RIM_FACTORY.createOrganizationType();
    organization.setId("urn:organization:id0");
    organization.setParent("urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
    organization.setPrimaryContact("somePrimaryContact");
    organization.setLid("someLid");
    organization.setStatus("someStatus");
    organization.setName(istHelper.create("Codice"));
    organization.getAddress().add(getAddress("Phoenix", "USA", "85037", "AZ", "1234 Some Street", null));
    organization.getTelephoneNumber().add(getPhoneNumber("555", null, "1234", "555-5555", null));
    organization.getEmailAddress().add(getEmailAddress("emailaddress@something.com", null));
    ClassificationType classification = RIM_FACTORY.createClassificationType();
    classification.setId("urn:classification:id0");
    classification.setClassifiedObject("classifiedObjectId");
    classification.setClassificationScheme("classificationScheme");
    classification.setClassificationNode("classificationNode");
    classification.setNodeRepresentation("nodeRepresentation");
    organization.getClassification().add(classification);
    return organization;
}
Also used : OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) ClassificationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType)

Example 5 with ClassificationType

use of com.google.cloud.automl.v1.ClassificationType in project ddf by codice.

the class RegistryObjectWebConverter method convertRegistryObject.

/**
     * This method creates a Map<String, Object> representation of the RegistryObjectType provided.
     * The following keys will be added to the map (Taken from EbrimConstants):
     * <p>
     * CLASSIFICATION_KEY = "Classification";
     * EXTERNAL_IDENTIFIER_KEY = "ExternalIdentifier";
     * NAME_KEY = "Name";
     * DESCRIPTION_KEY = "Description";
     * VERSION_INFO_KEY = "VersionInfo";
     * SLOT = "Slot";
     * ID_KEY = "id";
     * HOME_KEY = "home";
     * LID_KEY = "Lid";
     * STATUS_KEY = "Status";
     * OBJECT_TYPE_KEY = "objectType";
     * <p>
     * Uses:
     * ClassificationWebConverter
     * ExternalIdentifierWebConverter
     * SlotWebConverter
     * InternationalStringTypeHelper
     *
     * @param registryObject the RegistryObjectType to be converted into a map, null returns empty Map
     * @return Map<String, Object> representation of the RegistryObjectType provided
     */
public Map<String, Object> convertRegistryObject(RegistryObjectType registryObject) {
    Map<String, Object> registryObjectMap = new HashMap<>();
    if (registryObject.isSetClassification()) {
        List<Map<String, Object>> classifications = new ArrayList<>();
        ClassificationWebConverter classificationConverter = new ClassificationWebConverter();
        for (ClassificationType classification : registryObject.getClassification()) {
            Map<String, Object> classificationMap = classificationConverter.convert(classification);
            if (MapUtils.isNotEmpty(classificationMap)) {
                classifications.add(classificationMap);
            }
        }
        webMapHelper.putIfNotEmpty(registryObjectMap, CLASSIFICATION_KEY, classifications);
    }
    webMapHelper.putIfNotEmpty(registryObjectMap, DESCRIPTION_KEY, registryObject.getDescription());
    if (registryObject.isSetExternalIdentifier()) {
        List<Map<String, Object>> externalIdentifiers = new ArrayList<>();
        ExternalIdentifierWebConverter externalIdentifierConverter = new ExternalIdentifierWebConverter();
        for (ExternalIdentifierType externalIdentifier : registryObject.getExternalIdentifier()) {
            Map<String, Object> externalIdentifierMap = externalIdentifierConverter.convert(externalIdentifier);
            if (MapUtils.isNotEmpty(externalIdentifierMap)) {
                externalIdentifiers.add(externalIdentifierMap);
            }
        }
        webMapHelper.putIfNotEmpty(registryObjectMap, EXTERNAL_IDENTIFIER_KEY, externalIdentifiers);
    }
    webMapHelper.putIfNotEmpty(registryObjectMap, HOME_KEY, registryObject.getHome());
    webMapHelper.putIfNotEmpty(registryObjectMap, ID_KEY, registryObject.getId());
    webMapHelper.putIfNotEmpty(registryObjectMap, LID_KEY, registryObject.getLid());
    webMapHelper.putIfNotEmpty(registryObjectMap, NAME_KEY, registryObject.getName());
    webMapHelper.putIfNotEmpty(registryObjectMap, OBJECT_TYPE_KEY, registryObject.getObjectType());
    if (registryObject.isSetSlot()) {
        List<Map<String, Object>> slots = new ArrayList<>();
        SlotWebConverter slotConverter = new SlotWebConverter();
        for (SlotType1 slot : registryObject.getSlot()) {
            Map<String, Object> slotMap = slotConverter.convert(slot);
            if (MapUtils.isNotEmpty(slotMap)) {
                slots.add(slotMap);
            }
        }
        webMapHelper.putIfNotEmpty(registryObjectMap, SLOT, slots);
    }
    webMapHelper.putIfNotEmpty(registryObjectMap, STATUS_KEY, registryObject.getStatus());
    webMapHelper.putIfNotEmpty(registryObjectMap, VERSION_INFO_KEY, registryObject.getVersionInfo());
    return registryObjectMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) ClassificationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ClassificationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType)5 ArrayList (java.util.ArrayList)3 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)3 SlotType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1)3 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)2 ClassificationType (com.google.cloud.automl.v1.ClassificationType)2 Dataset (com.google.cloud.automl.v1.Dataset)2 LocationName (com.google.cloud.automl.v1.LocationName)2 OperationMetadata (com.google.cloud.automl.v1.OperationMetadata)2 JAXBElement (javax.xml.bind.JAXBElement)2 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)2 IdentifiableType (oasis.names.tc.ebxml_regrep.xsd.rim._3.IdentifiableType)2 RegistryObjectListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType)2 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)2 ImageClassificationDatasetMetadata (com.google.cloud.automl.v1.ImageClassificationDatasetMetadata)1 TextClassificationDatasetMetadata (com.google.cloud.automl.v1.TextClassificationDatasetMetadata)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1 AnyValueType (net.opengis.cat.wrs.v_1_0_2.AnyValueType)1