Search in sources :

Example 76 with Record

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());
}
Also used : OrcidRecordToSolrDocument(org.orcid.listener.solr.OrcidRecordToSolrDocument) Funding(org.orcid.jaxb.model.record_v2.Funding) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) Record(org.orcid.jaxb.model.record_v2.Record) OrcidProfileToSolrDocument(org.orcid.listener.solr.OrcidProfileToSolrDocument) Test(org.junit.Test)

Example 77 with Record

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."));
        */
}
Also used : OrcidRecordToSolrDocument(org.orcid.listener.solr.OrcidRecordToSolrDocument) Funding(org.orcid.jaxb.model.record_v2.Funding) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) Record(org.orcid.jaxb.model.record_v2.Record) Test(org.junit.Test)

Example 78 with Record

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Record(nikita.model.noark5.v4.Record) JsonNode(com.fasterxml.jackson.databind.JsonNode) ParseException(java.text.ParseException) Date(java.util.Date) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

Example 79 with 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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Record(nikita.model.noark5.v4.Record)

Example 80 with Record

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();
}
Also used : Record(nikita.model.noark5.v4.Record)

Aggregations

Test (org.junit.Test)61 Record (org.orcid.jaxb.model.record_v2.Record)49 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)21 Person (org.orcid.jaxb.model.record_v2.Person)20 Record (nikita.model.noark5.v4.Record)19 Email (org.orcid.jaxb.model.record_v2.Email)19 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)18 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)18 Address (org.orcid.jaxb.model.record_v2.Address)18 Keyword (org.orcid.jaxb.model.record_v2.Keyword)18 OtherName (org.orcid.jaxb.model.record_v2.OtherName)18 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)18 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)18 Name (org.orcid.jaxb.model.record_v2.Name)17 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)16 Emails (org.orcid.jaxb.model.record_v2.Emails)16 Addresses (org.orcid.jaxb.model.record_v2.Addresses)15 Biography (org.orcid.jaxb.model.record_v2.Biography)15