use of com.helger.phoss.smp.domain.pmigration.SMPParticipantMigration 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));
}
use of com.helger.phoss.smp.domain.pmigration.SMPParticipantMigration in project phoss-smp by phax.
the class SMPParticipantMigrationManagerMongoDB method createInboundParticipantMigration.
@Nonnull
public ISMPParticipantMigration createInboundParticipantMigration(@Nonnull final IParticipantIdentifier aParticipantID, @Nonnull @Nonempty final String sMigrationKey) {
final SMPParticipantMigration aSMPParticipantMigration = SMPParticipantMigration.createInbound(aParticipantID, sMigrationKey);
_createParticipantMigration(aSMPParticipantMigration);
return aSMPParticipantMigration;
}
use of com.helger.phoss.smp.domain.pmigration.SMPParticipantMigration 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);
}
use of com.helger.phoss.smp.domain.pmigration.SMPParticipantMigration in project phoss-smp by phax.
the class SMPParticipantMigrationManagerMongoDB method setParticipantMigrationState.
@Nonnull
public EChange setParticipantMigrationState(@Nullable final String sParticipantMigrationID, @Nonnull final EParticipantMigrationState eNewState) {
ValueEnforcer.notNull(eNewState, "NewState");
final SMPParticipantMigration aPM = getParticipantMigrationOfID(sParticipantMigrationID);
if (aPM == null) {
AuditHelper.onAuditModifyFailure(SMPParticipantMigration.OT, "set-migration-state", sParticipantMigrationID, "no-such-id");
return EChange.UNCHANGED;
}
{
EChange eChange = EChange.UNCHANGED;
eChange = eChange.or(aPM.setState(eNewState));
if (eChange.isUnchanged())
return EChange.UNCHANGED;
getCollection().findOneAndReplace(new Document(BSON_ID, sParticipantMigrationID), toBson(aPM));
}
AuditHelper.onAuditModifySuccess(SMPParticipantMigration.OT, "set-migration-state", sParticipantMigrationID, eNewState);
return EChange.CHANGED;
}
use of com.helger.phoss.smp.domain.pmigration.SMPParticipantMigration in project phoss-smp by phax.
the class SMPParticipantMigrationManagerJDBC method getParticipantMigrationOfParticipantID.
@Nullable
public ISMPParticipantMigration getParticipantMigrationOfParticipantID(@Nonnull final EParticipantMigrationDirection eDirection, @Nonnull final EParticipantMigrationState eState, @Nullable final IParticipantIdentifier aParticipantID) {
ValueEnforcer.notNull(eDirection, "Direction");
ValueEnforcer.notNull(eState, "State");
if (aParticipantID == null)
return null;
final Wrapper<DBResultRow> aDBResult = new Wrapper<>();
newExecutor().querySingle("SELECT id, initdt, migkey FROM smp_pmigration WHERE direction=? AND state=? AND pid=?", new ConstantPreparedStatementDataProvider(eDirection.getID(), eState.getID(), aParticipantID.getURIEncoded()), aDBResult::set);
if (aDBResult.isNotSet())
return null;
final DBResultRow aRow = aDBResult.get();
return new SMPParticipantMigration(aRow.getAsString(0), eDirection, eState, aParticipantID, aRow.getAsLocalDateTime(1), aRow.getAsString(2));
}
Aggregations