IdentityCardType cardType = FacadeDB.getInstance().getIdentityCardBroker().getIdentityCardTypeByName(cardTypeWs.getName());
if (cardType == null) {
cardType = new IdentityCardType();
cardType.setDescription(cardTypeWs.getName());
FacadeDB.getInstance().getIdentityCardBroker().save(cardType);
IdentityCardTypeRemote cardTypeRemote = new IdentityCardTypeRemote(cardType);
cardTypeRemote.setRemoteId(cardTypeWs.getId());
FacadeDB.getInstance().getIdentityCardTypeSyncBroker().saveIdentityCardTypeRemote(cardTypeRemote);
} else {
if (FacadeDB.getInstance().getIdentityCardTypeSyncBroker().getIdentityCardTypeRemoteFromCardType(cardType) == null) {
IdentityCardTypeRemote cardTypeRemote = new IdentityCardTypeRemote(cardType);
cardTypeRemote.setRemoteId(cardTypeWs.getId());
FacadeDB.getInstance().getIdentityCardTypeSyncBroker().saveIdentityCardTypeRemote(cardTypeRemote);
}
}
FacadeDB.getInstance().commitTransaction();
}