use of org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity in project ORCID-Source by ORCID.
the class LoadRinggoldData method processDeletedIdsLine.
private void processDeletedIdsLine(String[] line) {
String deletedSourceId = line[0];
String replacementSourceId = line[1];
OrgDisambiguatedEntity deletedEntity = orgDisambiguatedDao.findBySourceIdAndSourceType(deletedSourceId, RINGGOLD_SOURCE_TYPE);
if (deletedEntity != null) {
LOGGER.info("Deleted ID exists in DB, id={}", deletedSourceId);
Long deletedEntityId = deletedEntity.getId();
OrgDisambiguatedEntity replacementEntity = orgDisambiguatedDao.findBySourceIdAndSourceType(replacementSourceId, RINGGOLD_SOURCE_TYPE);
if (replacementEntity == null) {
LOGGER.warn("Replacement does not exist, id={}", replacementEntity);
numDeletionsSkipped++;
} else {
Long replacementEntityId = replacementEntity.getId();
orgDisambiguatedSolrDao.remove(deletedEntityId);
orgDisambiguatedDao.replace(deletedEntityId, replacementEntityId);
orgDisambiguatedDao.remove(deletedEntityId);
numDeleted++;
}
}
}
use of org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity in project ORCID-Source by ORCID.
the class LoadRinggoldData method checkForDuplicates.
private void checkForDuplicates() {
LOGGER.info("Checking for duplicates");
List<OrgDisambiguatedEntity> duplicates = orgDisambiguatedDao.findDuplicates();
for (OrgDisambiguatedEntity duplicate : duplicates) {
LOGGER.info("Found duplicate: {}\t{}\t{}\t{}\t{}\t{}\t{}", new Object[] { duplicate.getSourceType(), duplicate.getSourceId(), duplicate.getName(), duplicate.getCity(), duplicate.getRegion(), duplicate.getCountry(), duplicate.getOrgType() });
}
LOGGER.info("Finished checking for duplicates");
}
use of org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity in project ORCID-Source by ORCID.
the class OrgDisambiguatedManagerImpl method processOrgsForIndexing.
@Override
public synchronized void processOrgsForIndexing() {
LOGGER.info("About to process disambiguated orgs for indexing");
List<OrgDisambiguatedEntity> entities = null;
do {
entities = orgDisambiguatedDaoReadOnly.findOrgsByIndexingStatus(IndexingStatus.PENDING, 0, INDEXING_CHUNK_SIZE);
LOGGER.info("Found chunk of {} disambiguated orgs for indexing", entities.size());
for (OrgDisambiguatedEntity entity : entities) {
processDisambiguatedOrgInTransaction(entity);
}
} while (!entities.isEmpty());
}
use of org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity in project ORCID-Source by ORCID.
the class OrgManagerImpl method createUpdate.
@Override
public OrgEntity createUpdate(OrgEntity org, Long orgDisambiguatedId) {
OrgEntity existingOrg = orgDao.findByNameCityRegionAndCountry(org.getName(), org.getCity(), org.getRegion(), org.getCountry());
if (existingOrg != null) {
org = existingOrg;
}
if (org.getOrgDisambiguated() == null) {
OrgDisambiguatedEntity disambiguatedOrg = orgDisambiguatedDao.find(orgDisambiguatedId);
if (disambiguatedOrg == null) {
throw new IllegalArgumentException("No such disambiguated org with id=" + orgDisambiguatedId);
}
org.setOrgDisambiguated(disambiguatedOrg);
}
if (org.getSource() == null) {
org.setSource(new SourceEntity(sourceManager.retrieveSourceOrcid()));
}
return orgDao.merge(org);
}
use of org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity in project ORCID-Source by ORCID.
the class OrgManagerImpl method writeDisambiguatedOrgs.
@Override
public void writeDisambiguatedOrgs(Writer writer) {
@SuppressWarnings("resource") CSVWriter csvWriter = new CSVWriter(writer);
csvWriter.writeNext(DISAMBIGUATED_ORGS_HEADER);
int firstResult = 0;
List<OrgDisambiguatedEntity> chunk = null;
do {
chunk = orgDisambiguatedDao.getChunk(firstResult, CHUNK_SIZE);
for (OrgDisambiguatedEntity orgEntity : chunk) {
String[] line = new String[] { String.valueOf(orgEntity.getId()), orgEntity.getSourceId(), orgEntity.getSourceType(), orgEntity.getOrgType(), orgEntity.getName(), orgEntity.getCity(), orgEntity.getRegion(), orgEntity.getCountry().value(), String.valueOf(orgEntity.getPopularity()) };
csvWriter.writeNext(line);
}
firstResult += chunk.size();
} while (!chunk.isEmpty());
}
Aggregations