@Override protected Entity newInstance(EntityType type) { return type.create(); } }
public static Thing putEntityWithResource(GraknTx tx, String id, EntityType type, Label key) { Thing inst = type.create(); putResource(inst, tx.getSchemaConcept(key), id); return inst; }
@Override protected void buildInstances(GraknTx tx) { godfather = movie.create(); putResource(godfather, title, "Godfather"); putResource(godfather, tmdbVoteCount, 1000L); theMuppets = movie.create(); putResource(theMuppets, title, "The Muppets"); putResource(theMuppets, tmdbVoteCount, 100L); apocalypseNow = movie.create(); putResource(apocalypseNow, title, "Apocalypse Now"); putResource(apocalypseNow, tmdbVoteCount, 400L); putResource(apocalypseNow, tmdbVoteAverage, 8.4); heat = movie.create(); putResource(heat, title, "Heat"); hocusPocus = movie.create(); putResource(hocusPocus, title, "Hocus Pocus"); putResource(hocusPocus, tmdbVoteCount, 435L); spy = movie.create(); putResource(spy, title, "Spy"); putResource(spy, releaseDate, LocalDate.of(1986, 3, 3).atStartOfDay()); chineseCoffee = movie.create(); putResource(chineseCoffee, title, "Chinese Coffee"); putResource(chineseCoffee, tmdbVoteCount, 5L);
/** * Logs a new {@link Keyspace} to the {@link KeyspaceStore}. * * @param keyspace The new {@link Keyspace} we have just created */ @Override public void addKeyspace(Keyspace keyspace){ if(containsKeyspace(keyspace)) return; try (EmbeddedGraknTx<?> tx = systemKeyspaceSession.transaction(GraknTxType.WRITE)) { AttributeType<String> keyspaceName = tx.getSchemaConcept(KEYSPACE_RESOURCE); if (keyspaceName == null) { throw GraknBackendException.initializationException(keyspace); } Attribute<String> attribute = keyspaceName.create(keyspace.getValue()); if (attribute.owner() == null) { tx.<EntityType>getSchemaConcept(KEYSPACE_ENTITY).create().has(attribute); } tx.commit(); // add to cache existingKeyspaces.add(keyspace); } catch (InvalidKBException e) { throw new RuntimeException("Could not add keyspace [" + keyspace + "] to system graph", e); } }
private Thing putInstance() { Type type = use(TYPE); if (type.isEntityType()) { return type.asEntityType().create(); } else if (type.isRelationshipType()) { return type.asRelationshipType().create(); } else if (type.isAttributeType()) { return type.asAttributeType().create(use(VALUE)); } else if (type.label().equals(Schema.MetaSchema.THING.getLabel())) { throw GraqlQueryException.createInstanceOfMetaConcept(var, type); } else { throw CommonUtil.unreachableStatement("Can't recognize type " + type); } }