params, context, Params.PARENT_UUID, Params.PARENT_ID));
int childId = Integer.parseInt(Utils.getIdentifierFromParameters(
params, context, Params.CHILD_UUID, Params.CHILD_ID));
final Specifications<MetadataRelation> spec = where(hasMetadataId(parentId)).and(hasRelatedId(childId));
final MetadataRelationRepository metadataRelationRepository = context.getBean(MetadataRelationRepository.class);
final long count = metadataRelationRepository.count(spec);
boolean exist = false;
if (count == 1) {
exist = true;
} else {
MetadataRelation entity = new MetadataRelation().setId(new MetadataRelationId(parentId, childId));
metadataRelationRepository.save(entity);
}
Element response = new Element(Jeeves.Elem.RESPONSE)
.setAttribute("alreadyExist", String.valueOf(exist))
.addContent(