Search in sources :

Example 6 with PersonType

use of org.talend.types.test.library.common._1.PersonType in project ddf by codice.

the class RegistryPackageConverter method getRegistryObjectMetacard.

public static Metacard getRegistryObjectMetacard(RegistryObjectType registryObject, MetacardType metacardType) throws RegistryConversionException {
    MetacardImpl metacard = null;
    if (registryObject == null) {
        return metacard;
    }
    validateIdentifiable(registryObject);
    metacard = new MetacardImpl(metacardType);
    parseTopLevel(registryObject, metacard);
    if (registryObject instanceof RegistryPackageType) {
        parseRegistryPackage((RegistryPackageType) registryObject, metacard);
    } else if (registryObject instanceof ExtrinsicObjectType) {
        parseNodeExtrinsicObject(registryObject, metacard);
    } else if (registryObject instanceof ServiceType) {
        parseRegistryService((ServiceType) registryObject, metacard);
    } else if (registryObject instanceof OrganizationType) {
        parseRegistryOrganization((OrganizationType) registryObject, metacard);
    } else if (registryObject instanceof PersonType) {
        parseRegistryPerson((PersonType) registryObject, metacard);
    } else {
        LOGGER.debug("Unexpected object found: {}", registryObject);
    }
    return metacard;
}
Also used : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) ServiceType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 7 with PersonType

use of org.talend.types.test.library.common._1.PersonType in project ddf by codice.

the class RegistryObjectListWebConverter method convert.

/**
     * This method creates a Map<String, Object> representation of the RegistryObjectListType provided.
     * The following keys will be added to the map (Taken from EbrimConstants):
     * <p>
     * ASSOCIATION_KEY = "Association";
     * EXTRINSIC_OBJECT_KEY = "ExtrinsicObject";
     * ORGANIZATION_KEY = "Organization";
     * PERSON_KEY = "Person";
     * SERVICE_KEY = "Service";
     * <p>
     * <p>
     * Uses:
     * AssociationWebConverter
     * ExtrinsicObjectWebConverter
     * OrganizationWebConverter
     * PersonWebConverter
     * ServiceWebConverter
     *
     * @param registryObjectList the RegistryObjectListType to be converted into a map, null returns empty Map
     * @return Map<String, Object> representation of the RegistryObjectListType provided
     */
public Map<String, Object> convert(RegistryObjectListType registryObjectList) {
    Map<String, Object> registryObjectListMap = new HashMap<>();
    if (registryObjectList == null) {
        return registryObjectListMap;
    }
    List<Map<String, Object>> associations = new ArrayList<>();
    List<Map<String, Object>> extrinsicObjects = new ArrayList<>();
    List<Map<String, Object>> organizations = new ArrayList<>();
    List<Map<String, Object>> people = new ArrayList<>();
    List<Map<String, Object>> services = new ArrayList<>();
    AssociationWebConverter associationConverter = new AssociationWebConverter();
    ExtrinsicObjectWebConverter extrinsicObjectConverter = new ExtrinsicObjectWebConverter();
    OrganizationWebConverter organizationConverter = new OrganizationWebConverter();
    PersonWebConverter personConverter = new PersonWebConverter();
    ServiceWebConverter serviceConverter = new ServiceWebConverter();
    for (JAXBElement<? extends IdentifiableType> identifiable : registryObjectList.getIdentifiable()) {
        RegistryObjectType registryObject = (RegistryObjectType) identifiable.getValue();
        Map<String, Object> identifiableMap;
        if (registryObject instanceof ExtrinsicObjectType) {
            identifiableMap = extrinsicObjectConverter.convert((ExtrinsicObjectType) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                extrinsicObjects.add(identifiableMap);
            }
        } else if (registryObject instanceof ServiceType) {
            identifiableMap = serviceConverter.convert((ServiceType) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                services.add(identifiableMap);
            }
        } else if (registryObject instanceof OrganizationType) {
            identifiableMap = organizationConverter.convert((OrganizationType) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                organizations.add(identifiableMap);
            }
        } else if (registryObject instanceof PersonType) {
            identifiableMap = personConverter.convert((PersonType) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                people.add(identifiableMap);
            }
        } else if (registryObject instanceof AssociationType1) {
            identifiableMap = associationConverter.convert((AssociationType1) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                associations.add(identifiableMap);
            }
        }
    }
    webMapHelper.putIfNotEmpty(registryObjectListMap, ASSOCIATION_KEY, associations);
    webMapHelper.putIfNotEmpty(registryObjectListMap, EXTRINSIC_OBJECT_KEY, extrinsicObjects);
    webMapHelper.putIfNotEmpty(registryObjectListMap, ORGANIZATION_KEY, organizations);
    webMapHelper.putIfNotEmpty(registryObjectListMap, PERSON_KEY, people);
    webMapHelper.putIfNotEmpty(registryObjectListMap, SERVICE_KEY, services);
    return registryObjectListMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AssociationType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) ServiceType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType) HashMap(java.util.HashMap) Map(java.util.Map) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 8 with PersonType

use of org.talend.types.test.library.common._1.PersonType in project ddf by codice.

the class RegistryPackageTypeHelperTest method testGetObjectsAssociatedToServiceFromRegistryObjectList.

@Test
public void testGetObjectsAssociatedToServiceFromRegistryObjectList() throws Exception {
    String testServiceId = "urn:service:id0";
    RegistryObjectListType registryObjectList = ((RegistryPackageType) registryObject).getRegistryObjectList();
    List<OrganizationType> organizations = rptHelper.getAssociatedObjects(registryObjectList, testServiceId, OrganizationType.class);
    assertThat(organizations, hasSize(1));
    assertThat(organizations.get(0).getId(), is(equalTo("urn:organization:id0")));
    List<PersonType> contacts = rptHelper.getAssociatedObjects(testServiceId, PersonType.class);
    assertThat(contacts, hasSize(1));
    assertThat(contacts.get(0).getId(), is(equalTo("urn:contact:id1")));
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) Test(org.junit.Test)

Example 9 with PersonType

use of org.talend.types.test.library.common._1.PersonType in project tesb-rt-se by Talend.

the class LibraryServerImpl method seekBook.

@Override
public ListOfBooks seekBook(SearchFor body) throws SeekBookError {
    System.out.println("***************************************************************");
    System.out.println("*** seekBook request (Request-Response operation) is received *");
    System.out.println("***************************************************************");
    showSeekBookRequest(body);
    List<String> authorsLastNames = body.getAuthorLastName();
    if (authorsLastNames != null && authorsLastNames.size() > 0) {
        String authorsLastName = authorsLastNames.get(0);
        if (authorsLastName != null && authorsLastName.length() > 0 && !"Icebear".equalsIgnoreCase(authorsLastName)) {
            SeekBookError e = prepareException("No book available from author " + authorsLastName);
            System.out.println("No book available from author " + authorsLastName);
            System.out.println("\nSending business fault (SeekBook error) with parameters:");
            throw e;
        }
    }
    ListOfBooks result = new ListOfBooks();
    BookType book = new BookType();
    result.getBook().add(book);
    PersonType author = new PersonType();
    book.getAuthor().add(author);
    author.setFirstName("Jack");
    author.setLastName("Icebear");
    Calendar dateOfBirth = new GregorianCalendar(101, Calendar.JANUARY, 2);
    author.setDateOfBirth(dateOfBirth.getTime());
    book.getTitle().add("Survival in the Arctic");
    book.getPublisher().add("Frosty Edition");
    book.setYearPublished("2010");
    System.out.println("Book(s) is found:");
    showSeekBookResponse(result);
    return result;
}
Also used : BookType(org.talend.types.test.library.common._1.BookType) SeekBookError(org.talend.services.test.library._1_0.SeekBookError) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) PersonType(org.talend.types.test.library.common._1.PersonType) ListOfBooks(org.talend.types.test.library.common._1.ListOfBooks)

Example 10 with PersonType

use of org.talend.types.test.library.common._1.PersonType in project tesb-rt-se by Talend.

the class LibraryServerImpl method seekBook.

@Override
public ListOfBooks seekBook(SearchFor body) throws SeekBookError {
    System.out.println("***************************************************************");
    System.out.println("*** seekBook request (Request-Response operation) is received *");
    System.out.println("***************************************************************");
    showSeekBookRequest(body);
    List<String> authorsLastNames = body.getAuthorLastName();
    if (authorsLastNames != null && authorsLastNames.size() > 0) {
        String authorsLastName = authorsLastNames.get(0);
        if (authorsLastName != null && authorsLastName.length() > 0 && !"Icebear".equalsIgnoreCase(authorsLastName)) {
            SeekBookError e = prepareException("No book available from author " + authorsLastName);
            System.out.println("No book available from author " + authorsLastName);
            System.out.println("\nSending business fault (SeekBook error) with parameters:");
            throw e;
        }
    }
    ListOfBooks result = new ListOfBooks();
    BookType book = new BookType();
    result.getBook().add(book);
    PersonType author = new PersonType();
    book.getAuthor().add(author);
    author.setFirstName("Jack");
    author.setLastName("Icebear");
    Calendar dateOfBirth = new GregorianCalendar(101, Calendar.JANUARY, 2);
    author.setDateOfBirth(dateOfBirth.getTime());
    book.getTitle().add("Survival in the Arctic");
    book.getPublisher().add("Frosty Edition");
    book.setYearPublished("2010");
    System.out.println("Book(s) is found:");
    showSeekBookResponse(result);
    return result;
}
Also used : BookType(org.talend.types.test.library.common._1.BookType) SeekBookError(org.talend.services.test.library._1_0.SeekBookError) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) PersonType(org.talend.types.test.library.common._1.PersonType) ListOfBooks(org.talend.types.test.library.common._1.ListOfBooks)

Aggregations

PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)10 Calendar (java.util.Calendar)8 GregorianCalendar (java.util.GregorianCalendar)8 OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)5 SeekBookError (org.talend.services.test.library._1_0.SeekBookError)5 BookType (org.talend.types.test.library.common._1.BookType)5 ListOfBooks (org.talend.types.test.library.common._1.ListOfBooks)5 PersonType (org.talend.types.test.library.common._1.PersonType)5 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)4 ServiceType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType)4 BookType (org.talend.types.demos.library.common._1.BookType)4 PersonType (org.talend.types.demos.library.common._1.PersonType)4 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)3 RegistryObjectListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType)3 RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 SeekBookError (org.talend.services.demos.library._1_0.SeekBookError)2