use of nikita.model.noark5.v4.Class in project nikita-noark5-core by HiOA-ABI.
the class ClassDeserializer method deserialize.
@Override
public Class deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
Class klass = new Class();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(klass, objectNode);
// Deserialize classId
JsonNode currentNode = objectNode.get(CLASS_ID);
if (null != currentNode) {
klass.setClassId(currentNode.textValue());
objectNode.remove(CLASS_ID);
}
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The klasse you tried to create is malformed. The " + "following fields are not recognised as klasse fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return klass;
}
use of nikita.model.noark5.v4.Class in project nikita-noark5-core by HiOA-ABI.
the class ClassHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject classHateoas, JsonGenerator jgen) throws IOException {
Class klass = (Class) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, klass);
CommonUtils.Hateoas.Serialize.printTitleAndDescription(jgen, klass);
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, klass);
CommonUtils.Hateoas.Serialize.printFinaliseEntity(jgen, klass);
// TODO: Fix this ! CommonCommonUtils.Hateoas.Serialize.printCrossReference(jgen, klass);
CommonUtils.Hateoas.Serialize.printDisposal(jgen, klass);
CommonUtils.Hateoas.Serialize.printScreening(jgen, klass);
CommonUtils.Hateoas.Serialize.printClassified(jgen, klass);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, classHateoas.getLinks(klass));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.Class in project nikita-noark5-core by HiOA-ABI.
the class ClassService method getClassOrThrow.
// 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 Class back. If there is no valid
* Class, an exception is thrown
*
* @param classSystemId
* @return
*/
protected Class getClassOrThrow(@NotNull String classSystemId) {
Class klass = classRepository.findBySystemIdOrderBySystemId(classSystemId);
if (null == klass) {
String info = INFO_CANNOT_FIND_OBJECT + " Class, using systemId " + classSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return klass;
}
use of nikita.model.noark5.v4.Class in project nikita-noark5-core by HiOA-ABI.
the class ClassService method updateClassSetFinalized.
public Class updateClassSetFinalized(Long id) {
Class klass = classRepository.findById(id);
if (klass == null) {
// TODO throw Object not find
}
String username = SecurityContextHolder.getContext().getAuthentication().getName();
klass.setFinalisedDate(new Date());
klass.setFinalisedBy(username);
return classRepository.save(klass);
}
use of nikita.model.noark5.v4.Class in project nikita-noark5-core by HiOA-ABI.
the class ClassService method findClassByOwnerPaginated.
// All READ operations
@Override
public List<Class> findClassByOwnerPaginated(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<Class> criteriaQuery = criteriaBuilder.createQuery(Class.class);
Root<Class> from = criteriaQuery.from(Class.class);
CriteriaQuery<Class> select = criteriaQuery.select(from);
criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
TypedQuery<Class> typedQuery = entityManager.createQuery(select);
typedQuery.setFirstResult(skip);
typedQuery.setMaxResults(maxPageSize);
return typedQuery.getResultList();
}
Aggregations