/** * This method is invoked by the framework when the processor needs to process data or check constraints. * * @since 1.0 */ @Override public Object execute(Object value, CsvContext context) { validateInputNotNull(value, context); if( !(value instanceof KiWiNode) ) { throw new SuperCsvCellProcessorException(KiWiUriResource.class, value, context, this); } return ((KiWiNode)value).getId(); } }
private String formatJSON(KiWiNode node, boolean asObject) { if(node.isUriResource()) { String result = "\""+ node.stringValue()+"\""; return result; } else if(node.isAnonymousResource()) { String result = "\"_:"+node.stringValue()+"\""; } else if(node.isLiteral()) { KiWiLiteral l = (KiWiLiteral)node; return "{ \"type\" : \"literal\"," +
@Override protected void storeNode(KiWiNode node) throws SQLException { if(node.getId() < 0) { node.setId(connection.getNextSequence()); } nodeBacklog.add(node); if(node instanceof KiWiUriResource) { uriBacklogLookup.put(node.stringValue(),(KiWiUriResource)node); } else if(node instanceof KiWiAnonResource) { bnodeBacklogLookup.put(node.stringValue(), (KiWiAnonResource)node); } else if(node instanceof KiWiLiteral) { literalBacklogLookup.put(LiteralCommons.createCacheKey((Literal) node), (KiWiLiteral)node); } nodes++; }
private void cacheNode(KiWiNode node) { if (node.getId() >= 0) { nodeCache.put(node.getId(), node); } if (node instanceof KiWiUriResource) { uriCache.put(node.stringValue(), (KiWiUriResource) node); } else if (node instanceof KiWiAnonResource) { bnodeCache.put(node.stringValue(), (KiWiAnonResource) node); } else if (node instanceof KiWiLiteral) { literalCache.put(LiteralCommons.createCacheKey((Literal) node), (KiWiLiteral) node); } }
if(triple.getSubject().isUriResource() && triple.getObject().isUriResource()) { String sUri = triple.getSubject().stringValue(); String oUri = triple.getObject().stringValue(); output.writeLong(triple.getObject().getId()); DataIO.writeString(output, oUri.substring(prefix.length())); output.writeLong(triple.getObject().getCreated().getTime()); } else { output.writeByte(MODE_DEFAULT);
if (node.getId() < 0) { node.setId(getNextSequence()); insertNode.setLong(1,node.getId()); insertNode.setString(2,uriResource.stringValue()); insertNode.setTimestamp(3, new Timestamp(uriResource.getCreated().getTime()), calendarUTC); insertNode.setLong(1,node.getId()); insertNode.setString(2,anonResource.stringValue()); insertNode.setTimestamp(3, new Timestamp(anonResource.getCreated().getTime()), calendarUTC); insertNode.setLong(1,node.getId()); insertNode.setString(2, dateLiteral.stringValue()); insertNode.setTimestamp(3, new Timestamp(dateLiteral.getDateContent().getMillis()), calendarUTC); insertNode.setLong(1,node.getId()); insertNode.setString(2, intLiteral.getContent()); insertNode.setDouble(3, intLiteral.getDoubleContent()); insertNode.setLong(1, node.getId()); insertNode.setString(2, doubleLiteral.getContent()); insertNode.setDouble(3, doubleLiteral.getDoubleContent()); insertNode.setLong(1,node.getId()); insertNode.setString(2, booleanLiteral.getContent()); insertNode.setBoolean(3, booleanLiteral.booleanValue()); insertNode.setLong(1,node.getId()); insertNode.setString(2, stringLiteral.getContent());
if(!binding.get(rule.getHead().getSubject()).isUriResource() && !binding.get(rule.getHead().getSubject()).isAnonymousResource()) { log.info("cannot use value {} as subject, because it is not a resource",binding.get(rule.getHead().getSubject())); continue; if(!binding.get(rule.getHead().getProperty()).isUriResource()) { log.info("cannot use value {} as property, because it is not a URI resource",binding.get(rule.getHead().getProperty())); continue;
if(triple.getSubject().isUriResource() && triple.getObject().isUriResource()) { String sUri = triple.getSubject().stringValue(); String oUri = triple.getObject().stringValue(); output.writeLong(triple.getObject().getId()); DataIO.writeString(output, oUri.substring(prefix.length())); output.writeLong(triple.getObject().getCreated().getTime()); } else { output.writeByte(MODE_DEFAULT);
private void cacheNode(KiWiNode node) { if (node.getId() >= 0) { nodeCache.put(node.getId(), node); } if (node instanceof KiWiUriResource) { uriCache.put(node.stringValue(), (KiWiUriResource) node); } else if (node instanceof KiWiAnonResource) { bnodeCache.put(node.stringValue(), (KiWiAnonResource) node); } else if (node instanceof KiWiLiteral) { literalCache.put(LiteralCommons.createCacheKey((Literal) node), (KiWiLiteral) node); } }
if (node.getId() < 0) { node.setId(getNextSequence()); insertNode.setLong(1,node.getId()); insertNode.setString(2,uriResource.stringValue()); insertNode.setTimestamp(3, new Timestamp(uriResource.getCreated().getTime()), calendarUTC); insertNode.setLong(1,node.getId()); insertNode.setString(2,anonResource.stringValue()); insertNode.setTimestamp(3, new Timestamp(anonResource.getCreated().getTime()), calendarUTC); insertNode.setLong(1,node.getId()); insertNode.setString(2, dateLiteral.stringValue()); insertNode.setTimestamp(3, new Timestamp(dateLiteral.getDateContent().getMillis()), calendarUTC); insertNode.setLong(1,node.getId()); insertNode.setString(2, intLiteral.getContent()); insertNode.setDouble(3, intLiteral.getDoubleContent()); insertNode.setLong(1, node.getId()); insertNode.setString(2, doubleLiteral.getContent()); insertNode.setDouble(3, doubleLiteral.getDoubleContent()); insertNode.setLong(1,node.getId()); insertNode.setString(2, booleanLiteral.getContent()); insertNode.setBoolean(3, booleanLiteral.booleanValue()); insertNode.setLong(1,node.getId()); insertNode.setString(2, stringLiteral.getContent());
if(!binding.get(rule.getHead().getSubject()).isUriResource() && !binding.get(rule.getHead().getSubject()).isAnonymousResource()) { log.info("cannot use value {} as subject, because it is not a resource",binding.get(rule.getHead().getSubject())); continue; if(!binding.get(rule.getHead().getProperty()).isUriResource()) { log.info("cannot use value {} as property, because it is not a URI resource",binding.get(rule.getHead().getProperty())); continue;
/** * This method is invoked by the framework when the processor needs to process data or check constraints. * * @since 1.0 */ @Override public Object execute(Object value, CsvContext context) { validateInputNotNull(value, context); if( !(value instanceof KiWiNode) ) { throw new SuperCsvCellProcessorException(KiWiUriResource.class, value, context, this); } return ((KiWiNode)value).getId(); } }
@Override protected void storeNode(KiWiNode node) throws SQLException { if(node.getId() < 0) { node.setId(connection.getNextSequence()); } nodeBacklog.add(node); if(node instanceof KiWiUriResource) { uriBacklogLookup.put(node.stringValue(),(KiWiUriResource)node); } else if(node instanceof KiWiAnonResource) { bnodeBacklogLookup.put(node.stringValue(), (KiWiAnonResource)node); } else if(node instanceof KiWiLiteral) { literalBacklogLookup.put(LiteralCommons.createCacheKey((Literal) node), (KiWiLiteral)node); } nodes++; }
@Override public void meet(ValueConstant node) throws RuntimeException { String val = node.getValue().stringValue(); switch (optypes.peek()) { case STRING: case URI: builder.append("'").append(val).append("'"); break; case INT: builder.append(Integer.parseInt(val)); break; case DECIMAL: case DOUBLE: builder.append(Double.parseDouble(val)); break; case BOOL: builder.append(Boolean.parseBoolean(val)); break; case DATE: builder.append("'").append(sqlDateFormat.format(DateUtils.parseDate(val))).append("'"); break; // in this case we should return a node ID and also need to make sure it actually exists case TERM: case NODE: KiWiNode n = parent.getConverter().convert(node.getValue()); builder.append(n.getId()); break; default: throw new IllegalArgumentException("unsupported value type: " + optypes.peek()); } }
String vName = vNames.get(0); Value binding = converter.convert(bindings.getValue(v)); whereConditions.add(vName+" = "+((KiWiNode)binding).getId());
@Override public Boolean run() throws SQLException { PreparedStatement insertTriple = getPreparedStatement("store.triple"); insertTriple.setLong(1,triple.getId()); insertTriple.setLong(2,triple.getSubject().getId()); insertTriple.setLong(3,triple.getPredicate().getId()); insertTriple.setLong(4,triple.getObject().getId()); if (triple.getContext() != null) { insertTriple.setLong(5,triple.getContext().getId()); } else { insertTriple.setNull(5, Types.BIGINT); } insertTriple.setBoolean(6,triple.isInferred()); insertTriple.setTimestamp(7, new Timestamp(triple.getCreated().getTime())); int count = insertTriple.executeUpdate(); cacheTriple(triple); return count > 0; } });
node = constructNodeFromDatabase(rows); for (int i = 0; i < ids.length; i++) { if (ids[i] == node.getId()) { result[i] = node;
loadTripleId.setLong(1, subject.getId()); loadTripleId.setLong(2, predicate.getId()); loadTripleId.setLong(3, object.getId()); if (context != null) { loadTripleId.setLong(4, context.getId());
node = constructNodeFromDatabase(rows); for (int i = 0; i < ids.length; i++) { if (ids[i] == node.getId()) { result[i] = node;
@Override public Boolean run() throws SQLException { PreparedStatement insertTriple = getPreparedStatement("store.triple"); insertTriple.setLong(1,triple.getId()); insertTriple.setLong(2,triple.getSubject().getId()); insertTriple.setLong(3,triple.getPredicate().getId()); insertTriple.setLong(4,triple.getObject().getId()); if (triple.getContext() != null) { insertTriple.setLong(5,triple.getContext().getId()); } else { insertTriple.setNull(5, Types.BIGINT); } insertTriple.setBoolean(6,triple.isInferred()); insertTriple.setTimestamp(7, new Timestamp(triple.getCreated().getTime())); int count = insertTriple.executeUpdate(); cacheTriple(triple); return count > 0; } });