/** * Converts a {@link RyaIRI} to the contained data string. * @param namespace the namespace. * @param ryaIri the {@link RyaIRI} to convert. * @return the data value without the namespace. */ public static String convertRyaIriToString(final String namespace, final RyaIRI ryaIri) { return StringUtils.replaceOnce(ryaIri.getData(), namespace, ""); }
public String getPrefix() { String data = getStart().getData(); return data.substring(0, data.length() - 1); } }
public void setStatementMetadataProperties(final Set<RyaIRI> metadataProperties) { final String[] propArray = new String[metadataProperties.size()]; int i = 0; for(final RyaIRI uri: metadataProperties) { propArray[i] = uri.getData(); i++; } setStrings(CONF_STATEMENT_METADATA_PROPERTIES, propArray); }
/** * Converts a {@link RyaIRI} into a {@link IRI} representation of the * {@code ryaIri}. * @param ryaIri the {@link RyaIRI} to convert. * @return the {@link IRI} representation of the {@code ryaIri}. */ public static IRI convertIRI(final RyaIRI ryaIri) { return VF.createIRI(ryaIri.getData()); }
private static Bson makeIdFilter(final RyaIRI typeId) { return Filters.eq(TypeDocumentConverter.ID, typeId.getData()); } }
private static Bson makeSubjectFilter(final RyaIRI subject) { return Filters.eq(EntityDocumentConverter.SUBJECT, subject.getData()); }
private static Bson makeExplicitTypeFilter(final RyaIRI typeId) { return Filters.eq(EntityDocumentConverter.EXPLICIT_TYPE_IDS, typeId.getData()); }
public static Map<IRI, Value> entityToValueMap(final Entity entity) { final Map<IRI, Value> map = new LinkedHashMap<>(); for (final Entry<RyaIRI, ImmutableMap<RyaIRI, Property>> entry : entity.getProperties().entrySet()) { for (final Entry<RyaIRI, Property> property : entry.getValue().entrySet()) { final RyaIRI propertyKey = property.getKey(); final IRI iri = VF.createIRI(propertyKey.getData()); final Property propertyValue = property.getValue(); final Value value = RyaToRdfConversions.convertValue(propertyValue.getValue()); map.put(iri, value); } } return map; }
@Override public Document toDocument(final Type type) { requireNonNull(type); final Document doc = new Document(); doc.append(ID, type.getId().getData()); final List<String> propertyNames = new ArrayList<>(); type.getPropertyNames().forEach(field -> propertyNames.add(field.getData())); doc.append(PROPERTY_NAMES, propertyNames); return doc; }
@Override public boolean delete(final RyaIRI subject) throws EntityStorageException { requireNonNull(subject); try { final Document deleted = mongo.getDatabase(ryaInstanceName) .getCollection(COLLECTION_NAME) .findOneAndDelete( makeSubjectFilter(subject) ); return deleted != null; } catch(final MongoException e) { throw new EntityStorageException("Could not delete the Entity with Subject '" + subject.getData() + "'.", e); } }
@Override public boolean delete(final RyaIRI typeId) throws TypeStorageException { requireNonNull(typeId); try { final Document deleted = mongo.getDatabase(ryaInstanceName) .getCollection(COLLECTION_NAME) .findOneAndDelete( makeIdFilter(typeId) ); return deleted != null; } catch(final MongoException e) { throw new TypeStorageException("Could not delete the Type with ID '" + typeId.getData() + "'.", e); } }
private static String getShortNameForType(final RyaIRI type) throws SmartUriException { final String shortName = VF.createIRI(type.getData()).getLocalName(); return shortName; }
@Override public void create(final Type type) throws TypeStorageException { requireNonNull(type); try { mongo.getDatabase(ryaInstanceName) .getCollection(COLLECTION_NAME) .insertOne(TYPE_CONVERTER.toDocument(type)); } catch(final MongoException e) { throw new TypeStorageException("Failed to create Type with ID '" + type.getId().getData() + "'.", e); } }
private int statementSize(final RyaStatement ryaStatement) { final RyaIRI subject = ryaStatement.getSubject(); final RyaIRI predicate = ryaStatement.getPredicate(); final RyaType object = ryaStatement.getObject(); final RyaIRI context = ryaStatement.getContext(); int size = 3 + subject.getData().length() + predicate.getData().length() + object.getData().length(); if (!XMLSchema.ANYURI.equals(object.getDataType())) { size += 2 + object.getDataType().toString().length(); } if (context != null) { size += context.getData().length(); } return size; }
public static Map<IRI, Value> propertiesToMap(final Set<Property> properties) { final Map<IRI, Value> map = new LinkedHashMap<>(); for (final Property property : properties) { final IRI iri = VF.createIRI(property.getName().getData()); final Value value = RyaToRdfConversions.convertValue(property.getValue()); map.put(iri, value); } return map; } }
public static String getTripleString(final RyaStatement rs) { checkNotNull(rs); final String subj = rs.getSubject().getData() + TYPE_DELIM + URI_TYPE; final String pred = rs.getPredicate().getData() + TYPE_DELIM + URI_TYPE; final String objData = rs.getObject().getData(); final String objDataType = rs.getObject().getDataType().stringValue(); return subj + DELIM + pred + DELIM + objData + TYPE_DELIM + objDataType; }
private void init() throws RyaTypeResolverException { commonVar = this.getCommonVar(nodes); if(!commonVar.isConstant()) { commonVarName = commonVar.getName(); } else { commonVarName = commonVar.getName().substring(7); } if(hasContext()) { final RyaIRI ctxtURI = (RyaIRI) RdfToRyaConversions.convertValue(context.getValue()); contextURI = ctxtURI.getData(); } for(int i = 0; i < nodes.size(); i++){ nodeColumnCond[i] = nodeToTextColumn(nodes.get(i), i); } }
public static void ryaStatementsEqualIgnoresBlankNode(Set<RyaStatement> statements1, Set<RyaStatement> statements2) { Map<String, RyaIRI> bNodeMap = new HashMap<>(); statements1.forEach(x-> bNodeMap.put(x.getPredicate().getData(), x.getSubject())); statements2.forEach(x -> x.setSubject(bNodeMap.get(x.getPredicate().getData()))); ryaStatementSetsEqualIgnoresTimestamp(statements1, statements2); }
public static void ryaStatementsEqualIgnoresBlankNode(Set<RyaStatement> statements1, Set<RyaStatement> statements2) { Map<String, RyaIRI> bNodeMap = new HashMap<>(); statements1.forEach(x-> bNodeMap.put(x.getPredicate().getData(), x.getSubject())); statements2.forEach(x -> x.setSubject(bNodeMap.get(x.getPredicate().getData()))); ryaStatementSetsEqualIgnoresTimestamp(statements1, statements2); }