Search in sources :

Example 1 with EParticipantMigrationDirection

use of com.helger.phoss.smp.domain.pmigration.EParticipantMigrationDirection in project phoss-smp by phax.

the class SMPParticipantMigrationManagerJDBC method getParticipantMigrationOfID.

@Nullable
public SMPParticipantMigration getParticipantMigrationOfID(@Nullable final String sID) {
    if (StringHelper.hasNoText(sID))
        return null;
    final Wrapper<DBResultRow> aDBResult = new Wrapper<>();
    newExecutor().querySingle("SELECT direction, state, pid, initdt, migkey FROM smp_pmigration WHERE id=?", new ConstantPreparedStatementDataProvider(sID), aDBResult::set);
    if (aDBResult.isNotSet())
        return null;
    final DBResultRow aRow = aDBResult.get();
    final EParticipantMigrationDirection eDirection = EParticipantMigrationDirection.getFromIDOrNull(aRow.getAsString(0));
    final EParticipantMigrationState eState = EParticipantMigrationState.getFromIDOrNull(aRow.getAsString(1));
    final IParticipantIdentifier aPI = SMPMetaManager.getIdentifierFactory().parseParticipantIdentifier(aRow.getAsString(2));
    return new SMPParticipantMigration(sID, eDirection, eState, aPI, aRow.getAsLocalDateTime(3), aRow.getAsString(4));
}
Also used : Wrapper(com.helger.commons.wrapper.Wrapper) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) EParticipantMigrationState(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationState) SMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.SMPParticipantMigration) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) EParticipantMigrationDirection(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationDirection) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nullable(javax.annotation.Nullable)

Example 2 with EParticipantMigrationDirection

use of com.helger.phoss.smp.domain.pmigration.EParticipantMigrationDirection in project phoss-smp by phax.

the class SMPParticipantMigrationManagerMongoDB method toDomain.

@Nonnull
@ReturnsMutableCopy
public static SMPParticipantMigration toDomain(@Nonnull final Document aDoc) {
    final String sID = aDoc.getString(BSON_ID);
    final EParticipantMigrationDirection eDirection = EParticipantMigrationDirection.getFromIDOrNull(aDoc.getString(BSON_DIRECTION));
    final EParticipantMigrationState eState = EParticipantMigrationState.getFromIDOrNull(aDoc.getString(BSON_STATE));
    final IParticipantIdentifier aParticipantID = toParticipantID(aDoc.get(BSON_PARTICIPANT_ID, Document.class));
    final LocalDateTime aInitiationDateTime = TypeConverter.convert(aDoc.getDate(BSON_INIT_DT), LocalDateTime.class);
    final String sMigrationKey = aDoc.getString(BSON_MIGRATION_KEY);
    return new SMPParticipantMigration(sID, eDirection, eState, aParticipantID, aInitiationDateTime, sMigrationKey);
}
Also used : LocalDateTime(java.time.LocalDateTime) EParticipantMigrationState(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationState) SMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.SMPParticipantMigration) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) Document(org.bson.Document) EParticipantMigrationDirection(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationDirection) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Aggregations

IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)2 EParticipantMigrationDirection (com.helger.phoss.smp.domain.pmigration.EParticipantMigrationDirection)2 EParticipantMigrationState (com.helger.phoss.smp.domain.pmigration.EParticipantMigrationState)2 ISMPParticipantMigration (com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration)2 SMPParticipantMigration (com.helger.phoss.smp.domain.pmigration.SMPParticipantMigration)2 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)1 Wrapper (com.helger.commons.wrapper.Wrapper)1 ConstantPreparedStatementDataProvider (com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider)1 DBResultRow (com.helger.db.jdbc.executor.DBResultRow)1 LocalDateTime (java.time.LocalDateTime)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 Document (org.bson.Document)1