@Test public void testSetOptions() { Map<String, String> options = new HashMap<>(); options.put(CoreGraph.OPTION_DOCTYPE, "Foo"); try { graph.setOptions(options); fail("Should have raised IllegalArgumentException"); } catch (IllegalArgumentException e) { } options.put(CoreGraph.OPTION_DOCTYPE, "Relation"); graph.setOptions(options); }
protected void setOptions(Map<String, String> options) { for (Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String type = option.getValue(); if (key.equals(OPTION_DOCTYPE)) { SchemaManager sm = Framework.getService(SchemaManager.class); DocumentType documentType = sm.getDocumentType(type); if (documentType == null) { throw new IllegalArgumentException("Unknown type: " + type + " for graph: " + name); } Type[] th = documentType.getTypeHierarchy(); String baseType = th.length == 0 ? type : th[th.length - 1].getName(); if (!REL_TYPE.equals(baseType)) { throw new IllegalArgumentException("Not a Relation type: " + type + " for graph: " + name); } docType = type; } } }
CoreGraph implements Graph { protected void setOptions(Map<String, String> options) { for (Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String type = option.getValue(); if (key.equals(OPTION_DOCTYPE)) { SchemaManager sm = Framework.getService(SchemaManager.class); DocumentType documentType = sm.getDocumentType(type); if (documentType == null) { throw new IllegalArgumentException("Unknown type: " + type + " for graph: " + name); } Type[] th = documentType.getTypeHierarchy(); String baseType = th.length == 0 ? type : th[th.length - 1].getName(); if (!REL_TYPE.equals(baseType)) { throw new IllegalArgumentException("Not a Relation type: " + type + " for graph: " + name); } docType = type; } } } }
CoreGraph implements Graph { protected void setOptions(Map<String, String> options) { for (Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String type = option.getValue(); if (key.equals(OPTION_DOCTYPE)) { SchemaManager sm = Framework.getService(SchemaManager.class); DocumentType documentType = sm.getDocumentType(type); if (documentType == null) { throw new IllegalArgumentException("Unknown type: " + type + " for graph: " + name); } Type[] th = documentType.getTypeHierarchy(); String baseType = th.length == 0 ? type : th[th.length - 1].getName(); if (!REL_TYPE.equals(baseType)) { throw new IllegalArgumentException("Not a Relation type: " + type + " for graph: " + name); } docType = type; } } } CoreGraph(CoreSession session); }
CoreGraph implements Graph { protected void setOptions(Map<String, String> options) { for (Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String type = option.getValue(); if (key.equals(OPTION_DOCTYPE)) { SchemaManager sm = Framework.getService(SchemaManager.class); DocumentType documentType = sm.getDocumentType(type); if (documentType == null) { throw new IllegalArgumentException("Unknown type: " + type + " for graph: " + name); } Type[] th = documentType.getTypeHierarchy(); String baseType = th.length == 0 ? type : th[th.length - 1].getName(); if (!REL_TYPE.equals(baseType)) { throw new IllegalArgumentException("Not a Relation type: " + type + " for graph: " + name); } docType = type; } } } CoreGraph(CoreSession session); @Override void setDescription(GraphDescription graphDescription); @Override Map<String, String> getNamespaces(); @Override Long size(); @Override void clear(); @Override void add(Statement statement); @Override void add(List<Statement> statements); @Override void remove(Statement statement); @Override void remove(List<Statement> statements); @Override List<Statement> getStatements(); @Override List<Statement> getStatements(Node subject, Node predicate, Node object); @Override List<Statement> getStatements(Statement statement); @Override List<Node> getSubjects(Node predicate, Node object); @Override List<Node> getPredicates(Node subject, Node object); @Override List<Node> getObjects(Node subject, Node predicate); @Override boolean hasStatement(Statement statement); @Override boolean hasResource(Resource resource); @Override QueryResult query(String queryString, String language, String baseURI); @Override int queryCount(String queryString, String language, String baseURI); @Override boolean read(String path, String lang, String base); @Override boolean write(String path, String lang, String base); @Override boolean read(InputStream in, String lang, String base); @Override boolean write(OutputStream out, String lang, String base); }
CoreGraph implements Graph { protected void setOptions(Map<String, String> options) { for (Entry<String, String> option : options.entrySet()) { String key = option.getKey(); String type = option.getValue(); if (key.equals(OPTION_DOCTYPE)) { SchemaManager sm = Framework.getService(SchemaManager.class); DocumentType documentType = sm.getDocumentType(type); if (documentType == null) { throw new IllegalArgumentException("Unknown type: " + type + " for graph: " + name); } Type[] th = documentType.getTypeHierarchy(); String baseType = th.length == 0 ? type : th[th.length - 1].getName(); if (!REL_TYPE.equals(baseType)) { throw new IllegalArgumentException("Not a Relation type: " + type + " for graph: " + name); } docType = type; } } } CoreGraph(CoreSession session); @Override void setDescription(GraphDescription graphDescription); @Override Map<String, String> getNamespaces(); @Override Long size(); @Override void clear(); @Override void add(Statement statement); @Override void add(List<Statement> statements); @Override void remove(Statement statement); @Override void remove(List<Statement> statements); @Override List<Statement> getStatements(); @Override List<Statement> getStatements(Node subject, Node predicate, Node object); @Override List<Statement> getStatements(Statement statement); @Override List<Node> getSubjects(Node predicate, Node object); @Override List<Node> getPredicates(Node subject, Node object); @Override List<Node> getObjects(Node subject, Node predicate); @Override boolean hasStatement(Statement statement); @Override boolean hasResource(Resource resource); @Override QueryResult query(String queryString, String language, String baseURI); @Override int queryCount(String queryString, String language, String baseURI); @Override boolean read(String path, String lang, String base); @Override boolean write(String path, String lang, String base); @Override boolean read(InputStream in, String lang, String base); @Override boolean write(OutputStream out, String lang, String base); static final String OPTION_DOCTYPE; static final String REL_TYPE; static final String REL_PREDICATE; static final String REL_SOURCE_ID; static final String REL_SOURCE_URI; static final String REL_TARGET_ID; static final String REL_TARGET_URI; static final String REL_TARGET_STRING; static final String DC_CREATED; static final String DC_CREATOR; static final String DC_MODIFIED; static final String DC_TITLE; static final String DC_DESCRIPTION; static final String BLANK_NS; static final String DOCUMENT_NAMESPACE; static final String DOCUMENT_NAMESPACE2; static final String COMMENT_NAMESPACE; static final String[] DOC_NAMESPACES; public Map<String, String> namespaces; public List<String> namespaceList; static final Pattern SPARQL_SPO_PO; static final Pattern SPARQL_PO_S; static final Pattern SPARQL_S_PO; }