Search in sources :

Example 76 with Record

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."));
        */
}
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 77 with Record

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

Example 79 with Record

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

Example 80 with Record

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

Aggregations

Test (org.junit.Test)60 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