use of com.helger.phoss.smp.domain.businesscard.SMPBusinessCard in project phoss-smp by phax.
the class SMPBusinessCardManagerJDBC method getAllSMPBusinessCards.
@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPBusinessCard> getAllSMPBusinessCards() {
final ICommonsList<ISMPBusinessCard> ret = new CommonsArrayList<>();
final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT id, pid, name, country, geoinfo, identifiers, websites, contacts, addon, regdate" + " FROM smp_bce");
if (aDBResult != null) {
final IIdentifierFactory aIF = SMPMetaManager.getIdentifierFactory();
// Group by ID
final ICommonsMap<IParticipantIdentifier, ICommonsList<SMPBusinessCardEntity>> aEntityMap = new CommonsHashMap<>();
for (final DBResultRow aRow : aDBResult) {
final SMPBusinessCardEntity aEntity = new SMPBusinessCardEntity(aRow.getAsString(0));
// Single name only
aEntity.names().add(new SMPBusinessCardName(aRow.getAsString(2), null));
aEntity.setCountryCode(aRow.getAsString(3));
aEntity.setGeographicalInformation(aRow.getAsString(4));
aEntity.identifiers().setAll(getJsonAsBCI(aRow.getAsString(5)));
aEntity.websiteURIs().setAll(getJsonAsString(aRow.getAsString(6)));
aEntity.contacts().setAll(getJsonAsBCC(aRow.getAsString(7)));
aEntity.setAdditionalInformation(aRow.getAsString(8));
aEntity.setRegistrationDate(aRow.get(9).getAsLocalDate());
aEntityMap.computeIfAbsent(aIF.parseParticipantIdentifier(aRow.getAsString(1)), k -> new CommonsArrayList<>()).add(aEntity);
}
// Convert
for (final Map.Entry<IParticipantIdentifier, ICommonsList<SMPBusinessCardEntity>> aEntry : aEntityMap.entrySet()) {
final IParticipantIdentifier aPID = aEntry.getKey();
ret.add(new SMPBusinessCard(aPID, aEntry.getValue()));
}
}
return ret;
}
use of com.helger.phoss.smp.domain.businesscard.SMPBusinessCard in project phoss-smp by phax.
the class SMPBusinessCardManagerXML method deleteSMPBusinessCard.
@Nonnull
public EChange deleteSMPBusinessCard(@Nullable final ISMPBusinessCard aSMPBusinessCard) {
if (aSMPBusinessCard == null)
return EChange.UNCHANGED;
if (LOGGER.isDebugEnabled())
LOGGER.debug("deleteSMPBusinessCard (" + aSMPBusinessCard.getID() + ")");
m_aRWLock.writeLock().lock();
try {
final SMPBusinessCard aRealBusinessCard = internalDeleteItem(aSMPBusinessCard.getID());
if (aRealBusinessCard == null) {
AuditHelper.onAuditDeleteFailure(SMPBusinessCard.OT, aSMPBusinessCard.getID(), "no-such-id");
return EChange.UNCHANGED;
}
} finally {
m_aRWLock.writeLock().unlock();
}
AuditHelper.onAuditDeleteSuccess(SMPBusinessCard.OT, aSMPBusinessCard.getID(), Integer.valueOf(aSMPBusinessCard.getEntityCount()));
// Invoke generic callbacks
m_aCBs.forEach(x -> x.onSMPBusinessCardDeleted(aSMPBusinessCard));
if (LOGGER.isDebugEnabled())
LOGGER.debug("deleteSMPBusinessCard successful");
return EChange.CHANGED;
}
Aggregations