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));
}
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"));
}
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));
}
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);
}
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);
}
Aggregations