use of com.axelor.apps.base.db.SyncContact in project axelor-open-suite by axelor.
the class SyncContactService method getKeyAndClientId.
@POST
@Path("/key/{id}")
public SyncContactResponse getKeyAndClientId(@PathParam("id") Long id) {
SyncContact syncContact = syncContactRepo.find(id);
if (syncContact == null) {
return null;
}
SyncContactResponse response = new SyncContactResponse();
response.setClientid(syncContact.getCid());
response.setKey(syncContact.getGoogleApiKey());
response.setAuthFailed(I18n.get(SYNC_CONTACT_AUTH_FAILED));
response.setImportSuccessful(I18n.get(SYNC_CONTACT_IMPORT_SUCCESSFUL));
response.setNoImport(I18n.get(SYNC_CONTACT_NO_IMPORT));
return response;
}
use of com.axelor.apps.base.db.SyncContact in project axelor-open-suite by axelor.
the class SyncContactService method updateSyncContact.
@Transactional(rollbackOn = { AxelorException.class, Exception.class })
public void updateSyncContact(Long id, SyncContactHistoric syncContactHistoric) {
SyncContact syncContact;
syncContact = syncContactRepo.find(id);
syncContactHistoric.setUser(userService.getUser());
Set<Partner> partnerSet = new HashSet<>();
for (Partner partner : syncContactHistoric.getPartnerSet()) {
Partner find = partnerRepo.find(partner.getId());
if (find != null) {
partnerSet.add(find);
}
}
syncContactHistoric.clearPartnerSet();
syncContactHistoric.setPartnerSet(partnerSet);
syncContact.addSyncContactHistoricListItem(syncContactHistoric);
syncContactRepo.save(syncContact);
}
use of com.axelor.apps.base.db.SyncContact in project axelor-open-suite by axelor.
the class SyncContactService method importAllContact.
public void importAllContact(Long id, List<Person> people) {
int i = 0;
SyncContact syncContact = syncContactRepo.find(id);
if (syncContact == null) {
return;
}
SyncContactHistoric syncContactHistoric = new SyncContactHistoric();
for (Person googlePerson : people) {
Partner partner = importContact(googlePerson, syncContact.getUpdateContactField());
if (partner != null) {
syncContactHistoric.addPartnerSetItem(partner);
}
if (i % 10 == 0) {
JPA.clear();
}
i++;
}
updateSyncContact(id, syncContactHistoric);
}
Aggregations