Search in sources :

Example 11 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class ServiceBindingWebConverter method convert.

/**
     * This method creates a Map<String, Object> representation of the ServiceBindingType provided.
     * The following keys will be added to the map (Taken from EbrimConstants):
     * <p>
     * ACCESS_URI = "accessUri";
     * SERVICE = "service";
     * TARGET_BINDING = "targetBinding";
     * SPECIFICATION_LINK_KEY = "SpecificationLink";
     * <p>
     * This will also try to parse RegistryObjectType values to the map.
     * <p>
     * Uses:
     * SpecificationLinkWebConverter
     *
     * @param binding the ServiceBindingType to be converted into a map, null returns empty Map
     * @return Map<String, Object> representation of the ServiceBindingType provided
     */
public Map<String, Object> convert(ServiceBindingType binding) {
    Map<String, Object> bindingMap = new HashMap<>();
    if (binding == null) {
        return bindingMap;
    }
    webMapHelper.putAllIfNotEmpty(bindingMap, super.convertRegistryObject(binding));
    webMapHelper.putIfNotEmpty(bindingMap, ACCESS_URI, binding.getAccessURI());
    webMapHelper.putIfNotEmpty(bindingMap, SERVICE, binding.getService());
    if (binding.isSetSpecificationLink()) {
        List<Map<String, Object>> specificationLinks = new ArrayList<>();
        SpecificationLinkWebConverter specificationLinkConverter = new SpecificationLinkWebConverter();
        for (SpecificationLinkType specificationLink : binding.getSpecificationLink()) {
            Map<String, Object> specificationLinkMap = specificationLinkConverter.convert(specificationLink);
            if (MapUtils.isNotEmpty(specificationLinkMap)) {
                specificationLinks.add(specificationLinkMap);
            }
        }
        webMapHelper.putIfNotEmpty(bindingMap, SPECIFICATION_LINK_KEY, specificationLinks);
    }
    webMapHelper.putIfNotEmpty(bindingMap, TARGET_BINDING, binding.getTargetBinding());
    return bindingMap;
}
Also used : HashMap(java.util.HashMap) SpecificationLinkType(oasis.names.tc.ebxml_regrep.xsd.rim._3.SpecificationLinkType) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class RegistryPackageTypeHelperTest method getRegistryObjectFromResource.

private static RegistryObjectType getRegistryObjectFromResource(String path) throws ParserException {
    RegistryObjectType rot = null;
    JAXBElement<RegistryObjectType> jaxbRegistryObject = parser.unmarshal(configurator, JAXBElement.class, SlotTypeHelperTest.class.getResourceAsStream(path));
    if (jaxbRegistryObject != null) {
        rot = jaxbRegistryObject.getValue();
    }
    return rot;
}
Also used : RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 13 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class SlotTypeHelperTest method getNameSlotMapDuplicateSlotNamesAllowed.

@Test
public void getNameSlotMapDuplicateSlotNamesAllowed() throws Exception {
    RegistryObjectType rot = getRegistryObjectFromResource("/registry-package-slots-only-with-dup.xml");
    List<SlotType1> slots = rot.getSlot();
    String duplicateSlotCase = "serviceType";
    int expectedSize = 1;
    int expectedServiceTypeSize = 2;
    Map<String, List<SlotType1>> slotMap = stHelper.getNameSlotMapDuplicateSlotNamesAllowed(slots);
    for (SlotType1 slot : slots) {
        String slotName = slot.getName();
        // duplicate slotCase
        if (duplicateSlotCase.equals(slotName)) {
            continue;
        }
        assertThat(slotMap, hasKey(slotName));
        assertThat(slotMap.get(slotName), hasSize(expectedSize));
        SlotType1 mappedSlot = slotMap.get(slotName).get(0);
        assertThat(mappedSlot, is(equalTo(slot)));
    }
    // ServiceType slot is repeated in the test xml
    // Testing that both slots(SOAP & REST) are stored
    List<SlotType1> serviceTypes = slotMap.get(duplicateSlotCase);
    assertThat(serviceTypes, notNullValue());
    assertThat(serviceTypes, hasSize(expectedServiceTypeSize));
    for (SlotType1 serviceTypeSlot : serviceTypes) {
        String value = stHelper.getStringValues(serviceTypeSlot).get(0);
        assertThat(value, anyOf(equalTo("SOAP"), equalTo("REST")));
    }
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) ArrayList(java.util.ArrayList) List(java.util.List) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) Test(org.junit.Test)

