use of org.orcid.jaxb.model.record_rc3.Record in project ORCID-Source by ORCID.
the class OrcidRecordToSolrDocumentTest method test12SameAs20.
@Test
public void test12SameAs20() throws IOException, SolrServerException, JAXBException {
OrcidProfileToSolrDocument v12 = new OrcidProfileToSolrDocument();
OrcidRecordToSolrDocument v20 = new OrcidRecordToSolrDocument(false);
Record record = getRecord("/v20record.xml");
OrcidMessage message = getOrcidMessage();
OrcidSolrDocument v12Doc = v12.convert(message.getOrcidProfile());
OrcidSolrDocument v20Doc = v20.convert(record, new ArrayList<Funding>());
Assert.assertEquals(v12Doc.getOrcid(), v20Doc.getOrcid());
Assert.assertEquals(v12Doc.getFamilyName(), v20Doc.getFamilyName());
Assert.assertEquals(v12Doc.getGivenNames(), v20Doc.getGivenNames());
Assert.assertEquals(v12Doc.getGivenAndFamilyNames(), v20Doc.getGivenAndFamilyNames());
Assert.assertTrue(v12Doc.getDigitalObjectIds().containsAll(v20Doc.getDigitalObjectIds()));
Assert.assertTrue(v20Doc.getDigitalObjectIds().containsAll(v12Doc.getDigitalObjectIds()));
Assert.assertTrue(v12Doc.getWorkTitles().containsAll(v20Doc.getWorkTitles()));
Assert.assertTrue(v20Doc.getWorkTitles().containsAll(v12Doc.getWorkTitles()));
Assert.assertTrue(v12Doc.getCit().containsAll(v20Doc.getCit()));
Assert.assertTrue(v20Doc.getCit().containsAll(v12Doc.getCit()));
Assert.assertTrue(v12Doc.getAgr().containsAll(v20Doc.getAgr()));
Assert.assertTrue(v20Doc.getAgr().containsAll(v12Doc.getAgr()));
Assert.assertEquals(v12Doc.getProfileLastModifiedDate(), v20Doc.getProfileLastModifiedDate());
Assert.assertEquals(v12Doc.getProfileSubmissionDate(), v20Doc.getProfileSubmissionDate());
}
use of org.orcid.jaxb.model.record_rc3.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_rc3.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_rc3.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_rc3.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();
}
Aggregations