All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.uniroma2.art.sheet2rdf.header.GraphApplication Maven / Gradle / Ivy

There is a newer version: 6.0.6
Show newest version
package it.uniroma2.art.sheet2rdf.header;

import java.util.UUID;

import org.eclipse.rdf4j.model.IRI;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;

import it.uniroma2.art.sheet2rdf.utils.RDF4JValueSerializer;

public abstract class GraphApplication {
	
	protected String id; //id of the object, useful to identify the instance when the user updates it
	
	
	public GraphApplication() {
		id = UUID.randomUUID().toString();
	}
	
	public String getId() {
		return id;
	}
	
	/**
	 * Removes the referenced node with the given id
	 * @param nodeId
	 */
	abstract public void removeNode(String nodeId);
	
	public JsonNode toJson() {
		ObjectMapper mapper = new ObjectMapper();
		SimpleModule module = new SimpleModule();
		module.addSerializer(IRI.class, new RDF4JValueSerializer());
		mapper.registerModule(module);
		return mapper.valueToTree(this);
	}
	
	abstract public void fromJson(JsonNode jsonNode);
	
	abstract public String toString();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy