Search in sources :

Example 6 with IProcessIdentifier

use of com.helger.peppolid.IProcessIdentifier in project peppol-commons by phax.

the class SimpleIdentifierFactoryTest method testProcessIDCaseInsensitive.

@Test
public void testProcessIDCaseInsensitive() {
    final SimpleIdentifierFactory aIF = SimpleIdentifierFactory.INSTANCE;
    // Default scheme - handle case insensitive
    final String sScheme = CBDXR1Identifier.DEFAULT_PROCESS_IDENTIFIER_SCHEME;
    final IProcessIdentifier aID1 = aIF.createProcessIdentifier(sScheme, "abc");
    assertEquals(sScheme, aID1.getScheme());
    assertEquals("abc", aID1.getValue());
    // Value is lower case internally
    final IProcessIdentifier aID2 = aIF.createProcessIdentifier(sScheme, "ABC");
    assertEquals(sScheme, aID2.getScheme());
    assertEquals("ABC", aID2.getValue());
    assertFalse(aID1.hasSameContent(aID2));
}
Also used : IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) Test(org.junit.Test)

Example 7 with IProcessIdentifier

use of com.helger.peppolid.IProcessIdentifier in project peppol-commons by phax.

the class PeppolProcessIdentifierTest method testURIStuff.

@Test
public void testURIStuff() {
    final IIdentifierFactory aIF = PeppolIdentifierFactory.INSTANCE;
    final IProcessIdentifier aID1 = new PeppolProcessIdentifier("scheme1", "value1");
    assertEquals("scheme1::value1", aID1.getURIEncoded());
    assertEquals("scheme1%3A%3Avalue1", aID1.getURIPercentEncoded());
    final IProcessIdentifier aID2 = aIF.parseProcessIdentifier("scheme1::value1");
    assertEquals(aID1, aID2);
    assertNull(aIF.parseProcessIdentifier("scheme1"));
    assertNull(aIF.parseProcessIdentifier(null));
    assertNull(aIF.parseProcessIdentifier(""));
    assertNotNull(aIF.parseProcessIdentifier("process::proc1"));
    assertNotNull(aIF.parseProcessIdentifier("process::proc2 "));
    assertNull(aIF.parseProcessIdentifier("processany-actorid-dummythatiswaytoolongforwhatisexpected::proc2"));
    assertNull(aIF.parseProcessIdentifier("process::" + StringHelper.getRepeated('a', PeppolIdentifierHelper.MAX_PROCESS_VALUE_LENGTH + 1)));
    assertNull(aIF.parseProcessIdentifier("process:proc2"));
    assertNull(aIF.parseProcessIdentifier("processproc2"));
}
Also used : IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) Test(org.junit.Test)

Example 8 with IProcessIdentifier

use of com.helger.peppolid.IProcessIdentifier in project peppol-commons by phax.

the class BDXR1IdentifierFactoryTest method testProcessIDCaseSensitive.

@Test
public void testProcessIDCaseSensitive() {
    final BDXR1IdentifierFactory aIF = BDXR1IdentifierFactory.INSTANCE;
    // Different scheme - handle case sensitive
    final String sScheme = "cs-docid-qns";
    final IProcessIdentifier aID1 = aIF.createProcessIdentifier(sScheme, "abc");
    assertEquals(sScheme, aID1.getScheme());
    assertEquals("abc", aID1.getValue());
    // Value is NOT lower cased internally
    final IProcessIdentifier aID2 = aIF.createProcessIdentifier(sScheme, "ABC");
    assertEquals(sScheme, aID2.getScheme());
    assertEquals("ABC", aID2.getValue());
    assertFalse(aID1.hasSameContent(aID2));
}
Also used : IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) Test(org.junit.Test)

Example 9 with IProcessIdentifier

use of com.helger.peppolid.IProcessIdentifier in project phoss-smp by phax.

the class SMPServiceInformationManagerJDBC method deleteSMPProcess.

@Nonnull
public EChange deleteSMPProcess(@Nullable final ISMPServiceInformation aSMPServiceInformation, @Nullable final ISMPProcess aProcess) {
    if (aSMPServiceInformation == null || aProcess == null)
        return EChange.UNCHANGED;
    final Wrapper<Long> ret = new Wrapper<>(Long.valueOf(0));
    final DBExecutor aExecutor = newExecutor();
    final ESuccess eSuccess = aExecutor.performInTransaction(() -> {
        final IParticipantIdentifier aPID = aSMPServiceInformation.getServiceGroup().getParticipantIdentifier();
        final IDocumentTypeIdentifier aDocTypeID = aSMPServiceInformation.getDocumentTypeIdentifier();
        final IProcessIdentifier aProcessID = aProcess.getProcessIdentifier();
        final long nCountEP = aExecutor.insertOrUpdateOrDelete("DELETE FROM smp_endpoint" + " WHERE businessIdentifierScheme=? AND businessIdentifier=? AND documentIdentifierScheme=? AND documentIdentifier=? AND processIdentifierType=? AND processIdentifier=?", new ConstantPreparedStatementDataProvider(aPID.getScheme(), aPID.getValue(), aDocTypeID.getScheme(), aDocTypeID.getValue(), aProcessID.getScheme(), aProcessID.getValue()));
        final long nCountProc = aExecutor.insertOrUpdateOrDelete("DELETE FROM smp_process" + " WHERE businessIdentifierScheme=? AND businessIdentifier=? AND documentIdentifierScheme=? AND documentIdentifier=? AND processIdentifierType=? AND processIdentifier=?", new ConstantPreparedStatementDataProvider(aPID.getScheme(), aPID.getValue(), aDocTypeID.getScheme(), aDocTypeID.getValue(), aProcessID.getScheme(), aProcessID.getValue()));
        ret.set(Long.valueOf(nCountEP + nCountProc));
    });
    if (eSuccess.isFailure())
        return EChange.UNCHANGED;
    return EChange.valueOf(ret.get().longValue() > 0);
}
Also used : ESuccess(com.helger.commons.state.ESuccess) Wrapper(com.helger.commons.wrapper.Wrapper) DBExecutor(com.helger.db.jdbc.executor.DBExecutor) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull)

Example 10 with IProcessIdentifier

use of com.helger.peppolid.IProcessIdentifier in project phoss-smp by phax.

the class SMPServiceInformationManagerMongoDB method toProcess.

@Nullable
@ReturnsMutableCopy
public static SMPProcess toProcess(@Nonnull final Document aDoc) {
    final IProcessIdentifier aProcessID = toProcessID((Document) aDoc.get(BSON_PROCESS_ID));
    final List<Document> aEndpointDocs = aDoc.getList(BSON_ENDPOINTS, Document.class);
    if (aEndpointDocs == null)
        return null;
    final ICommonsList<SMPEndpoint> aEndpoints = new CommonsArrayList<>();
    for (final Document aDocEP : aEndpointDocs) aEndpoints.add(toEndpoint(aDocEP));
    final String sExtension = aDoc.getString(BSON_EXTENSIONS);
    return new SMPProcess(aProcessID, aEndpoints, sExtension);
}
Also used : SMPProcess(com.helger.phoss.smp.domain.serviceinfo.SMPProcess) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) SMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) Document(org.bson.Document) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nullable(javax.annotation.Nullable)

Aggregations

IProcessIdentifier (com.helger.peppolid.IProcessIdentifier)26 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)14 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)12 Test (org.junit.Test)12 SimpleProcessIdentifier (com.helger.peppolid.simple.process.SimpleProcessIdentifier)6 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)6 ISMPProcess (com.helger.phoss.smp.domain.serviceinfo.ISMPProcess)6 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)5 Nonnull (javax.annotation.Nonnull)5 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)4 SimpleDocumentTypeIdentifier (com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier)4 ISMPEndpoint (com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint)4 EndpointType (com.helger.xsds.peppol.smp1.EndpointType)4 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)3 CommonsHashSet (com.helger.commons.collection.impl.CommonsHashSet)3 XMLOffsetDateTime (com.helger.commons.datetime.XMLOffsetDateTime)3 CommonsLinkedHashMap (com.helger.commons.collection.impl.CommonsLinkedHashMap)2 PDTFromString (com.helger.commons.datetime.PDTFromString)2 PDTToString (com.helger.commons.datetime.PDTToString)2 ESuccess (com.helger.commons.state.ESuccess)2