Example 14 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class ServiceWebConverter method convert.

/**
     * This method creates a Map<String, Object> representation of the ServiceType provided.
     * The following keys will be added to the map (Taken from EbrimConstants):
     * <p>
     * SERVICE_BINDING_KEY = "ServiceBinding";
     * <p>
     * This will also try to parse RegistryObjectType values to the map.
     * <p>
     * Uses:
     * ServiceBindingWebConverter
     *
     * @param service the ServiceType to be converted into a map, null returns empty Map
     * @return Map<String, Object> representation of the ServiceType provided
     */
public Map<String, Object> convert(ServiceType service) {
    Map<String, Object> serviceMap = new HashMap<>();
    if (service == null) {
        return serviceMap;
    }
    webMapHelper.putAllIfNotEmpty(serviceMap, super.convertRegistryObject(service));
    if (service.isSetServiceBinding()) {
        List<Map<String, Object>> bindings = new ArrayList<>();
        ServiceBindingWebConverter bindingConverter = new ServiceBindingWebConverter();
        for (ServiceBindingType binding : service.getServiceBinding()) {
            Map<String, Object> bindingMap = bindingConverter.convert(binding);
            if (MapUtils.isNotEmpty(bindingMap)) {
                bindings.add(bindingMap);
            }
        }
        webMapHelper.putIfNotEmpty(serviceMap, SERVICE_BINDING_KEY, bindings);
    }
    return serviceMap;
}
Also used : ServiceBindingType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceBindingType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 15 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class IdentificationPluginTest method testIdsAlreadySet.

//test both ids are already set
@Test
public void testIdsAlreadySet() throws Exception {
    //unmarshal metacard.metadata and confirm only local ext id are set to metacard.getId()
    String xml = convert("/registry-both-extid.xml");
    sampleData.setAttribute(Metacard.METADATA, xml);
    CreateRequest result = identificationPlugin.process(new CreateRequestImpl(sampleData));
    Metacard testMetacard = result.getMetacards().get(0);
    String metadata = testMetacard.getMetadata();
    InputStream inputStream = new ByteArrayInputStream(metadata.getBytes(Charsets.UTF_8));
    JAXBElement<RegistryObjectType> registryObjectTypeJAXBElement = parser.unmarshal(configurator, JAXBElement.class, inputStream);
    RegistryObjectType registryObjectType = registryObjectTypeJAXBElement.getValue();
    List<ExternalIdentifierType> extIdList = registryObjectType.getExternalIdentifier();
    for (ExternalIdentifierType singleExtId : extIdList) {
        if (singleExtId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_LOCAL)) {
            assertThat(singleExtId.getValue(), is(testMetacard.getId()));
        } else if (singleExtId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN)) {
            assertThat(singleExtId.getId(), is(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN));
            assertThat(singleExtId.getValue(), is("registryPresetOriginValue"));
        }
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) ByteArrayInputStream(java.io.ByteArrayInputStream) CreateRequest(ddf.catalog.operation.CreateRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) Test(org.junit.Test)

Aggregations

RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)16 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 Map (java.util.Map)6 Test (org.junit.Test)6 InputStream (java.io.InputStream)5 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ExternalIdentifierType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)4 OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)4 PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)4 ServiceType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType)4 SlotType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1)4 Metacard (ddf.catalog.data.Metacard)3 CreateRequest (ddf.catalog.operation.CreateRequest)3 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)3 JAXBElement (javax.xml.bind.JAXBElement)3 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)3 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)2