Search in sources :

Example 96 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 97 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 98 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)

Example 99 with Record

use of org.orcid.jaxb.model.record_rc2.Record in project nikita-noark5-core by HiOA-ABI.

the class RecordService method updateRecordSetFinalized.

public Record updateRecordSetFinalized(Long id) {
    Record record = recordRepository.findById(id);
    if (record == null) {
    // TODO throw Object not find
    }
    String username = SecurityContextHolder.getContext().getAuthentication().getName();
    return recordRepository.save(record);
}
Also used : Record(nikita.model.noark5.v4.Record)

Example 100 with Record

use of org.orcid.jaxb.model.record_rc2.Record in project nikita-noark5-core by HiOA-ABI.

the class RecordService method handleUpdate.

// All UPDATE operations
@Override
public Record handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull Record incomingRecord) {
    Record existingRecord = getRecordOrThrow(systemId);
    // Here copy all the values you are allowed to copy ....
    // TODO: FIND ALL VALUES
    // This might be a class that can only have values set via parameter values rather than request bodies
    existingRecord.setVersion(version);
    recordRepository.save(existingRecord);
    return existingRecord;
}
Also used : Record(nikita.model.noark5.v4.Record)

Aggregations

Test (org.junit.Test)72 Record (org.orcid.jaxb.model.record_v2.Record)62 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)25 Person (org.orcid.jaxb.model.record_v2.Person)22 Email (org.orcid.jaxb.model.record_v2.Email)20 Record (nikita.model.noark5.v4.Record)19 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)19 Address (org.orcid.jaxb.model.record_v2.Address)19 Name (org.orcid.jaxb.model.record_v2.Name)19 OtherName (org.orcid.jaxb.model.record_v2.OtherName)19 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)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 Keyword (org.orcid.jaxb.model.record_v2.Keyword)18 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)18 Record (org.neo4j.driver.v1.Record)17 Emails (org.orcid.jaxb.model.record_v2.Emails)17 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)16 Addresses (org.orcid.jaxb.model.record_v2.Addresses)16