use of nikita.model.noark5.v4.Fonds in project nikita-noark5-core by HiOA-ABI.
the class FondsDeserializer method deserialize.
@Override
public Fonds deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
Fonds fonds = new Fonds();
ObjectNode objectNode = mapper.readTree(jsonParser);
// TODO : Are we deserialising parent? No, it's not done here or is it????
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(fonds, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(fonds, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(fonds, objectNode);
// Deserialize seriesStatus
JsonNode currentNode = objectNode.get(FONDS_STATUS);
if (currentNode != null) {
fonds.setFondsStatus(currentNode.textValue());
objectNode.remove(FONDS_STATUS);
}
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The arkiv you tried to create is malformed. The " + "following fields are not recognised as arkiv fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return fonds;
}
use of nikita.model.noark5.v4.Fonds in project nikita-noark5-core by HiOA-ABI.
the class UserDeserializer method deserialize.
@Override
public Fonds deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
Fonds fonds = new Fonds();
ObjectNode objectNode = mapper.readTree(jsonParser);
// TODO : Are we deserialising parent? No, it's not done here or is it????
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(fonds, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(fonds, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(fonds, objectNode);
// Deserialize seriesStatus
JsonNode currentNode = objectNode.get(FONDS_STATUS);
if (currentNode != null) {
fonds.setFondsStatus(currentNode.textValue());
objectNode.remove(FONDS_STATUS);
}
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The arkiv you tried to create is malformed. The " + "following fields are not recognised as arkiv fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return fonds;
}
use of nikita.model.noark5.v4.Fonds in project nikita-noark5-core by HiOA-ABI.
the class UserHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject fondsHateoas, JsonGenerator jgen) throws IOException {
Fonds fonds = (Fonds) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, fonds);
CommonUtils.Hateoas.Serialize.printTitleAndDescription(jgen, fonds);
if (fonds.getFondsStatus() != null) {
jgen.writeStringField(FONDS_STATUS, fonds.getFondsStatus());
}
CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, fonds);
CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, fonds);
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, fonds);
CommonUtils.Hateoas.Serialize.printFinaliseEntity(jgen, fonds);
CommonUtils.Hateoas.Serialize.printFondsCreators(jgen, fonds);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, fondsHateoas.getLinks(fonds));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.Fonds in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorService method createFondsAssociatedWithFondsCreator.
@Override
public Fonds createFondsAssociatedWithFondsCreator(String fondsCreatorSystemId, Fonds fonds) {
FondsCreator fondsCreator = getFondsCreatorOrThrow(fondsCreatorSystemId);
NoarkUtils.NoarkEntity.Create.checkDocumentMediumValid(fonds);
NoarkUtils.NoarkEntity.Create.setNoarkEntityValues(fonds);
fonds.setFondsStatus(STATUS_OPEN);
NoarkUtils.NoarkEntity.Create.setFinaliseEntityValues(fonds);
fonds.getReferenceFondsCreator().add(fondsCreator);
fondsCreator.getReferenceFonds().add(fonds);
fondsRepository.save(fonds);
return fonds;
}
use of nikita.model.noark5.v4.Fonds in project nikita-noark5-core by HiOA-ABI.
the class FondsService method createFondsAssociatedWithFonds.
/**
*
** Persists a new fonds object to the database, that is associated with a parent fonds object. Some values are set
* in the incoming payload (e.g. title) and some are set by the core. owner, createdBy, createdDate are
* automatically set by the core.
*
* First we try to locate the parent. If the parent does not exist a NoarkEntityNotFoundException exception is
* thrown
*
* @param childFonds incoming fonds object with some values set
* @param parentFondsSystemId The systemId of the parent fonds
* @return the newly persisted fonds object
*/
@Override
public Fonds createFondsAssociatedWithFonds(String parentFondsSystemId, Fonds childFonds) {
Fonds persistedChildFonds = null;
Fonds parentFonds = fondsRepository.findBySystemIdOrderBySystemId(parentFondsSystemId);
if (parentFonds == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Fonds, using fondsSystemId " + parentFondsSystemId + " when " + "trying to associate a child fonds with a parent fonds";
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else if (parentFonds.getReferenceSeries() != null) {
String info = INFO_INVALID_STRUCTURE + " Cannot associate a new child fonds with a fonds that has " + "one or more series " + parentFondsSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
childFonds.setReferenceParentFonds(parentFonds);
persistedChildFonds = this.createNewFonds(childFonds);
}
return persistedChildFonds;
}
Aggregations