UniqueFactory<Relationship> factory = new UniqueFactory.UniqueRelationshipFactory(graph, PROP_INDEX_REL) {
@Override
protected Relationship create(Map<String, Object> properties) {
Relationship rel = source.createRelationshipTo(target, type);
rel.setProperty(PROP_ID, properties.get(PROP_ID));
return rel;
}
@Override
protected void initialize(Relationship rel, Map<String, Object> properties) {
rel.setProperty(PROP_CREATED, System.currentTimeMillis());
}
};
return factory.getOrCreate(PROP_ID, key);
}