Skip to content

Instantly share code, notes, and snippets.

@okram
Created Oct 12, 2011
Embed
What would you like to do?
class ShareSavSchema {
public static Schema generateSchema() {
Schema schema = new Schema();
def thing = schema.addClass("thing");
def timeThing = schema.addClass("time thing");
thing.canHaveProperty("_type", String.class);
timeThing.setSuperClass(thing);
timeThing.addCanHaveProperty("_startDate", Long.class)
timeThing.addCanHaveProperty("_endDate", Long.class)
// SHARE
def shareThing = schema.addClass("share thing");
shareThing.addCanHaveProperty("shareId", Long.class)
shareThing.addCanHaveProperty("structureId", Long.class)
shareThing.addCanHaveProperty("shareName", String.class)
shareThing.setSuperClass(timeThing);
[schema.addClass("super theatre"),
schema.addClass("operation"),
schema.addClass("area"),
schema.addClass("country"),
schema.addClass("team"),
schema.addClass("consolidation"),
schema.addClass("theatre"),
schema.addClass("sub team"),
schema.addClass("region"),
schema.addClass("district/team"),
schema.addClass("market lob")].each {it.setSuperClass(shareThing)}
schema.addRelation("contains", shareThing, shareThing)
/// SAV
def sav = schema.addClass("sav")
sav.setSuperClass(thing);
def savProperty = schema.addClass("sav property")
savProperty.setSuperClass(timeThing)
savProperty.addCanHaveProperty("value", Long.class);
[schema.addClass("ownerId"),
schema.addClass("coverageLevel"),
schema.addClass("shareNodeId"),
schema.addClass("geoBoundary")].each {it.setSuperClass(savProperty)}
def savName = schema.addClass("savName")
savName.canHaveProperty("value", String.class);
savName.setSuperClass(savProperty);
schema.addRelation("hasSav", shareThing, sav);
schema.addRelation("hasProperty", sav, savProperty);
return schema;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment