Implementing entity management
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/information-system-model@130196 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8f1171efec
commit
8cbb5b793a
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.impl.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gcube.informationsystem.model.embedded.Header;
|
||||
import org.gcube.informationsystem.model.entity.Entity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class Utility {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(Utility.class);
|
||||
|
||||
public static String getUUIDFromJSONString(String json) throws JsonProcessingException, IOException {
|
||||
logger.trace("Tryning to get UUID from {} of {} ", Header.class.getSimpleName(), json);
|
||||
JsonNode jsonNode = getJSONNode(json);
|
||||
JsonNode header = jsonNode.get(Entity.HEADER_PROPERTY);
|
||||
String uuid = header.get(Header.UUID_PROPERTY).asText();
|
||||
logger.trace("UUID got from {} is : {} ", json, uuid);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public static JsonNode getJSONNode(String json) throws JsonProcessingException, IOException {
|
||||
if(json==null || json.compareTo("")==0){
|
||||
return null;
|
||||
}
|
||||
logger.trace("Tryning to get Jsonnode from {}");
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.readTree(json);
|
||||
return jsonNode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -13,6 +13,9 @@ import org.gcube.informationsystem.model.entity.Entity;
|
|||
*/
|
||||
public interface Relation<Out extends Entity, In extends Entity> {
|
||||
|
||||
public static final String NAME = Relation.class.getSimpleName();
|
||||
|
||||
|
||||
public static final String RELATION_PROPERTY = "relationProperty";
|
||||
|
||||
public static final String HEADER_PROPERTY = Entity.HEADER_PROPERTY;
|
||||
|
|
Loading…
Reference in New Issue