forked from 2pm.tech/traqtor
No supperss warnings at last
parent
fbbe79e9a7
commit
dd9a274f0a
@ -1,26 +1,164 @@
|
|||||||
package link.pagan.traqtor;
|
package link.pagan.traqtor;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.DatabaseProject;
|
||||||
|
import link.pagan.traqtor.project.UniverseProject;
|
||||||
|
import link.pagan.traqtor.project.database.DatabaseSchema;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
import link.pagan.traqtor.project.universe.element.Atom;
|
||||||
|
import link.pagan.traqtor.project.universe.element.Isotope;
|
||||||
|
import link.pagan.traqtor.project.universe.link.ManyToManyLink;
|
||||||
|
import link.pagan.traqtor.project.universe.link.OneToManyLink;
|
||||||
|
import link.pagan.traqtor.project.universe.link.OneToOneLink;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.LiteralDataTypeSchema;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.LogicDatatypeSchema;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.NumericDatatypeSchema;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.TemporalDatatypeSchema;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.LiteralDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.RationalDataType;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class EndToEndTest {
|
public class EndToEndTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void endToEndTest() {
|
void endToEndTest() {
|
||||||
DatatypeSchema refSchema = new ReferenceDatatypeSchema();
|
LiteralDataTypeSchema LITERAL = LiteralDataTypeSchema.instance();
|
||||||
DatatypeSchema altSchema = new AlternativeDatatypeSchema();
|
LogicDatatypeSchema LOGIC = LogicDatatypeSchema.instance();
|
||||||
|
NumericDatatypeSchema NUMERIC = NumericDatatypeSchema.instance();
|
||||||
|
TemporalDatatypeSchema TEMPORAL = TemporalDatatypeSchema.instance();
|
||||||
|
|
||||||
|
LiteralDataType STRING = LITERAL.STRING;
|
||||||
|
// LogicDataType BOOLEAN = LOGIC.BOOLEAN;
|
||||||
|
// IntegerDataType BYTE = NUMERIC.BYTE;
|
||||||
|
// IntegerDataType SHORT = NUMERIC.SHORT;
|
||||||
|
// IntegerDataType INTEGER = NUMERIC.INTEGER;
|
||||||
|
// IntegerDataType LONG = NUMERIC.LONG;
|
||||||
|
RationalDataType FLOAT = NUMERIC.FLOAT;
|
||||||
|
RationalDataType DOUBLE = NUMERIC.DOUBLE;
|
||||||
|
// TemporalDataType DATE = TEMPORAL.DATE;
|
||||||
|
// TemporalDataType TIME = TEMPORAL.TIME;
|
||||||
|
// TemporalDataType TIMESTAMP = TEMPORAL.TIMESTAMP;
|
||||||
|
|
||||||
WorkspaceBuilder builder = new WorkspaceBuilder();
|
Atom account = new Atom()
|
||||||
builder.addDatatypeSchema();
|
.name(new Name("account"))
|
||||||
|
.addParticle(STRING.particle()
|
||||||
|
.name(new Name("email"))
|
||||||
|
.description("email as main identifier for an account")
|
||||||
|
)
|
||||||
|
.addParticle(STRING.particle()
|
||||||
|
.name(new Name("phone"))
|
||||||
|
.description("alternative identifier for an account")
|
||||||
|
);
|
||||||
|
|
||||||
UniverseProjectBuilder upb = new UniverseProjectBuilder()
|
Atom accountDetails = new Atom()
|
||||||
.addSchema(refSchema).addSchema(altSchema);
|
.name(new Name("account", "details"))
|
||||||
|
.addParticle(STRING.particle()
|
||||||
.addProject(
|
.name(new Name("first", "name"))
|
||||||
new
|
.description("first name of user")
|
||||||
)
|
)
|
||||||
|
.addParticle(STRING.particle()
|
||||||
|
.name(new Name("last", "name"))
|
||||||
|
.description("last name of user")
|
||||||
|
);
|
||||||
|
|
||||||
|
Isotope male = new Isotope()
|
||||||
|
.base(account)
|
||||||
|
.name(new Name("male"))
|
||||||
|
.addParticle(DOUBLE.particle()
|
||||||
|
.name(new Name("length"))
|
||||||
|
.description("penis length")
|
||||||
|
);
|
||||||
|
|
||||||
}
|
Isotope female = new Isotope()
|
||||||
|
.base(account)
|
||||||
|
.name(new Name("female"))
|
||||||
|
.addParticle(FLOAT.particle()
|
||||||
|
.name(new Name("depth"))
|
||||||
|
.description("vagina depth")
|
||||||
|
);
|
||||||
|
|
||||||
|
Atom position = new Atom()
|
||||||
|
.name(new Name("position"))
|
||||||
|
.addParticle(STRING.particle()
|
||||||
|
.name(new Name("title"))
|
||||||
|
.description("position name")
|
||||||
|
);
|
||||||
|
|
||||||
|
Atom militaryId = new Atom()
|
||||||
|
.name(new Name("military", "id"))
|
||||||
|
.addParticle(STRING.particle()
|
||||||
|
.name(new Name("number"))
|
||||||
|
.description("military id number")
|
||||||
|
);
|
||||||
|
|
||||||
|
Atom profile = new Atom()
|
||||||
|
.name((new Name("profile"))
|
||||||
|
);
|
||||||
|
|
||||||
|
UniverseProject baseUniverse = new UniverseProject()
|
||||||
|
.name(new Name("base"))
|
||||||
|
.importSchema(LITERAL)
|
||||||
|
.importSchema(LOGIC)
|
||||||
|
.importSchema(NUMERIC)
|
||||||
|
.importSchema(TEMPORAL)
|
||||||
|
.addElement(account)
|
||||||
|
.addElement(accountDetails)
|
||||||
|
.addElement(male)
|
||||||
|
.addElement(female)
|
||||||
|
.addElement(position)
|
||||||
|
.addElement(militaryId)
|
||||||
|
.addElement(profile)
|
||||||
|
.addLink(new OneToOneLink()
|
||||||
|
.from(account)
|
||||||
|
.fromName(new Name("details"))
|
||||||
|
.to(accountDetails)
|
||||||
|
.toName(new Name("account"))
|
||||||
|
.mandatory()
|
||||||
|
)
|
||||||
|
.addLink(new OneToManyLink()
|
||||||
|
.from(account)
|
||||||
|
.fromName(new Name("profiles"))
|
||||||
|
.to(profile)
|
||||||
|
.toName(new Name("account"))
|
||||||
|
.more(0)
|
||||||
|
)
|
||||||
|
.addLink(new ManyToManyLink()
|
||||||
|
.from(profile)
|
||||||
|
.fromName(new Name("positions"))
|
||||||
|
.to(position)
|
||||||
|
.toName(new Name("profiles"))
|
||||||
|
)
|
||||||
|
.addLink(new OneToOneLink()
|
||||||
|
.from(male)
|
||||||
|
.fromName(new Name("military", "id"))
|
||||||
|
.to(militaryId)
|
||||||
|
.toName(new Name("account"))
|
||||||
|
);
|
||||||
|
|
||||||
|
UniverseProject dataUniverse = new UniverseProject()
|
||||||
|
.name(new Name("data"))
|
||||||
|
.importSchema(LITERAL)
|
||||||
|
.addElement(new Atom()
|
||||||
|
.name(new Name("organization"))
|
||||||
|
.addParticle(STRING.particle()
|
||||||
|
.name(new Name("name"))
|
||||||
|
.description("full name of an organization")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
DatabaseProject mainDatabase = new DatabaseProject()
|
||||||
|
.name(new Name("primary"))
|
||||||
|
.addSchema(new DatabaseSchema()
|
||||||
|
.name(new Name("public"))
|
||||||
|
// .table("base", "account")
|
||||||
|
// .table("base", "account", "details")
|
||||||
|
// .table("data", "organization")
|
||||||
|
);
|
||||||
|
|
||||||
|
new Workspace()
|
||||||
|
.name(new Name("link", "pagan"))
|
||||||
|
.addProject(baseUniverse)
|
||||||
|
.addProject(dataUniverse)
|
||||||
|
.addProject(mainDatabase);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package link.pagan.traqtor;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.Project;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
class Workspace {
|
||||||
|
|
||||||
|
public Workspace name(Name name) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Workspace addProject(Project project) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,89 +0,0 @@
|
|||||||
package link.pagan.traqtor.generator;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import link.pagan.traqtor._api.result.CommandExecResult;
|
|
||||||
import static link.pagan.traqtor._api.result.CommandExecResultStatus.DONE;
|
|
||||||
import link.pagan.traqtor.api.API;
|
|
||||||
import link.pagan.traqtor.api.Traqtor;
|
|
||||||
import link.pagan.traqtor.generator.blueprint.universe.LinkType;
|
|
||||||
import link.pagan.traqtor.generator.blueprint.universe.build.LinkBlueprintBuilder;
|
|
||||||
import link.pagan.traqtor.generator.blueprint.universe.build.AtomBlueprintBuilder;
|
|
||||||
import link.pagan.traqtor.generator.blueprint.universe.build.ParticleBlueprintBuilder;
|
|
||||||
import link.pagan.traqtor.generator.blueprint.universe.build.UniverseBlueprintBuilder;
|
|
||||||
import link.pagan.traqtor.generator.blueprint.universe.UniverseBlueprint;
|
|
||||||
import link.pagan.traqtor.util.Name;
|
|
||||||
import link.pagan.traqtor.schema.basic.data.DataTypeSchemaReferenceImplementation;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
|
||||||
*/
|
|
||||||
public class UniverseBlueprintTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void programmaticBuild() throws JsonProcessingException {
|
|
||||||
UniverseBlueprintBuilder builder = new UniverseBlueprintBuilder(new DataTypeSchemaReferenceImplementation());
|
|
||||||
builder
|
|
||||||
.addAtom(new AtomBlueprintBuilder()
|
|
||||||
.name(Name.of("account"))
|
|
||||||
.description("Base user atom")
|
|
||||||
.addParticle(new ParticleBlueprintBuilder()
|
|
||||||
.name(Name.of("nickname"))
|
|
||||||
.description("User nickname, just in case")
|
|
||||||
.type("string")
|
|
||||||
)
|
|
||||||
.addParticle(new ParticleBlueprintBuilder()
|
|
||||||
.name(Name.of("email"))
|
|
||||||
.description("Main auth facility for user")
|
|
||||||
.type("string")
|
|
||||||
)
|
|
||||||
.addParticle(new ParticleBlueprintBuilder()
|
|
||||||
.name(Name.of("phone"))
|
|
||||||
.description("Alternative user authentification facility")
|
|
||||||
.type("string")
|
|
||||||
)
|
|
||||||
.addParticle(new ParticleBlueprintBuilder()
|
|
||||||
.name(Name.of("password"))
|
|
||||||
.description("User password")
|
|
||||||
.type("string")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.addAtom(new AtomBlueprintBuilder()
|
|
||||||
.name(Name.of("account", "details"))
|
|
||||||
.description("User info atom")
|
|
||||||
.addParticle(new ParticleBlueprintBuilder()
|
|
||||||
.name(Name.of("first", "name"))
|
|
||||||
.description("First name of a user")
|
|
||||||
.type("string")
|
|
||||||
)
|
|
||||||
.addParticle(new ParticleBlueprintBuilder()
|
|
||||||
.name(Name.of("last", "name"))
|
|
||||||
.description("Last name of a user")
|
|
||||||
.type("string")
|
|
||||||
)
|
|
||||||
.addParticle(new ParticleBlueprintBuilder()
|
|
||||||
.name(Name.of("middle", "names"))
|
|
||||||
.description("Middle names of a user")
|
|
||||||
.type("string")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.addLink(new LinkBlueprintBuilder()
|
|
||||||
.from(Name.of("account"))
|
|
||||||
.to(Name.of("account", "details"))
|
|
||||||
.type(LinkType.ONE_TO_ONE)
|
|
||||||
);
|
|
||||||
|
|
||||||
UniverseBlueprint build = builder.build();
|
|
||||||
|
|
||||||
Traqtor traqtor = Traqtor.init();
|
|
||||||
CommandExecResult result = traqtor.execute(new API.CreateWorkspace());
|
|
||||||
assertEquals(result.getStatus(), DONE);
|
|
||||||
assertEquals(traqtor.workspace().dirty(), true);
|
|
||||||
String serialized = traqtor.workspace().mapper().writeValueAsString(build);
|
|
||||||
System.out.println(serialized);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package link.pagan.traqtor.project;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.database.DatabaseSchema;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class DatabaseProject extends Project {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DatabaseProject name(Name name) {
|
||||||
|
super.name(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatabaseProject addSchema(DatabaseSchema name) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package link.pagan.traqtor.project;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
public class Project {
|
||||||
|
|
||||||
|
public Project name(Name name){
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package link.pagan.traqtor.project;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DatatypeSchema;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
import link.pagan.traqtor.project.universe.Link;
|
||||||
|
import link.pagan.traqtor.project.universe.Element;
|
||||||
|
|
||||||
|
public class UniverseProject extends Project {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UniverseProject name(Name name){
|
||||||
|
super.name(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UniverseProject importSchema (DatatypeSchema schema) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UniverseProject addElement (Element element) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UniverseProject addLink(Link link) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package link.pagan.traqtor.project.database;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class DatabaseSchema {
|
||||||
|
|
||||||
|
public DatabaseSchema name(Name name) {
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package link.pagan.traqtor.project.universe;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
public class Element {
|
||||||
|
|
||||||
|
public Element name(Name name){
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Element addParticle(Particle<?> particle) {
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package link.pagan.traqtor.project.universe;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
public class Link {
|
||||||
|
|
||||||
|
public Link from(Element element) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Link to(Element element) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Link fromName(Name name) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Link toName(Name name) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package link.pagan.traqtor.project.universe;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DataType;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
public class Particle<T extends DataType> {
|
||||||
|
|
||||||
|
final DataType type;
|
||||||
|
Name name;
|
||||||
|
String description;
|
||||||
|
|
||||||
|
public Particle(DataType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Particle<T> name(Name name) {
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Particle<T> description(String description) {
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package link.pagan.traqtor.project.universe;
|
||||||
|
|
||||||
|
public class UniverseSchema {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.element;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Element;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
|
||||||
|
public class Atom extends Element {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Atom name(Name name){
|
||||||
|
super.name(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Atom addParticle(Particle<?> particle) {
|
||||||
|
super.addParticle(particle);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.element;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Element;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
|
||||||
|
public class Isotope extends Element {
|
||||||
|
|
||||||
|
Element base;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Isotope name(Name name) {
|
||||||
|
super.name(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Isotope addParticle(Particle<?> particle) {
|
||||||
|
super.addParticle(particle);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Isotope base(Element base) {
|
||||||
|
this.base = base;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.link;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Link;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
import link.pagan.traqtor.project.universe.Element;
|
||||||
|
|
||||||
|
public class ManyToManyLink extends Link {
|
||||||
|
|
||||||
|
public ManyToManyLink from(Element element) {
|
||||||
|
super.from(element);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ManyToManyLink to(Element element) {
|
||||||
|
super.to(element);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ManyToManyLink fromName(Name name) {
|
||||||
|
super.fromName(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ManyToManyLink toName(Name name) {
|
||||||
|
super.toName(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.link;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Link;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
import link.pagan.traqtor.project.universe.Element;
|
||||||
|
|
||||||
|
public class OneToManyLink extends Link {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OneToManyLink from(Element element) {
|
||||||
|
super.from(element);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OneToManyLink to(Element element) {
|
||||||
|
super.to(element);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OneToManyLink fromName(Name name) {
|
||||||
|
super.fromName(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OneToManyLink toName(Name name) {
|
||||||
|
super.toName(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OneToManyLink more(int count) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OneToManyLink less(int count) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OneToManyLink exact(int count) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.link;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Link;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
import link.pagan.traqtor.project.universe.Element;
|
||||||
|
|
||||||
|
public class OneToOneLink extends Link {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OneToOneLink from(Element element) {
|
||||||
|
super.from(element);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OneToOneLink to(Element element) {
|
||||||
|
super.to(element);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OneToOneLink fromName(Name name) {
|
||||||
|
super.fromName(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OneToOneLink toName(Name name) {
|
||||||
|
super.toName(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OneToOneLink mandatory() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
* @param <T> type to which this constraint is applicable
|
||||||
|
*/
|
||||||
|
public class Constraint <T extends DataType> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
|
||||||
|
public abstract class DataType {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
protected DataType (){
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataType(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public abstract DataType type();
|
||||||
|
|
||||||
|
public abstract Particle<? extends DataType> particle();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package link.pagan.traqtor.project.universe.schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public abstract class DatatypeSchema {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DatatypeSchema;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.LiteralDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.literal.StringDataType;
|
||||||
|
|
||||||
|
public class LiteralDataTypeSchema extends DatatypeSchema {
|
||||||
|
|
||||||
|
private static final LiteralDataTypeSchema instance = new LiteralDataTypeSchema();
|
||||||
|
|
||||||
|
public final LiteralDataType STRING = StringDataType.instance();
|
||||||
|
|
||||||
|
public static LiteralDataTypeSchema instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DatatypeSchema;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.LogicDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.logic.BooleanDataType;
|
||||||
|
|
||||||
|
public class LogicDatatypeSchema extends DatatypeSchema {
|
||||||
|
|
||||||
|
private static final LogicDatatypeSchema instance = new LogicDatatypeSchema();
|
||||||
|
|
||||||
|
public final LogicDataType BOOLEAN = BooleanDataType.instance();
|
||||||
|
|
||||||
|
public static LogicDatatypeSchema instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DatatypeSchema;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.IntegerDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.RationalDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.ByteDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.IntDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.LongDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.ShortDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.real.DoubleDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.real.FloatDataType;
|
||||||
|
|
||||||
|
public class NumericDatatypeSchema extends DatatypeSchema {
|
||||||
|
|
||||||
|
private static final NumericDatatypeSchema instance = new NumericDatatypeSchema();
|
||||||
|
|
||||||
|
public final IntegerDataType BYTE = ByteDataType.instance();
|
||||||
|
public final IntegerDataType SHORT = ShortDataType.instance();
|
||||||
|
public final IntegerDataType INTEGER = IntDataType.instance();
|
||||||
|
public final IntegerDataType LONG = LongDataType.instance();
|
||||||
|
|
||||||
|
public final RationalDataType FLOAT = FloatDataType.instance();
|
||||||
|
public final RationalDataType DOUBLE = DoubleDataType.instance();
|
||||||
|
|
||||||
|
public static NumericDatatypeSchema instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DatatypeSchema;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.TemporalDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.temporal.DateDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.temporal.TimeDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.temporal.TimestampDataType;
|
||||||
|
|
||||||
|
public class TemporalDatatypeSchema extends DatatypeSchema {
|
||||||
|
|
||||||
|
private static final TemporalDatatypeSchema instance = new TemporalDatatypeSchema();
|
||||||
|
|
||||||
|
public final TemporalDataType DATE = DateDataType.instance();
|
||||||
|
public final TemporalDataType TIME = TimeDataType.instance();
|
||||||
|
public final TemporalDataType TIMESTAMP = TimestampDataType.instance();
|
||||||
|
|
||||||
|
public static TemporalDatatypeSchema instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.constraints;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class NotNullConstraint extends Constraint<DataType> {
|
||||||
|
|
||||||
|
public NotNullConstraint() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public abstract class LiteralDataType extends DataType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Particle<? extends LiteralDataType> particle();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public abstract class LogicDataType extends DataType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Particle<? extends LogicDataType> particle();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public abstract class NumericDataType extends DataType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Particle<? extends NumericDataType> particle();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.DataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public abstract class TemporalDataType extends DataType {
|
||||||
|
|
||||||
|
final List<Constraint<? extends TemporalDataType>> typeConstraints;
|
||||||
|
|
||||||
|
public TemporalDataType(List<Constraint<? extends TemporalDataType>> typeConstraints) {
|
||||||
|
this.typeConstraints = typeConstraints;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Particle<? extends TemporalDataType> particle();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.literal;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class StringDataType extends LiteralDataType {
|
||||||
|
|
||||||
|
private static final StringDataType instance = new StringDataType();
|
||||||
|
|
||||||
|
final List<Constraint<? extends LiteralDataType>> typeConstraints;
|
||||||
|
|
||||||
|
public static StringDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringDataType() {
|
||||||
|
this.typeConstraints = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<StringDataType> particle() {
|
||||||
|
return new Particle<StringDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.logic;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class BooleanDataType extends LogicDataType {
|
||||||
|
|
||||||
|
private static final BooleanDataType instance = new BooleanDataType();
|
||||||
|
|
||||||
|
final List<Constraint<? extends LogicDataType>> typeConstraints;
|
||||||
|
|
||||||
|
public static BooleanDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BooleanDataType() {
|
||||||
|
this.typeConstraints = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<BooleanDataType> particle() {
|
||||||
|
return new Particle<BooleanDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.NumericDataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public abstract class IntegerDataType extends NumericDataType {
|
||||||
|
|
||||||
|
final List<Constraint<? extends IntegerDataType>> typeConstraints;
|
||||||
|
|
||||||
|
public IntegerDataType(List<Constraint<? extends IntegerDataType>> typeConstraints) {
|
||||||
|
this.typeConstraints = typeConstraints;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Particle<? extends IntegerDataType> particle();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.NumericDataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public abstract class RationalDataType extends NumericDataType {
|
||||||
|
|
||||||
|
final List<Constraint<? extends RationalDataType>> typeConstraints;
|
||||||
|
|
||||||
|
public RationalDataType(List<Constraint<? extends RationalDataType>> typeConstraints) {
|
||||||
|
this.typeConstraints = typeConstraints;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Particle<? extends RationalDataType> particle();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.IntegerDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints.IntegerMaxConstraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints.IntegerMinConstraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class ByteDataType extends IntegerDataType {
|
||||||
|
|
||||||
|
private static final ByteDataType instance = new ByteDataType();
|
||||||
|
|
||||||
|
public static ByteDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ByteDataType() {
|
||||||
|
super(new ArrayList<>() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
{
|
||||||
|
add(new IntegerMaxConstraint(Byte.MAX_VALUE));
|
||||||
|
add(new IntegerMinConstraint(Byte.MIN_VALUE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<ByteDataType> particle() {
|
||||||
|
return new Particle<ByteDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.IntegerDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints.IntegerMaxConstraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints.IntegerMinConstraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class IntDataType extends IntegerDataType {
|
||||||
|
|
||||||
|
private static final IntDataType instance = new IntDataType();
|
||||||
|
|
||||||
|
public static IntDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IntDataType() {
|
||||||
|
super(new ArrayList<>() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
{
|
||||||
|
add(new IntegerMaxConstraint(Integer.MAX_VALUE));
|
||||||
|
add(new IntegerMinConstraint(Integer.MIN_VALUE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<IntDataType> particle() {
|
||||||
|
return new Particle<IntDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.IntegerDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints.IntegerMaxConstraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints.IntegerMinConstraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class LongDataType extends IntegerDataType {
|
||||||
|
|
||||||
|
private static final LongDataType instance = new LongDataType();
|
||||||
|
|
||||||
|
public static LongDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LongDataType() {
|
||||||
|
super(new ArrayList<>() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
{
|
||||||
|
add(new IntegerMaxConstraint(Long.MAX_VALUE));
|
||||||
|
add(new IntegerMinConstraint(Long.MIN_VALUE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<LongDataType> particle() {
|
||||||
|
return new Particle<LongDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.IntegerDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints.IntegerMaxConstraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints.IntegerMinConstraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class ShortDataType extends IntegerDataType {
|
||||||
|
|
||||||
|
private static final ShortDataType instance = new ShortDataType();
|
||||||
|
|
||||||
|
public static ShortDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ShortDataType() {
|
||||||
|
super(new ArrayList<>() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
{
|
||||||
|
add(new IntegerMaxConstraint(Short.MAX_VALUE));
|
||||||
|
add(new IntegerMinConstraint(Short.MIN_VALUE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<ShortDataType> particle() {
|
||||||
|
return new Particle<ShortDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.IntegerDataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class IntegerMaxConstraint extends Constraint<IntegerDataType> {
|
||||||
|
|
||||||
|
long max;
|
||||||
|
|
||||||
|
public IntegerMaxConstraint(long max) {
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.integer.constraints;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.IntegerDataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class IntegerMinConstraint extends Constraint<IntegerDataType> {
|
||||||
|
|
||||||
|
long min;
|
||||||
|
|
||||||
|
public IntegerMinConstraint(long min) {
|
||||||
|
this.min = min;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.real;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.RationalDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.real.constraints.RationalMaxConstraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.real.constraints.RationalMinConstraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class DoubleDataType extends RationalDataType {
|
||||||
|
|
||||||
|
private static final DoubleDataType instance = new DoubleDataType();
|
||||||
|
|
||||||
|
public static DoubleDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DoubleDataType() {
|
||||||
|
super(new ArrayList<>() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
{
|
||||||
|
add(new RationalMaxConstraint(Double.MAX_VALUE));
|
||||||
|
add(new RationalMinConstraint(Double.MIN_VALUE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<DoubleDataType> particle() {
|
||||||
|
return new Particle<DoubleDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.real;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.RationalDataType;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.real.constraints.RationalMaxConstraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.real.constraints.RationalMinConstraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class FloatDataType extends RationalDataType {
|
||||||
|
|
||||||
|
private static final FloatDataType instance = new FloatDataType();
|
||||||
|
|
||||||
|
public static FloatDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FloatDataType() {
|
||||||
|
super(new ArrayList<>() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
{
|
||||||
|
add(new RationalMaxConstraint(Float.MAX_VALUE));
|
||||||
|
add(new RationalMinConstraint(Float.MIN_VALUE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<FloatDataType> particle() {
|
||||||
|
return new Particle<FloatDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.real.constraints;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.RationalDataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class RationalMaxConstraint extends Constraint<RationalDataType> {
|
||||||
|
|
||||||
|
double max;
|
||||||
|
|
||||||
|
public RationalMaxConstraint(double max) {
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.numeric.real.constraints;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.project.universe.schema.Constraint;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.numeric.RationalDataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class RationalMinConstraint extends Constraint<RationalDataType> {
|
||||||
|
|
||||||
|
double min;
|
||||||
|
|
||||||
|
public RationalMinConstraint(double min) {
|
||||||
|
this.min = min;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.temporal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.*;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class DateDataType extends TemporalDataType {
|
||||||
|
|
||||||
|
private static final DateDataType instance = new DateDataType();
|
||||||
|
|
||||||
|
public static DateDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DateDataType() {
|
||||||
|
super(new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<DateDataType> particle() {
|
||||||
|
return new Particle<DateDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.temporal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.*;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class TimeDataType extends TemporalDataType {
|
||||||
|
|
||||||
|
private static final TimeDataType instance = new TimeDataType();
|
||||||
|
|
||||||
|
public static TimeDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TimeDataType() {
|
||||||
|
super(new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<TimeDataType> particle() {
|
||||||
|
return new Particle<TimeDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package link.pagan.traqtor.project.universe.schema.impl.data.temporal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import link.pagan.traqtor.project.universe.schema.impl.data.*;
|
||||||
|
import link.pagan.traqtor.project.universe.Particle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class TimestampDataType extends TemporalDataType {
|
||||||
|
|
||||||
|
private static final TimestampDataType instance = new TimestampDataType();
|
||||||
|
|
||||||
|
public static TimestampDataType instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TimestampDataType() {
|
||||||
|
super(new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Particle<TimestampDataType> particle() {
|
||||||
|
return new Particle<TimestampDataType>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package link.pagan.traqtor.util;
|
||||||
|
|
||||||
|
public class Name {
|
||||||
|
|
||||||
|
public Name(String... string) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,3 +1,5 @@
|
|||||||
|
package link.pagan.z_old;
|
||||||
|
|
||||||
// package link.pagan.traqtor._api;
|
// package link.pagan.traqtor._api;
|
||||||
|
|
||||||
// import java.io.File;
|
// import java.io.File;
|
||||||
@ -1,3 +1,5 @@
|
|||||||
|
package link.pagan.z_old;
|
||||||
|
|
||||||
// package link.pagan.traqtor.api;
|
// package link.pagan.traqtor.api;
|
||||||
|
|
||||||
// import java.io.IOException;
|
// import java.io.IOException;
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
package link.pagan.z_old;
|
||||||
|
|
||||||
|
//package link.pagan.traqtor.generator;
|
||||||
|
//
|
||||||
|
//import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
//import link.pagan.traqtor._api.result.CommandExecResult;
|
||||||
|
//import static link.pagan.traqtor._api.result.CommandExecResultStatus.DONE;
|
||||||
|
//import link.pagan.traqtor.api.API;
|
||||||
|
//import link.pagan.traqtor.api.Traqtor;
|
||||||
|
//import link.pagan.traqtor.generator.blueprint.universe.LinkType;
|
||||||
|
//import link.pagan.traqtor.generator.blueprint.universe.build.LinkBlueprintBuilder;
|
||||||
|
//import link.pagan.traqtor.generator.blueprint.universe.build.AtomBlueprintBuilder;
|
||||||
|
//import link.pagan.traqtor.generator.blueprint.universe.build.ParticleBlueprintBuilder;
|
||||||
|
//import link.pagan.traqtor.generator.blueprint.universe.build.UniverseBlueprintBuilder;
|
||||||
|
//import link.pagan.traqtor.generator.blueprint.universe.UniverseBlueprint;
|
||||||
|
//import link.pagan.traqtor.util.Name;
|
||||||
|
//import link.pagan.traqtor.schema.basic.data.DataTypeSchemaReferenceImplementation;
|
||||||
|
//import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
//import org.junit.jupiter.api.Test;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// *
|
||||||
|
// * @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
// */
|
||||||
|
//public class UniverseBlueprintTest {
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
|
// void programmaticBuild() throws JsonProcessingException {
|
||||||
|
// UniverseBlueprintBuilder builder = new UniverseBlueprintBuilder(new DataTypeSchemaReferenceImplementation());
|
||||||
|
// builder
|
||||||
|
// .addAtom(new AtomBlueprintBuilder()
|
||||||
|
// .name(Name.of("account"))
|
||||||
|
// .description("Base user atom")
|
||||||
|
// .addParticle(new ParticleBlueprintBuilder()
|
||||||
|
// .name(Name.of("nickname"))
|
||||||
|
// .description("User nickname, just in case")
|
||||||
|
// .type("string")
|
||||||
|
// )
|
||||||
|
// .addParticle(new ParticleBlueprintBuilder()
|
||||||
|
// .name(Name.of("email"))
|
||||||
|
// .description("Main auth facility for user")
|
||||||
|
// .type("string")
|
||||||
|
// )
|
||||||
|
// .addParticle(new ParticleBlueprintBuilder()
|
||||||
|
// .name(Name.of("phone"))
|
||||||
|
// .description("Alternative user authentification facility")
|
||||||
|
// .type("string")
|
||||||
|
// )
|
||||||
|
// .addParticle(new ParticleBlueprintBuilder()
|
||||||
|
// .name(Name.of("password"))
|
||||||
|
// .description("User password")
|
||||||
|
// .type("string")
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// .addAtom(new AtomBlueprintBuilder()
|
||||||
|
// .name(Name.of("account", "details"))
|
||||||
|
// .description("User info atom")
|
||||||
|
// .addParticle(new ParticleBlueprintBuilder()
|
||||||
|
// .name(Name.of("first", "name"))
|
||||||
|
// .description("First name of a user")
|
||||||
|
// .type("string")
|
||||||
|
// )
|
||||||
|
// .addParticle(new ParticleBlueprintBuilder()
|
||||||
|
// .name(Name.of("last", "name"))
|
||||||
|
// .description("Last name of a user")
|
||||||
|
// .type("string")
|
||||||
|
// )
|
||||||
|
// .addParticle(new ParticleBlueprintBuilder()
|
||||||
|
// .name(Name.of("middle", "names"))
|
||||||
|
// .description("Middle names of a user")
|
||||||
|
// .type("string")
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// .addLink(new LinkBlueprintBuilder()
|
||||||
|
// .from(Name.of("account"))
|
||||||
|
// .to(Name.of("account", "details"))
|
||||||
|
// .type(LinkType.ONE_TO_ONE)
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// UniverseBlueprint build = builder.build();
|
||||||
|
//
|
||||||
|
// Traqtor traqtor = Traqtor.init();
|
||||||
|
// CommandExecResult result = traqtor.execute(new API.CreateWorkspace());
|
||||||
|
// assertEquals(result.getStatus(), DONE);
|
||||||
|
// assertEquals(traqtor.workspace().dirty(), true);
|
||||||
|
// String serialized = traqtor.workspace().mapper().writeValueAsString(build);
|
||||||
|
// System.out.println(serialized);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
@ -1,3 +1,5 @@
|
|||||||
|
package link.pagan.z_old;
|
||||||
|
|
||||||
// package link.pagan.traqtor.api.workspace;
|
// package link.pagan.traqtor.api.workspace;
|
||||||
|
|
||||||
// import java.io.IOException;
|
// import java.io.IOException;
|
||||||
Loading…
Reference in New Issue