Java源码示例:org.apache.commons.collections4.set.ListOrderedSet
示例1
/**
* Called via {@link Schema#ensureEdgeLabelExist(String, VertexLabel, VertexLabel, Map)}
* This is called when the {@link EdgeLabel} does not exist and needs to be created.
*
* @param edgeLabelName The edge's label.
* @param inVertexLabel The edge's in vertex.
* @param properties The edge's properties.
* @param identifiers The edge's user defined identifiers.
* @return The new EdgeLabel.
*/
EdgeLabel addEdgeLabel(
String edgeLabelName,
VertexLabel inVertexLabel,
Map<String, PropertyType> properties,
ListOrderedSet<String> identifiers) {
EdgeLabel edgeLabel = EdgeLabel.createEdgeLabel(edgeLabelName, this, inVertexLabel, properties, identifiers);
if (this.schema.isSqlgSchema()) {
this.outEdgeLabels.put(this.schema.getName() + "." + edgeLabel.getLabel(), edgeLabel);
inVertexLabel.inEdgeLabels.put(this.schema.getName() + "." + edgeLabel.getLabel(), edgeLabel);
} else {
this.uncommittedOutEdgeLabels.put(this.schema.getName() + "." + edgeLabel.getLabel(), edgeLabel);
inVertexLabel.uncommittedInEdgeLabels.put(this.schema.getName() + "." + edgeLabel.getLabel(), edgeLabel);
}
return edgeLabel;
}
示例2
private void referenceGroup(Business business, Wo wo) throws Exception {
EntityManager em = business.entityManagerContainer().get(Group.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Group> cq = cb.createQuery(Group.class);
Root<Group> root = cq.from(Group.class);
Predicate p = cb.isMember(wo.getId(), root.get(Group_.personList));
List<Group> os = em.createQuery(cq.select(root).where(p)).getResultList();
ListOrderedSet<Group> set = new ListOrderedSet<>();
os.stream().forEach(o -> {
set.add(o);
try {
set.addAll(business.group().listSupNestedObject(o));
} catch (Exception e) {
e.printStackTrace();
}
});
List<WoGroup> wos = WoGroup.copier.copy(set.asList());
wos = business.group().sort(wos);
wo.setWoGroupList(wos);
}
示例3
public List<String> listSupNestedWithPerson(String id) throws Exception {
ListOrderedSet<String> set = new ListOrderedSet<>();
List<String> list = new ArrayList<>();
for (String o : this.listSupDirectWithPerson(id)) {
if (!set.contains(o)) {
list.add(o);
}
}
if (!list.isEmpty()) {
set.addAll(list);
for (String str : list) {
this.supNested(str, set);
}
}
return set.asList();
}
示例4
public List<String> listSupNestedWithPerson(String id) throws Exception {
ListOrderedSet<String> set = new ListOrderedSet<>();
List<String> list = new ArrayList<>();
for (String o : this.listSupDirectWithPerson(id)) {
if (!set.contains(o)) {
list.add(o);
}
}
if (!list.isEmpty()) {
set.addAll(list);
for (String str : list) {
this.supNested(str, set);
}
}
return set.asList();
}
示例5
@Test
public void testDeletedVertexUserSuppliedPK() {
this.sqlgGraph.getTopology().getPublicSchema()
.ensureVertexLabelExist(
"Person",
new HashMap<String, PropertyType>() {{
put("name", PropertyType.varChar(100));
}},
ListOrderedSet.listOrderedSet(Collections.singletonList("name"))
);
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "pieter");
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().close();
v1.remove();
this.sqlgGraph.tx().commit();
Assert.assertFalse(this.sqlgGraph.traversal().V(v1.id()).hasNext());
Assert.assertTrue(this.sqlgGraph.traversal().V(v2.id()).hasNext());
}
示例6
@SuppressWarnings("unchecked")
public static <T> List<T> addWithProperty(Object obj, String propertyName, boolean ignoreNull, T... ts)
throws Exception {
List<T> list = new ArrayList<>();
ListOrderedSet<T> set = new ListOrderedSet<T>();
Object o = PropertyUtils.getProperty(obj, propertyName);
if (null != o) {
set.addAll((List<T>) o);
}
for (T t : ts) {
if (null == t && ignoreNull) {
continue;
}
if (!set.contains(t)) {
set.add(t);
list.add(t);
}
}
PropertyUtils.setProperty(obj, propertyName, set.asList());
return list;
}
示例7
@SuppressWarnings("unchecked")
public static <T> List<T> subtractWithProperty(Object obj, String propertyName, T... ts) throws Exception {
List<T> list = new ArrayList<>();
ListOrderedSet<T> set = new ListOrderedSet<T>();
Object o = PropertyUtils.getProperty(obj, propertyName);
if (null != o) {
set.addAll((List<T>) o);
}
for (T t : ts) {
if (set.contains(t)) {
set.remove(t);
list.add(t);
}
}
PropertyUtils.setProperty(obj, propertyName, set.asList());
return list;
}
示例8
@SuppressWarnings("unchecked")
public static <T> List<T> subtractWithProperty(Object obj, String propertyName, List<T> ts) throws Exception {
List<T> list = new ArrayList<>();
ListOrderedSet<T> set = new ListOrderedSet<T>();
Object o = PropertyUtils.getProperty(obj, propertyName);
if (null != o) {
set.addAll((List<T>) o);
}
if (null != ts) {
for (T t : ts) {
if (set.contains(t)) {
set.remove(t);
list.add(t);
}
}
}
PropertyUtils.setProperty(obj, propertyName, set.asList());
return list;
}
示例9
public VertexLabel ensureVertexLabelExist(final String label, final Map<String, PropertyType> columns, ListOrderedSet<String> identifiers) {
Objects.requireNonNull(label, "Given table must not be null");
Preconditions.checkArgument(!label.startsWith(VERTEX_PREFIX), "label may not be prefixed with \"%s\"", VERTEX_PREFIX);
for (String identifier : identifiers) {
Preconditions.checkState(columns.containsKey(identifier), "The identifiers must be in the specified columns. \"%s\" not found", identifier);
}
Optional<VertexLabel> vertexLabelOptional = this.getVertexLabel(label);
if (!vertexLabelOptional.isPresent()) {
this.topology.lock();
vertexLabelOptional = this.getVertexLabel(label);
//noinspection OptionalIsPresent
if (!vertexLabelOptional.isPresent()) {
return this.createVertexLabel(label, columns, identifiers);
} else {
return vertexLabelOptional.get();
}
} else {
VertexLabel vertexLabel = vertexLabelOptional.get();
//check if all the columns are there.
vertexLabel.ensurePropertiesExist(columns);
return vertexLabel;
}
}
示例10
private EdgeLabel(
boolean forSqlgSchema,
String edgeLabelName,
VertexLabel outVertexLabel,
VertexLabel inVertexLabel,
Map<String, PropertyType> properties,
ListOrderedSet<String> identifiers) {
super(outVertexLabel.getSchema().getSqlgGraph(), edgeLabelName, properties, identifiers);
if (forSqlgSchema) {
this.outVertexLabels.add(outVertexLabel);
this.inVertexLabels.add(inVertexLabel);
} else {
this.uncommittedOutVertexLabels.add(outVertexLabel);
this.uncommittedInVertexLabels.add(inVertexLabel);
}
// this is a topology edge label, the columns exist
if (forSqlgSchema) {
for (PropertyColumn pc : this.uncommittedProperties.values()) {
pc.setCommitted(true);
this.properties.put(pc.getName(), pc);
}
this.uncommittedProperties.clear();
}
this.topology = outVertexLabel.getSchema().getTopology();
}
示例11
@Test
public void testRecordIdFromElementUserSuppliedPK() {
this.sqlgGraph.getTopology().getPublicSchema()
.ensureVertexLabelExist(
"A",
new HashMap<String, PropertyType>() {{
put("uid1", PropertyType.varChar(100));
}},
ListOrderedSet.listOrderedSet(Collections.singletonList("uid1")));
String uid1 = UUID.randomUUID().toString();
this.sqlgGraph.addVertex(T.label, "A", "uid1", uid1);
this.sqlgGraph.tx().commit();
RecordId recordId = RecordId.from(this.sqlgGraph, this.sqlgGraph.getTopology().getPublicSchema().getName() + ".A" + RecordId.RECORD_ID_DELIMITER + "[" + uid1 + "]");
Assert.assertEquals(
SchemaTable.of(this.sqlgGraph.getTopology().getPublicSchema().getName(), "A"),
recordId.getSchemaTable()
);
Assert.assertEquals(1, recordId.getIdentifiers().size());
Assert.assertEquals(uid1, recordId.getIdentifiers().get(0));
}
示例12
@Test
public void testRecordIdFromElementUserSuppliedPK_With2Ids() {
this.sqlgGraph.getTopology().getPublicSchema()
.ensureVertexLabelExist(
"A",
new HashMap<String, PropertyType>() {{
put("uid1", PropertyType.varChar(100));
put("uid2", PropertyType.varChar(100));
}},
ListOrderedSet.listOrderedSet(Arrays.asList("uid1", "uid2")));
String uid1 = UUID.randomUUID().toString();
String uid2 = UUID.randomUUID().toString();
this.sqlgGraph.addVertex(T.label, "A", "uid1", uid1, "uid2", uid2);
this.sqlgGraph.tx().commit();
RecordId recordId = RecordId.from(this.sqlgGraph, this.sqlgGraph.getTopology().getPublicSchema().getName() + ".A" + RecordId.RECORD_ID_DELIMITER + "[" + uid1 + ", " + uid2 + "]");
Assert.assertEquals(
SchemaTable.of(this.sqlgGraph.getTopology().getPublicSchema().getName(), "A"),
recordId.getSchemaTable()
);
Assert.assertEquals(2, recordId.getIdentifiers().size());
Assert.assertEquals(uid1, recordId.getIdentifiers().get(0));
Assert.assertEquals(uid2, recordId.getIdentifiers().get(1));
}
示例13
@Test
public void testVertexBatchStreamMode() {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsStreamingBatchMode());
this.sqlgGraph.getTopology().ensureVertexLabelExist(
"A",
new HashMap<String, PropertyType>() {{
put("name1", PropertyType.STRING);
put("name2", PropertyType.STRING);
}},
ListOrderedSet.listOrderedSet(Arrays.asList("name1", "name2"))
);
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().streamingBatchModeOn();
for (int i = 0; i < 100; i++) {
this.sqlgGraph.streamVertex(T.label, "A", "name1", "a" + i, "name2", "a" + i);
}
this.sqlgGraph.tx().commit();
Assert.assertEquals(100, this.sqlgGraph.traversal().V().hasLabel("A").toList().size());
}
示例14
@Test
public void testMultipleIDs() {
Schema aSchema = this.sqlgGraph.getTopology().ensureSchemaExist("A");
aSchema.ensureVertexLabelExist(
"A",
new HashMap<String, PropertyType>(){{
put("uid", PropertyType.varChar(100));
put("country", PropertyType.varChar(100));
}},
ListOrderedSet.listOrderedSet(Arrays.asList("uid", "country")));
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().normalBatchModeOn();
int count = 2;
List<Vertex> ids = new ArrayList<>();
for (int i = 0; i < count; i++) {
Vertex v = this.sqlgGraph.addVertex(T.label, "A.A", "uid", UUID.randomUUID().toString(), "country", "SA");
ids.add(v);
}
this.sqlgGraph.tx().commit();
List<Vertex> vertices = this.sqlgGraph.traversal().V(ids.toArray()).toList();
Assert.assertEquals(count, vertices.size());
}
示例15
@Test(expected = RuntimeException.class)
public void testIdAsPrimaryKeyIsUnique() {
Schema aSchema = this.sqlgGraph.getTopology().ensureSchemaExist("A");
aSchema.ensureVertexLabelExist(
"A",
new HashMap<String, PropertyType>(){{
put("uid", PropertyType.STRING);
put("country", PropertyType.STRING);
}},
ListOrderedSet.listOrderedSet(Arrays.asList("uid", "country")));
this.sqlgGraph.tx().commit();
this.sqlgGraph.tx().normalBatchModeOn();
List<Vertex> ids = new ArrayList<>();
int count = 5;
for (int i = 0; i < count; i++) {
Vertex v = this.sqlgGraph.addVertex(T.label, "A.A", "uid", "aaa", "country", "SA");
ids.add(v);
}
this.sqlgGraph.tx().commit();
}
示例16
static VertexLabel createPartitionedVertexLabel(
SqlgGraph sqlgGraph,
Schema schema,
String label,
Map<String, PropertyType> columns,
ListOrderedSet<String> identifiers,
PartitionType partitionType,
String partitionExpression) {
Preconditions.checkArgument(!schema.isSqlgSchema(), "createVertexLabel may not be called for \"%s\"", SQLG_SCHEMA);
Preconditions.checkArgument(partitionType != PartitionType.NONE, "PartitionType must be RANGE or LIST. Found NONE.");
Preconditions.checkArgument(!StringUtils.isEmpty(partitionExpression), "partitionExpression may not be null or empty when creating a partitioned vertex label.");
Preconditions.checkArgument(!identifiers.isEmpty(), "Partitioned label must have at least one identifier.");
VertexLabel vertexLabel = new VertexLabel(schema, label, columns, identifiers, partitionType, partitionExpression);
vertexLabel.createPartitionedVertexLabelOnDb(columns, identifiers);
TopologyManager.addVertexLabel(sqlgGraph, schema.getName(), label, columns, identifiers, partitionType, partitionExpression);
vertexLabel.committed = false;
return vertexLabel;
}
示例17
/**
* Only called for a new partitioned vertex/edge label being added.
*
* @param label The vertex or edge's label.
* @param properties The element's properties.
* @param identifiers The element's identifiers.
* @param partitionType The partition type. i.e. RANGE or LIST.
* @param partitionExpression The sql fragment to express the partition column or expression.
*/
AbstractLabel(SqlgGraph sqlgGraph, String label, Map<String, PropertyType> properties, ListOrderedSet<String> identifiers, PartitionType partitionType, String partitionExpression) {
Preconditions.checkArgument(partitionType == PartitionType.RANGE || partitionType == PartitionType.LIST, "Only RANGE and LIST partitions are supported. Found %s", partitionType.name());
Preconditions.checkArgument(!partitionExpression.isEmpty(), "partitionExpression may not be an empty string.");
Preconditions.checkArgument(!identifiers.isEmpty(), "Partitioned labels must have at least one identifier.");
this.sqlgGraph = sqlgGraph;
this.label = label;
for (Map.Entry<String, PropertyType> propertyEntry : properties.entrySet()) {
PropertyColumn property = new PropertyColumn(this, propertyEntry.getKey(), propertyEntry.getValue());
property.setCommitted(false);
this.uncommittedProperties.put(propertyEntry.getKey(), property);
}
this.uncommittedIdentifiers.addAll(identifiers);
this.partitionType = partitionType;
this.partitionExpression = partitionExpression;
}
示例18
@Test
public void testMapUserSuppliedPK() {
VertexLabel vertexLabel = this.sqlgGraph.getTopology().getPublicSchema()
.ensureVertexLabelExist(
"Person",
new HashMap<String, PropertyType>() {{
put("uid", PropertyType.varChar(100));
put("name1", PropertyType.STRING);
put("name2", PropertyType.STRING);
put("name3", PropertyType.STRING);
}},
ListOrderedSet.listOrderedSet(Collections.singletonList("uid"))
);
Map<String, Object> map = new HashMap<>();
map.put("uid", UUID.randomUUID().toString());
map.put("name1", "p1");
map.put("name2", "p2");
map.put("name3", "p3");
Vertex v1 = this.sqlgGraph.addVertex("Person", map);
this.sqlgGraph.tx().commit();
Vertex v2 = this.sqlgGraph.traversal().V().has(T.label, "Person").next();
Assert.assertEquals(v1, v2);
Assert.assertEquals("p1", v2.property("name1").value());
Assert.assertEquals("p2", v2.property("name2").value());
Assert.assertEquals("p3", v2.property("name3").value());
}
示例19
static VertexLabel createVertexLabel(SqlgGraph sqlgGraph, Schema schema, String label, Map<String, PropertyType> columns, ListOrderedSet<String> identifiers) {
Preconditions.checkArgument(!schema.isSqlgSchema(), "createVertexLabel may not be called for \"%s\"", SQLG_SCHEMA);
VertexLabel vertexLabel = new VertexLabel(schema, label, columns, identifiers);
vertexLabel.createVertexLabelOnDb(columns, identifiers);
TopologyManager.addVertexLabel(sqlgGraph, schema.getName(), label, columns, identifiers);
vertexLabel.committed = false;
return vertexLabel;
}
示例20
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
Share share = emc.find(id, Share.class);
if (null == share) {
throw new ExceptionAttachmentNotExist(id);
}
/* 判断文件的所有者是否是当前用户 */
if (!StringUtils.equals(effectivePerson.getDistinguishedName(), share.getPerson())) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
EntityManager em = emc.beginTransaction(Share.class);
emc.delete(Share.class, share.getId());
em.getTransaction().commit();
if(!"password".equals(share.getShareType())){
List<String> shareCancels = new ArrayList<>();
shareCancels.addAll(share.getShareUserList());
if(!share.getShareOrgList().isEmpty()){
shareCancels.addAll(business.organization().person().listWithUnitSubNested( share.getShareOrgList() ));
}
ListOrderedSet<String> set = new ListOrderedSet<>();
set.addAll(shareCancels);
shareCancels = set.asList();
/* 发送取消共享通知 */
for (String str : shareCancels) {
this.message_send_attachment_shareCancel(share, str);
}
}
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
示例21
@Test
public void testPartitioningRange() {
Schema publicSchema = this.sqlgGraph.getTopology().getPublicSchema();
VertexLabel partitionedVertexLabel = publicSchema.ensurePartitionedVertexLabelExist(
"Measurement",
new LinkedHashMap<String, PropertyType>() {{
put("date", PropertyType.LOCALDATE);
put("temp", PropertyType.INTEGER);
}},
ListOrderedSet.listOrderedSet(Collections.singletonList("date")),
PartitionType.RANGE,
"date");
partitionedVertexLabel.ensureRangePartitionExists("measurement1", "'2016-07-01'", "'2016-08-01'");
partitionedVertexLabel.ensureRangePartitionExists("measurement2", "'2016-08-01'", "'2016-09-01'");
this.sqlgGraph.tx().commit();
LocalDate localDate1 = LocalDate.of(2016, 7, 1);
this.sqlgGraph.addVertex(T.label, "Measurement", "date", localDate1);
LocalDate localDate2 = LocalDate.of(2016, 8, 1);
this.sqlgGraph.addVertex(T.label, "Measurement", "date", localDate2);
this.sqlgGraph.tx().commit();
Assert.assertEquals(2, this.sqlgGraph.traversal().V().hasLabel("Measurement").count().next(), 0);
Assert.assertEquals(1, this.sqlgGraph.traversal().V().hasLabel("Measurement").has("date", localDate1).count().next(), 0);
Assert.assertEquals(1, this.sqlgGraph.traversal().V().hasLabel("Measurement").has("date", localDate2).count().next(), 0);
Partition partition = this.sqlgGraph.getTopology().getPublicSchema().getVertexLabel("Measurement").get().getPartition("measurement1").get();
partition.remove();
this.sqlgGraph.tx().commit();
Assert.assertEquals(1, this.sqlgGraph.traversal().V().hasLabel("Measurement").count().next(), 0);
Assert.assertEquals(0, this.sqlgGraph.traversal().V().hasLabel("Measurement").has("date", localDate1).count().next(), 0);
Assert.assertEquals(1, this.sqlgGraph.traversal().V().hasLabel("Measurement").has("date", localDate2).count().next(), 0);
Assert.assertEquals(1, this.sqlgGraph.topology().V().hasLabel(Topology.SQLG_SCHEMA + "." + Topology.SQLG_SCHEMA_PARTITION).count().next(), 0);
}
示例22
@Test
public void testShardingWithPartition() {
VertexLabel aVertexLabel = this.sqlgGraph.getTopology().getPublicSchema().ensurePartitionedVertexLabelExist(
"A",
new HashMap<String, PropertyType>() {{
put("uid", PropertyType.STRING);
put("dist", PropertyType.STRING);
put("date", PropertyType.LOCALDATE);
put("value", PropertyType.STRING);
}},
ListOrderedSet.listOrderedSet(Arrays.asList("uid", "dist")),
PartitionType.RANGE,
"date"
);
aVertexLabel.ensureRangePartitionExists("july", "'2016-07-01'", "'2016-08-01'");
aVertexLabel.ensureRangePartitionExists("august", "'2016-08-01'", "'2016-09-01'");
PropertyColumn dist = aVertexLabel.getProperty("dist").orElseThrow(IllegalStateException::new);
aVertexLabel.ensureDistributed(32, dist);
this.sqlgGraph.tx().commit();
LocalDate localDate1 = LocalDate.of(2016, 7, 1);
this.sqlgGraph.addVertex(T.label, "A", "uid", UUID.randomUUID().toString(), "dist", "a", "date", localDate1, "value", "1");
LocalDate localDate2 = LocalDate.of(2016, 8, 1);
this.sqlgGraph.addVertex(T.label, "A", "uid", UUID.randomUUID().toString(), "dist", "b", "date", localDate2, "value", "1");
this.sqlgGraph.tx().commit();
}
示例23
static EdgeLabel loadSqlgSchemaEdgeLabel(
String edgeLabelName,
VertexLabel outVertexLabel,
VertexLabel inVertexLabel,
Map<String, PropertyType> properties) {
//edges are created in the out vertex's schema.
return new EdgeLabel(true, edgeLabelName, outVertexLabel, inVertexLabel, properties, new ListOrderedSet<>());
}
示例24
@Test
public void testRecordIdFromElementUserSuppliedPK_With3Ids() {
this.sqlgGraph.getTopology().getPublicSchema()
.ensureVertexLabelExist(
"A",
new HashMap<String, PropertyType>() {{
put("uid1", PropertyType.varChar(100));
put("uid2", PropertyType.varChar(100));
put("uid3", PropertyType.varChar(100));
}},
ListOrderedSet.listOrderedSet(Arrays.asList("uid1", "uid2", "uid3")));
String uid1 = UUID.randomUUID().toString();
String uid2 = UUID.randomUUID().toString();
String uid3 = UUID.randomUUID().toString();
this.sqlgGraph.addVertex(T.label, "A", "uid1", uid1, "uid2", uid2, "uid3", uid3);
this.sqlgGraph.tx().commit();
RecordId recordId = RecordId.from(this.sqlgGraph, this.sqlgGraph.getTopology().getPublicSchema().getName() + ".A" + RecordId.RECORD_ID_DELIMITER + "[" + uid1 + ", " + uid2 + ", " + uid3 + "]");
Assert.assertEquals(
SchemaTable.of(this.sqlgGraph.getTopology().getPublicSchema().getName(), "A"),
recordId.getSchemaTable()
);
Assert.assertEquals(3, recordId.getIdentifiers().size());
Assert.assertEquals(uid1, recordId.getIdentifiers().get(0));
Assert.assertEquals(uid2, recordId.getIdentifiers().get(1));
Assert.assertEquals(uid3, recordId.getIdentifiers().get(2));
}
示例25
@Test
public void testReloadVertexLabelWithPartitions() {
Schema publicSchema = this.sqlgGraph.getTopology().getPublicSchema();
VertexLabel a = publicSchema.ensurePartitionedVertexLabelExist(
"A",
new LinkedHashMap<String, PropertyType>() {{
put("int1", PropertyType.INTEGER);
put("int2", PropertyType.INTEGER);
put("int3", PropertyType.INTEGER);
}},
ListOrderedSet.listOrderedSet(Collections.singletonList("int1")),
PartitionType.RANGE,
"int1,int2");
a.ensureRangePartitionExists("part1", "1,1", "5,5");
a.ensureRangePartitionExists("part2", "5,5", "10,10");
this.sqlgGraph.tx().commit();
//Delete the topology
dropSqlgSchema(this.sqlgGraph);
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
a = sqlgGraph1.getTopology().getPublicSchema().getVertexLabel("A").get();
Assert.assertEquals("int1,int2", a.getPartitionExpression());
Assert.assertEquals(PartitionType.RANGE, a.getPartitionType());
Optional<Partition> part1 = a.getPartition("part1");
Assert.assertTrue(part1.isPresent());
Assert.assertNull(part1.get().getPartitionExpression());
Assert.assertEquals("1, 1", part1.get().getFrom());
Assert.assertEquals("5, 5", part1.get().getTo());
Optional<Partition> part2 = a.getPartition("part2");
Assert.assertTrue(part2.isPresent());
Assert.assertNull(part2.get().getPartitionExpression());
Assert.assertEquals("5, 5", part2.get().getFrom());
Assert.assertEquals("10, 10", part2.get().getTo());
}
}
示例26
static EdgeLabel createEdgeLabel(
String edgeLabelName,
VertexLabel outVertexLabel,
VertexLabel inVertexLabel,
Map<String, PropertyType> properties) {
return createEdgeLabel(edgeLabelName, outVertexLabel, inVertexLabel, properties, new ListOrderedSet<>());
}
示例27
@Test
public void testGetEdgeById() {
VertexLabel aVertexLabel = this.sqlgGraph.getTopology().ensureVertexLabelExist(
this.sqlgGraph.getSqlDialect().getPublicSchema(),
"A",
new HashMap<String, PropertyType>() {{
put("name", PropertyType.varChar(100));
}},
ListOrderedSet.listOrderedSet(Collections.singletonList("name"))
);
VertexLabel bVertexLabel = this.sqlgGraph.getTopology().ensureVertexLabelExist(
this.sqlgGraph.getSqlDialect().getPublicSchema(),
"B",
new HashMap<String, PropertyType>() {{
put("name", PropertyType.varChar(100));
}},
ListOrderedSet.listOrderedSet(Collections.singletonList("name"))
);
aVertexLabel.ensureEdgeLabelExist(
"ab",
bVertexLabel,
new HashMap<String, PropertyType>() {{
put("name", PropertyType.varChar(100));
put("country", PropertyType.STRING);
}},
ListOrderedSet.listOrderedSet(Collections.singletonList("name"))
);
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "A1");
Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "A1");
Edge e = a1.addEdge("ab", b1, "name", "halo", "country", "earth");
this.sqlgGraph.tx().commit();
Vertex otherV = this.sqlgGraph.traversal().V(a1.id()).next();
Assert.assertEquals(a1, otherV);
Edge other = this.sqlgGraph.traversal().E(e.id()).next();
Assert.assertEquals(e, other);
}
示例28
/**
* Only called for a new vertex/edge label being added.
*
* @param label The vertex or edge's label.
* @param properties The vertex's properties.
* @param identifiers The vertex or edge's identifiers
*/
AbstractLabel(SqlgGraph sqlgGraph, String label, Map<String, PropertyType> properties, ListOrderedSet<String> identifiers) {
this.sqlgGraph = sqlgGraph;
this.label = label;
for (Map.Entry<String, PropertyType> propertyEntry : properties.entrySet()) {
PropertyColumn property = new PropertyColumn(this, propertyEntry.getKey(), propertyEntry.getValue());
property.setCommitted(false);
this.uncommittedProperties.put(propertyEntry.getKey(), property);
}
this.uncommittedIdentifiers.addAll(identifiers);
}
示例29
private VertexLabel createPartitionedVertexLabel(
String vertexLabelName,
Map<String, PropertyType> columns,
ListOrderedSet<String> identifers,
PartitionType partitionType,
String partitionExpression) {
Preconditions.checkState(!this.isSqlgSchema(), "createVertexLabel may not be called for \"%s\"", SQLG_SCHEMA);
Preconditions.checkArgument(!vertexLabelName.startsWith(VERTEX_PREFIX), "vertex label may not start with " + VERTEX_PREFIX);
this.sqlgGraph.getSqlDialect().validateTableName(vertexLabelName);
for (String columnName : columns.keySet()) {
this.sqlgGraph.getSqlDialect().validateColumnName(columnName);
}
this.uncommittedRemovedVertexLabels.remove(this.name + "." + VERTEX_PREFIX + vertexLabelName);
VertexLabel vertexLabel = VertexLabel.createPartitionedVertexLabel(
this.sqlgGraph,
this,
vertexLabelName,
columns,
identifers,
partitionType,
partitionExpression
);
this.uncommittedVertexLabels.put(this.name + "." + VERTEX_PREFIX + vertexLabelName, vertexLabel);
this.getTopology().fire(vertexLabel, "", TopologyChangeAction.CREATE);
return vertexLabel;
}
示例30
public EdgeLabel ensureEdgeLabelExist(
final String edgeLabelName,
final VertexLabel outVertexLabel,
final VertexLabel inVertexLabel,
Map<String, PropertyType> columns) {
return ensureEdgeLabelExist(edgeLabelName, outVertexLabel, inVertexLabel, columns, new ListOrderedSet<>());
}