Search in sources :

Example 1 with PDIdentifier

use of com.helger.pd.businesscard.generic.PDIdentifier in project phoss-directory by phax.

the class ExportHelper method getAsXML.

@Nonnull
public static IMicroDocument getAsXML(@Nonnull final ICommonsOrderedMap<IParticipantIdentifier, ICommonsList<PDStoredBusinessEntity>> aMap, final boolean bIncludeDocTypes) {
    // XML root
    final IMicroDocument aDoc = new MicroDocument();
    final IMicroElement aRoot = aDoc.appendElement(XML_EXPORT_NS_URI, "root");
    aRoot.setAttribute("version", "2");
    aRoot.setAttribute("creationdt", PDTWebDateHelper.getAsStringXSD(PDTFactory.getCurrentZonedDateTimeUTC()));
    // For all BCs
    for (final Map.Entry<IParticipantIdentifier, ICommonsList<PDStoredBusinessEntity>> aEntry : aMap.entrySet()) {
        final IParticipantIdentifier aParticipantID = aEntry.getKey();
        final PDBusinessCard aBC = new PDBusinessCard();
        aBC.setParticipantIdentifier(new PDIdentifier(aParticipantID.getScheme(), aParticipantID.getValue()));
        for (final PDStoredBusinessEntity aSBE : aEntry.getValue()) aBC.businessEntities().add(aSBE.getAsBusinessEntity());
        final IMicroElement eBC = aBC.getAsMicroXML(XML_EXPORT_NS_URI, "businesscard");
        // New in v2 - add all Document types
        if (bIncludeDocTypes && aEntry.getValue().isNotEmpty())
            for (final IDocumentTypeIdentifier aDocTypeID : aEntry.getValue().getFirst().documentTypeIDs()) eBC.appendChild(_createMicroElement(aDocTypeID));
        aRoot.appendChild(eBC);
    }
    return aDoc;
}
Also used : PDIdentifier(com.helger.pd.businesscard.generic.PDIdentifier) IMicroDocument(com.helger.xml.microdom.IMicroDocument) MicroDocument(com.helger.xml.microdom.MicroDocument) ICommonsList(com.helger.commons.collection.impl.ICommonsList) PDBusinessCard(com.helger.pd.businesscard.generic.PDBusinessCard) PDStoredBusinessEntity(com.helger.pd.indexer.storage.PDStoredBusinessEntity) IMicroElement(com.helger.xml.microdom.IMicroElement) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IMicroDocument(com.helger.xml.microdom.IMicroDocument) ICommonsOrderedMap(com.helger.commons.collection.impl.ICommonsOrderedMap) Map(java.util.Map) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull)

Example 2 with PDIdentifier

use of com.helger.pd.businesscard.generic.PDIdentifier in project phoss-directory by phax.

the class PDStoredBusinessEntity method getAsBusinessCard.

/**
 * @return This {@link PDStoredBusinessEntity} as a {@link PDBusinessCard}.
 */
@Nonnull
@ReturnsMutableCopy
public PDBusinessCard getAsBusinessCard() {
    final PDBusinessCard ret = new PDBusinessCard();
    ret.setParticipantIdentifier(new PDIdentifier(m_aParticipantID.getScheme(), m_aParticipantID.getValue()));
    // We have a single entity
    ret.businessEntities().add(getAsBusinessEntity());
    return ret;
}
Also used : PDIdentifier(com.helger.pd.businesscard.generic.PDIdentifier) PDBusinessCard(com.helger.pd.businesscard.generic.PDBusinessCard) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 3 with PDIdentifier

use of com.helger.pd.businesscard.generic.PDIdentifier in project phoss-directory by phax.

the class IndexerResourceTest method _createMockBC.

@Nonnull
private static PDExtendedBusinessCard _createMockBC(@Nonnull final IParticipantIdentifier aParticipantID) {
    final PDBusinessCard aBI = new PDBusinessCard();
    aBI.setParticipantIdentifier(new PDIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "9915:mock"));
    {
        final PDBusinessEntity aEntity = new PDBusinessEntity();
        aEntity.names().add(new PDName("Philip's mock Peppol receiver"));
        aEntity.setCountryCode("AT");
        aEntity.identifiers().add(new PDIdentifier("mock", "12345678"));
        aEntity.identifiers().add(new PDIdentifier(aParticipantID.getScheme(), aParticipantID.getValue()));
        aEntity.setAdditionalInfo("This is a mock entry for testing purposes only");
        aBI.businessEntities().add(aEntity);
    }
    {
        final PDBusinessEntity aEntity = new PDBusinessEntity();
        aEntity.names().add(new PDName("Philip's mock Peppol receiver 2"));
        aEntity.setCountryCode("NO");
        aEntity.identifiers().add(new PDIdentifier("mock", "abcdefgh"));
        aEntity.setAdditionalInfo("This is another mock entry for testing purposes only");
        aBI.businessEntities().add(aEntity);
    }
    return new PDExtendedBusinessCard(aBI, new CommonsArrayList<>(EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30.getAsDocumentTypeIdentifier()));
}
Also used : PDIdentifier(com.helger.pd.businesscard.generic.PDIdentifier) PDBusinessCard(com.helger.pd.businesscard.generic.PDBusinessCard) PDName(com.helger.pd.businesscard.generic.PDName) PDBusinessEntity(com.helger.pd.businesscard.generic.PDBusinessEntity) PDExtendedBusinessCard(com.helger.pd.indexer.businesscard.PDExtendedBusinessCard) Nonnull(javax.annotation.Nonnull)

Example 4 with PDIdentifier

