use of org.orcid.jaxb.model.record_rc2.Record in project ORCID-Source by ORCID.
the class OrcidRecordToSolrDocumentTest method testOrgIDAndGrantNumber.
@Test
public void testOrgIDAndGrantNumber() throws JAXBException {
Record record = getRecord("/v20record.xml");
OrcidRecordToSolrDocument v20 = new OrcidRecordToSolrDocument(false);
OrcidSolrDocument v20Doc = v20.convert(record, new ArrayList<Funding>());
Assert.assertTrue(v20Doc.getOrganisationIds().containsKey("ringgold-org-id"));
Assert.assertTrue(v20Doc.getOrganisationIds().get("ringgold-org-id").contains("5488"));
Assert.assertTrue(v20Doc.getOrganisationIds().get("ringgold-org-id").contains("4925"));
Assert.assertTrue(v20Doc.getOrganisationNames().get("affiliation-org-name").contains("Open University"));
Assert.assertTrue(v20Doc.getOrganisationNames().get("affiliation-org-name").contains("British Library"));
/*
Assert.assertTrue(v20Doc.getOrganisationNames().get("funding-org-name").contains("THOR - Technical and Human Infrastructure for Open Research"));
Assert.assertTrue(v20Doc.getGrantNumbers().contains("H2020-EU.1.4.1.3."));
*/
}
use of org.orcid.jaxb.model.record_rc2.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordDeserializer method deserialize.
@Override
public Record deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
Record record = new Record();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(record, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(record, objectNode);
// Deserialize archivedBy
JsonNode currentNode = objectNode.get(RECORD_ARCHIVED_BY);
if (currentNode != null) {
record.setArchivedBy(currentNode.textValue());
objectNode.remove(RECORD_ARCHIVED_BY);
}
// Deserialize archivedDate
currentNode = objectNode.get(RECORD_ARCHIVED_DATE);
if (currentNode != null) {
try {
Date parsedDate = Deserialize.parseDateTimeFormat(currentNode.textValue());
record.setArchivedDate(parsedDate);
objectNode.remove(RECORD_ARCHIVED_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The registrering you tried to create " + "has a malformed arkivertDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The registrering you tried to create is malformed. The " + "following fields are not recognised as registrering fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return record;
}
use of org.orcid.jaxb.model.record_rc2.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordService method findRecordByOwnerPaginated.
// All READ operations
public List<Record> findRecordByOwnerPaginated(Integer top, Integer skip) {
if (top == null || top > maxPageSize) {
top = maxPageSize;
}
if (skip == null) {
skip = 0;
}
String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Record> criteriaQuery = criteriaBuilder.createQuery(Record.class);
Root<Record> from = criteriaQuery.from(Record.class);
CriteriaQuery<Record> select = criteriaQuery.select(from);
criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
TypedQuery<Record> typedQuery = entityManager.createQuery(select);
typedQuery.setFirstResult(skip);
typedQuery.setMaxResults(maxPageSize);
return typedQuery.getResultList();
}
use of org.orcid.jaxb.model.record_rc2.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordService method deleteEntity.
// All DELETE operations
@Override
public void deleteEntity(@NotNull String systemID) {
Record record = getRecordOrThrow(systemID);
// See issue for a description of why this code was written this way
// https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
//Query q = entityManager.createNativeQuery("DELETE FROM fonds_fonds_creator WHERE pk_fonds_creator_id = :id ;");
//q.setParameter("id", record.getId());
//q.executeUpdate();
entityManager.remove(record);
entityManager.flush();
entityManager.clear();
}
use of org.orcid.jaxb.model.record_rc2.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordService method createDocumentDescriptionAssociatedWithRecord.
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRecord(String systemID, DocumentDescription documentDescription) {
DocumentDescription persistedDocumentDescription = null;
Record record = recordRepository.findBySystemIdOrderBySystemId(systemID);
if (record == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemID " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
TreeSet<Record> records = (TreeSet<Record>) documentDescription.getReferenceRecord();
if (records == null) {
records = new TreeSet<>();
documentDescription.setReferenceRecord(records);
}
records.add(record);
Set<DocumentDescription> documentDescriptions = record.getReferenceDocumentDescription();
documentDescriptions.add(documentDescription);
persistedDocumentDescription = documentDescriptionService.save(documentDescription);
}
return persistedDocumentDescription;
}
Aggregations