Search in sources :

Example 51 with Record

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

the class RecordHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject recordHateoas, JsonGenerator jgen) throws IOException {
    Record record = (Record) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, record);
    CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, record);
    if (record.getArchivedDate() != null) {
        jgen.writeStringField(RECORD_ARCHIVED_DATE, Serialize.formatDateTime(record.getArchivedDate()));
    }
    if (record.getArchivedBy() != null) {
        jgen.writeStringField(RECORD_ARCHIVED_BY, record.getArchivedBy());
    }
    CommonUtils.Hateoas.Serialize.printDisposal(jgen, record);
    CommonUtils.Hateoas.Serialize.printScreening(jgen, record);
    CommonUtils.Hateoas.Serialize.printClassified(jgen, record);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, recordHateoas.getLinks(record));
    jgen.writeEndObject();
}
Also used : Record(nikita.model.noark5.v4.Record)

Example 52 with Record

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

the class FileService method createRecordAssociatedWithFile.

@Override
public Record createRecordAssociatedWithFile(String fileSystemId, Record record) {
    Record persistedRecord = null;
    File file = fileRepository.findBySystemIdOrderBySystemId(fileSystemId);
    if (file == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        record.setReferenceFile(file);
        persistedRecord = recordService.save(record);
    }
    return persistedRecord;
}
Also used : Record(nikita.model.noark5.v4.Record) BasicRecord(nikita.model.noark5.v4.BasicRecord) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) File(nikita.model.noark5.v4.File)

Example 53 with Record

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

the class FileService method createRecordAssociatedWithFile.

@Override
public Record createRecordAssociatedWithFile(String fileSystemId, Record record) {
    Record persistedRecord;
    File file = fileRepository.findBySystemId(fileSystemId);
    if (file == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        record.setReferenceFile(file);
        persistedRecord = recordService.save(record);
    }
    return persistedRecord;
}
Also used : BasicRecord(nikita.common.model.noark5.v4.BasicRecord) Record(nikita.common.model.noark5.v4.Record) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) File(nikita.common.model.noark5.v4.File)

Example 54 with Record

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

the class RecordService method getRecordOrThrow.

// All HELPER operations
/**
 * Internal helper method. Rather than having a find and try catch in multiple methods, we have it here once.
 * If you call this, be aware that you will only ever get a valid Record back. If there is no valid
 * Record, an exception is thrown
 *
 * @param systemID
 * @return
 */
protected Record getRecordOrThrow(@NotNull String systemID) {
    Record record = recordRepository.findBySystemId(systemID);
    if (record == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemId " + systemID;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return record;
}
Also used : Record(nikita.common.model.noark5.v4.Record) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 55 with Record

use of org.orcid.jaxb.model.record_v2.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.common.model.noark5.v4.Record)

Aggregations

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