it.uniroma2.art.sheet2rdf.header.AdvancedGraphApplication Maven / Gradle / Ivy
package it.uniroma2.art.sheet2rdf.header;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.rio.ntriples.NTriplesUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.uniroma2.art.sheet2rdf.utils.JsonConstants;
public class AdvancedGraphApplication extends GraphApplication {
private List nodeIds; //ids of the nodes referenced in the graph pattern
private Map prefixMapping;
private String pattern;
private IRI defaultPredicate;
public static final String PREDICATE_PLACEHOLDER = "{{pred}}";
public AdvancedGraphApplication() {
super();
nodeIds = new ArrayList();
prefixMapping = new HashMap();
}
public List getNodeIds() {
return nodeIds;
}
public void setNodeIds(List nodeIds) {
this.nodeIds = nodeIds;
}
@Override
public void removeNode(String nodeId) {
nodeIds.remove(nodeId);
}
public String getPattern() {
return pattern;
}
public void setPattern(String pattern) {
this.pattern = pattern;
}
public Map getPrefixMapping() {
return prefixMapping;
}
public void setPrefixMapping(Map prefixMapping) {
this.prefixMapping = prefixMapping;
}
public IRI getDefaultPredicate() {
return defaultPredicate;
}
public void setDefaultPredicate(IRI defaultPredicate) {
this.defaultPredicate = defaultPredicate;
}
@Override
public void fromJson(JsonNode jsonNode) {
ObjectMapper mapper = new ObjectMapper();
this.id = jsonNode.get(JsonConstants.ADVANCED_GRAPH_APPLICATION_ID).asText();
this.pattern = jsonNode.get(JsonConstants.ADVANCED_GRAPH_APPLICATION_PATTERN).asText();
this.nodeIds = mapper.convertValue(jsonNode.get(JsonConstants.ADVANCED_GRAPH_APPLICATION_NODE_IDS), new TypeReference>(){});
this.prefixMapping = mapper.convertValue(jsonNode.get(JsonConstants.ADVANCED_GRAPH_APPLICATION_PREFIX_MAPPING), new TypeReference