use of com.helger.pd.businesscard.generic.PDIdentifier in project phoss-directory by phax.

the class LocalHost8080FuncTest method _createMockBC.

@Nonnull
private static PDExtendedBusinessCard _createMockBC(@Nonnull final IParticipantIdentifier aParticipantID) {
    final PDBusinessCard aBI = new PDBusinessCard();
    aBI.setParticipantIdentifier(new PDIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "9915:mock"));
    {
        final PDBusinessEntity aEntity = new PDBusinessEntity();
        aEntity.names().add(new PDName("Philip's mock Peppol receiver"));
        aEntity.setCountryCode("AT");
        aEntity.identifiers().add(new PDIdentifier("mock", "12345678"));
        aEntity.identifiers().add(new PDIdentifier(aParticipantID.getScheme(), aParticipantID.getValue()));
        aEntity.setAdditionalInfo("This is a mock entry for testing purposes only");
        aBI.businessEntities().add(aEntity);
    }
    {
        final PDBusinessEntity aEntity = new PDBusinessEntity();
        aEntity.names().add(new PDName("Philip's mock Peppol receiver 2"));
        aEntity.setCountryCode("NO");
        aEntity.identifiers().add(new PDIdentifier("mock", "abcdefgh"));
        aEntity.setAdditionalInfo("This is another mock entry for testing purposes only");
        aBI.businessEntities().add(aEntity);
    }
    return new PDExtendedBusinessCard(aBI, new CommonsArrayList<>(EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30.getAsDocumentTypeIdentifier()));
}
Also used : PDIdentifier(com.helger.pd.businesscard.generic.PDIdentifier) PDBusinessCard(com.helger.pd.businesscard.generic.PDBusinessCard) PDName(com.helger.pd.businesscard.generic.PDName) PDBusinessEntity(com.helger.pd.businesscard.generic.PDBusinessEntity) PDExtendedBusinessCard(com.helger.pd.indexer.businesscard.PDExtendedBusinessCard) Nonnull(javax.annotation.Nonnull)

Example 5 with PDIdentifier

use of com.helger.pd.businesscard.generic.PDIdentifier in project phoss-directory by phax.

the class PDStorageManagerTest method _createMockBI.

@Nonnull
private static PDExtendedBusinessCard _createMockBI(@Nonnull final IParticipantIdentifier aParticipantID) {
    final PDBusinessCard aBI = new PDBusinessCard();
    aBI.setParticipantIdentifier(new PDIdentifier(aParticipantID.getScheme(), aParticipantID.getValue()));
    {
        final PDBusinessEntity aEntity = new PDBusinessEntity();
        aEntity.setCountryCode("AT");
        aEntity.setRegistrationDate(PDTFactory.createLocalDate(2015, Month.JULY, 6));
        aEntity.names().add(new PDName("Philip's mock Peppol receiver"));
        aEntity.setGeoInfo("Vienna");
        for (int i = 0; i < 10; ++i) aEntity.identifiers().add(new PDIdentifier("scheme" + i, "value" + i));
        aEntity.websiteURIs().add("http://www.peppol.eu");
        aEntity.contacts().add(new PDContact("support", "BC name", "12345", "test@example.org"));
        aEntity.setAdditionalInfo("This is a mock entry for testing purposes only");
        aBI.businessEntities().add(aEntity);
    }
    {
        final PDBusinessEntity aEntity = new PDBusinessEntity();
        aEntity.setCountryCode("NO");
        aEntity.names().add(new PDName("Entity2a", "no"));
        aEntity.names().add(new PDName("Entity2b", "de"));
        aEntity.names().add(new PDName("Entity2c", "en"));
        aEntity.setAdditionalInfo("Mock");
        aBI.businessEntities().add(aEntity);
    }
    return new PDExtendedBusinessCard(aBI, new CommonsArrayList<>(EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30));
}
Also used : PDIdentifier(com.helger.pd.businesscard.generic.PDIdentifier) PDBusinessCard(com.helger.pd.businesscard.generic.PDBusinessCard) PDName(com.helger.pd.businesscard.generic.PDName) PDBusinessEntity(com.helger.pd.businesscard.generic.PDBusinessEntity) PDContact(com.helger.pd.businesscard.generic.PDContact) PDExtendedBusinessCard(com.helger.pd.indexer.businesscard.PDExtendedBusinessCard) Nonnull(javax.annotation.Nonnull)

Aggregations

PDIdentifier (com.helger.pd.businesscard.generic.PDIdentifier)7 Nonnull (javax.annotation.Nonnull)7 PDBusinessCard (com.helger.pd.businesscard.generic.PDBusinessCard)6 PDName (com.helger.pd.businesscard.generic.PDName)5 PDBusinessEntity (com.helger.pd.businesscard.generic.PDBusinessEntity)4 PDContact (com.helger.pd.businesscard.generic.PDContact)3 PDExtendedBusinessCard (com.helger.pd.indexer.businesscard.PDExtendedBusinessCard)3 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)2 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)1 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)1 ICommonsList (com.helger.commons.collection.impl.ICommonsList)1 ICommonsOrderedMap (com.helger.commons.collection.impl.ICommonsOrderedMap)1 PDStoredBusinessEntity (com.helger.pd.indexer.storage.PDStoredBusinessEntity)1 PDField (com.helger.pd.indexer.storage.field.PDField)1 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)1 IMicroDocument (com.helger.xml.microdom.IMicroDocument)1 IMicroElement (com.helger.xml.microdom.IMicroElement)1 MicroDocument (com.helger.xml.microdom.MicroDocument)1 Map (java.util.Map)1 Document (org.apache.lucene.document.Document)1