Maven family has arrived at the party
parent
57d759dd21
commit
38951ae138
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>TraQtor</name>
|
||||
|
||||
<modules>
|
||||
<module>traqtor-framework</module>
|
||||
<module>traqtor-generator</module>
|
||||
<module>traqtor-schema</module>
|
||||
<module>traqtor-schema-ref</module>
|
||||
<module>traqtor-api</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.2</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor-api</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TraQtor / API </name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit-bom</artifactId>
|
||||
<version>5.7.1</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>traqtor-schema-basic</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>traqtor-generator</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>traqtor-framework</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.12.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@ -0,0 +1,45 @@
|
||||
package link.pagan.traqtor._api;
|
||||
|
||||
import link.pagan.traqtor._api.result.CommandExecResult;
|
||||
import link.pagan.traqtor._api.result.message.CommandExecMessage;
|
||||
import link.pagan.traqtor._api.result.message.CommandExecMessageStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public abstract class Command<T> {
|
||||
|
||||
protected CommandExecResult result;
|
||||
|
||||
public abstract CommandExecResult exec(T object);
|
||||
|
||||
protected CommandExecResult fail(String message) {
|
||||
result.add(new CommandExecMessage(CommandExecMessageStatus.FAIL, message));
|
||||
return result;
|
||||
}
|
||||
|
||||
protected CommandExecResult info(String message) {
|
||||
result.add(new CommandExecMessage(CommandExecMessageStatus.INFO, message));
|
||||
return result;
|
||||
}
|
||||
|
||||
protected CommandExecResult warn(String message) {
|
||||
result.add(new CommandExecMessage(CommandExecMessageStatus.WARN, message));
|
||||
return result;
|
||||
}
|
||||
|
||||
protected CommandExecResult done(String message) {
|
||||
result.add(new CommandExecMessage(CommandExecMessageStatus.DONE, message));
|
||||
return result;
|
||||
}
|
||||
|
||||
protected CommandExecResult done() {
|
||||
result.add(new CommandExecMessage(CommandExecMessageStatus.DONE, "OK"));
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResultHolder(CommandExecResult result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package link.pagan.traqtor._api;
|
||||
|
||||
import link.pagan.traqtor._api.result.CommandExecResult;
|
||||
import link.pagan.traqtor._api.result.CommandExecResultStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public abstract class Executor<T> {
|
||||
|
||||
private static boolean paranoindLoggin = false;
|
||||
|
||||
public CommandExecResult execute(Command<Executor<T>> command) {
|
||||
CommandExecResult result = new CommandExecResult();
|
||||
command.setResultHolder(result);
|
||||
command.exec(this);
|
||||
if (paranoindLoggin) {
|
||||
result.print();
|
||||
} else {
|
||||
if (result.getStatus() != CommandExecResultStatus.DONE) {
|
||||
result.print();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void enableParanoindLoggin() {
|
||||
paranoindLoggin = true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package link.pagan.traqtor._api.result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import link.pagan.traqtor._api.result.message.CommandExecMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class CommandExecResult {
|
||||
|
||||
final ArrayList<CommandExecMessage> messages;
|
||||
|
||||
public CommandExecResult() {
|
||||
this.messages = new ArrayList<CommandExecMessage>();
|
||||
}
|
||||
|
||||
public void add(CommandExecMessage message) {
|
||||
this.messages.add(message);
|
||||
}
|
||||
|
||||
public boolean OK () {
|
||||
return this.getStatus() == CommandExecResultStatus.DONE;
|
||||
}
|
||||
|
||||
public CommandExecResultStatus getStatus() {
|
||||
int status = 100;
|
||||
for (CommandExecMessage message : messages) {
|
||||
if (status > message.getStatus().getCode()) {
|
||||
status = message.getStatus().getCode();
|
||||
}
|
||||
}
|
||||
return CommandExecResultStatus.ofCode(status);
|
||||
}
|
||||
|
||||
public void print() {
|
||||
for (CommandExecMessage message : messages) {
|
||||
message.print();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package link.pagan.traqtor._api.result;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public enum CommandExecResultStatus {
|
||||
DONE(0),
|
||||
WARN(-1),
|
||||
FAIL(-2);
|
||||
|
||||
int code;
|
||||
|
||||
private CommandExecResultStatus(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static CommandExecResultStatus ofCode (int code) {
|
||||
if (code < -1) return FAIL;
|
||||
if (code == -1) return WARN;
|
||||
return DONE;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package link.pagan.traqtor._api.result.message;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class CommandExecMessage {
|
||||
|
||||
final CommandExecMessageStatus status;
|
||||
final String message;
|
||||
|
||||
public CommandExecMessage(CommandExecMessageStatus status, String message) {
|
||||
this.status = status;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public CommandExecMessageStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void print() {
|
||||
// if (status.getCode() < 0) {
|
||||
System.out.println(status.toString() + " : " + message);
|
||||
// } else {
|
||||
// System.out.println(status.toString() + " : " + message);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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._api.result.message;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public enum CommandExecMessageStatus {
|
||||
INFO(1),
|
||||
DONE(0),
|
||||
WARN(-1),
|
||||
FAIL(-2);
|
||||
|
||||
int code;
|
||||
|
||||
private CommandExecMessageStatus(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,155 @@
|
||||
package link.pagan.traqtor.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import link.pagan.traqtor._api.Command;
|
||||
import link.pagan.traqtor._api.Executor;
|
||||
import link.pagan.traqtor._api.result.CommandExecResult;
|
||||
import link.pagan.traqtor.api.workspace.Workspace;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class Traqtor extends Executor {
|
||||
|
||||
private static Traqtor env = new Traqtor();
|
||||
|
||||
public static CommandExecResult exec(Command<Traqtor> command) {
|
||||
return env.execute(command);
|
||||
}
|
||||
|
||||
static void reset() {
|
||||
env = new Traqtor();
|
||||
}
|
||||
|
||||
Workspace workspace;
|
||||
|
||||
public static Workspace getWorkspace() {
|
||||
return env.workspace;
|
||||
}
|
||||
|
||||
|
||||
public static class CreateWorkspace extends Command<Traqtor> {
|
||||
|
||||
private final String name;
|
||||
private final String path;
|
||||
|
||||
public CreateWorkspace() {
|
||||
this(Workspace.DEFAULT_WORKSPACE_NAME);
|
||||
}
|
||||
|
||||
public CreateWorkspace(String name) {
|
||||
this(name, null);
|
||||
}
|
||||
|
||||
public CreateWorkspace(String name, String path) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandExecResult exec(Traqtor traqtor) {
|
||||
if (traqtor.workspace != null) {
|
||||
return fail("There is an open workspace - please close this first, before creating new one");
|
||||
}
|
||||
traqtor.workspace = new Workspace();
|
||||
traqtor.workspace.setName(name);
|
||||
if (path != null) {
|
||||
SaveAsWorkspace saveAsWorkspace = new SaveAsWorkspace(path);
|
||||
saveAsWorkspace.setResultHolder(result);
|
||||
saveAsWorkspace.exec(traqtor);
|
||||
if (!result.OK()) {
|
||||
traqtor.workspace = null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return done();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SaveAsWorkspace extends Command<Traqtor> {
|
||||
|
||||
private String workspacePath;
|
||||
|
||||
public SaveAsWorkspace(String workspacePath) {
|
||||
this.workspacePath = workspacePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandExecResult exec(Traqtor traqtor) {
|
||||
File workspaceDir = new File(workspacePath);
|
||||
if (!workspaceDir.exists()) {
|
||||
if (!workspaceDir.mkdir()) {
|
||||
return fail("Failed to create workspace root directory at " + workspacePath);
|
||||
} else {
|
||||
info("Workspace root directory created at " + workspacePath);
|
||||
}
|
||||
} else {
|
||||
if (workspaceDir.listFiles().length > 0) {
|
||||
return fail("Root directory is not empty, failed to assing " + workspacePath + " as root for workspace");
|
||||
}
|
||||
}
|
||||
File workspaceFile = new File(workspacePath, Workspace.JSON_FILENAME + ".json");
|
||||
if (!workspaceFile.exists()) {
|
||||
try {
|
||||
if (!workspaceFile.createNewFile()){
|
||||
return fail("Failed to create " + Workspace.JSON_FILENAME + ".json in workspace root directory");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
return fail("IO erorr while creating " + Workspace.JSON_FILENAME + ".json in workspace root directory");
|
||||
}
|
||||
}
|
||||
|
||||
String hold = traqtor.workspace.getRoot();
|
||||
traqtor.workspace.setRoot(workspacePath);
|
||||
|
||||
SaveWorkspace saveWorkspace = new SaveWorkspace();
|
||||
saveWorkspace.setResultHolder(result);
|
||||
saveWorkspace.exec(traqtor);
|
||||
if (!result.OK()) {
|
||||
traqtor.workspace.setRoot(hold);
|
||||
return result;
|
||||
}
|
||||
|
||||
return done();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SaveWorkspace extends Command<Traqtor> {
|
||||
|
||||
@Override
|
||||
public CommandExecResult exec(Traqtor traqtor) {
|
||||
String workspacePath = traqtor.workspace.getRoot();
|
||||
if (traqtor.workspace.getRoot() == null) {
|
||||
return fail("Workspace was not saved before - use \"save as\" command for the first save");
|
||||
}
|
||||
File workspaceFile = new File(workspacePath, Workspace.JSON_FILENAME + ".json");
|
||||
|
||||
if (!workspaceFile.exists()) {
|
||||
return fail("Failed to save, " + Workspace.JSON_FILENAME + ".json does not exist, workspace corrupted?");
|
||||
}
|
||||
|
||||
if (!workspaceFile.canWrite()) {
|
||||
return fail("Can not write " + Workspace.JSON_FILENAME + ".json - permission denied");
|
||||
}
|
||||
|
||||
try {
|
||||
traqtor.workspace.getMapper().writeValue(workspaceFile, traqtor.workspace);
|
||||
} catch (IOException ex) {
|
||||
return fail("Failed to write " + Workspace.JSON_FILENAME + ".json");
|
||||
}
|
||||
|
||||
traqtor.workspace.setDirty(false);
|
||||
|
||||
return done();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package link.pagan.traqtor.api.project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import link.pagan.traqtor.generator.blueprint.database.DatabaseBlueprint;
|
||||
import link.pagan.traqtor.schema.basic.EndpointSchemaImpl;
|
||||
import link.pagan.traqtor.schema.basic.data.DataTypeSchemaImpl;
|
||||
import link.pagan.traqtor.schema.data.DataTypeSchema;
|
||||
import link.pagan.traqtor.schema.logic.EndpointSchema;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class Project {
|
||||
|
||||
private EndpointSchema endpointSchema;
|
||||
private DataTypeSchema dataTypeSchema;
|
||||
|
||||
private List<DatabaseBlueprint> dataBases;
|
||||
|
||||
static Project init() {
|
||||
return new Project(new EndpointSchemaImpl(), new DataTypeSchemaImpl());
|
||||
}
|
||||
|
||||
public Project(EndpointSchema endpointSchema, DataTypeSchema dataTypeSchema) {
|
||||
this.endpointSchema = endpointSchema;
|
||||
this.dataTypeSchema = dataTypeSchema;
|
||||
this.dataBases = new ArrayList<DatabaseBlueprint>();
|
||||
}
|
||||
|
||||
void addDataBaseBlueprint(DatabaseBlueprint dataBaseBlueprint) {
|
||||
this.dataBases.add(dataBaseBlueprint);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package link.pagan.traqtor.api.workspace;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import link.pagan.traqtor._api.Executor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class Workspace extends Executor {
|
||||
|
||||
public static final String JSON_FILENAME = "workspace";
|
||||
public static final String DEFAULT_WORKSPACE_NAME = "I'm too lazy to think of a name for this workspace";
|
||||
|
||||
private String name;
|
||||
|
||||
@JsonIgnore
|
||||
private boolean dirty;
|
||||
|
||||
@JsonIgnore
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@JsonIgnore
|
||||
private String root;
|
||||
|
||||
public Workspace() {
|
||||
this.mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
public void setRoot(String root) {
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ObjectMapper getMapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
public void setDirty(boolean dirty) {
|
||||
this.dirty = dirty;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package link.pagan.traqtor.api.workspace.command;
|
||||
|
||||
//package link.pagan.traqtor.api.workbench.command;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.IOException;
|
||||
//import link.pagan.traqtor._api.Command;
|
||||
//import link.pagan.traqtor._api.result.CommandExecResult;
|
||||
//import link.pagan.traqtor.api.workbench.Workbench;
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
// */
|
||||
//public class WorkbenchCommandSave extends Command<Workbench> {
|
||||
//
|
||||
// @Override
|
||||
// public CommandExecResult exec(Workbench workbench) {
|
||||
// if (workbench.getRoot() == null) {
|
||||
// return fail("Workspace was not saved before - use \"save as\" command for the first save");
|
||||
// }
|
||||
// File demoDir = new File(workbench.getRoot());
|
||||
// File workbenchFile = new File(demoDir, Workbench.JSON_FILENAME + ".json");
|
||||
// if (!workbenchFile.exists()) {
|
||||
// return fail("Workspace lock file (" + (workbenchFile.getAbsolutePath()) + ") does not exit ");
|
||||
// }
|
||||
// try {
|
||||
// workbench.getMapper().writeValue(workbenchFile, workbench);
|
||||
// } catch (IOException ex) {
|
||||
// return fail("Failed to write" + Workbench.JSON_FILENAME + ".json");
|
||||
// }
|
||||
// return done();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@ -0,0 +1,47 @@
|
||||
package link.pagan.traqtor.api.workspace.command;
|
||||
|
||||
//package link.pagan.traqtor.api.workbench.command;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.IOException;
|
||||
//import link.pagan.traqtor._api.Command;
|
||||
//import link.pagan.traqtor._api.result.CommandExecResult;
|
||||
//import link.pagan.traqtor.api.workbench.Workbench;
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
// */
|
||||
//public class WorkbenchCommandSaveAs extends Command<Workbench> {
|
||||
//
|
||||
// String path;
|
||||
//
|
||||
// public WorkbenchCommandSaveAs(String path) {
|
||||
// this.path = path;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public CommandExecResult exec(Workbench workbench) {
|
||||
// File demoDir = new File(path);
|
||||
// if (!demoDir.exists()) {
|
||||
// if (!demoDir.mkdir()) {
|
||||
// return fail("Failed to create workbench root directory at " + path);
|
||||
// } else {
|
||||
// info("Create workbench root directory at " + path);
|
||||
// }
|
||||
// } else {
|
||||
// if (demoDir.listFiles().length > 0) {
|
||||
// return fail("Root directory is not empty, failed to assing " + path + " as root for workspace");
|
||||
// }
|
||||
// }
|
||||
// File workbenchFile = new File(demoDir, Workbench.JSON_FILENAME + ".json");
|
||||
// try {
|
||||
// workbench.getMapper().writeValue(workbenchFile, workbench);
|
||||
// } catch (IOException ex) {
|
||||
// return fail("Failed to write " + Workbench.JSON_FILENAME + ".json");
|
||||
// }
|
||||
// workbench.setRoot(path);
|
||||
// return done();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@ -0,0 +1,28 @@
|
||||
package link.pagan.traqtor._api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class TraqtorApiTestUtils {
|
||||
|
||||
public static final String TEST_WORKSPACE_ROOT = new File(new File("").getAbsoluteFile().getParentFile(), "traqtor-demo-workspace").getAbsolutePath();
|
||||
public static final String TEST_WORKSPACE_NAME = "TRAQTOR_DEMO_WORKSPACE";
|
||||
|
||||
public static final void killTestRoot() throws IOException {
|
||||
File root = new File(TEST_WORKSPACE_ROOT);
|
||||
if (root.exists()) {
|
||||
Files.walk(new File(TEST_WORKSPACE_ROOT).toPath())
|
||||
.sorted(Comparator.reverseOrder())
|
||||
.map(Path::toFile)
|
||||
.forEach(File::delete);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package link.pagan.traqtor.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import link.pagan.traqtor._api.Executor;
|
||||
import link.pagan.traqtor._api.TraqtorApiTestUtils;
|
||||
import link.pagan.traqtor._api.result.CommandExecResult;
|
||||
import static link.pagan.traqtor._api.result.CommandExecResultStatus.DONE;
|
||||
import static link.pagan.traqtor._api.result.CommandExecResultStatus.FAIL;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class TraqtorTest {
|
||||
|
||||
CommandExecResult result;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
Executor.enableParanoindLoggin();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void cleanTestDir() throws IOException {
|
||||
TraqtorApiTestUtils.killTestRoot();
|
||||
}
|
||||
|
||||
|
||||
@AfterEach
|
||||
public void killCore() {
|
||||
Traqtor.reset();
|
||||
System.out.println("TEST_WORKSPACE_ROOT = " + TraqtorApiTestUtils.TEST_WORKSPACE_ROOT);
|
||||
}
|
||||
|
||||
@Test
|
||||
void newWorkspace() {
|
||||
result = Traqtor.exec(new Traqtor.CreateWorkspace());
|
||||
assertEquals(result.getStatus(), DONE);
|
||||
assertEquals(Traqtor.getWorkspace().isDirty(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void newWorkspaceSave() {
|
||||
result = Traqtor.exec(new Traqtor.CreateWorkspace());
|
||||
assertEquals(DONE, result.getStatus());
|
||||
assertEquals(Traqtor.getWorkspace().isDirty(), true);
|
||||
result = Traqtor.exec(new Traqtor.SaveWorkspace());
|
||||
assertEquals(FAIL, result.getStatus());
|
||||
assertEquals(Traqtor.getWorkspace().isDirty(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void newWorkspaceWithName() {
|
||||
result = Traqtor.exec(new Traqtor.CreateWorkspace(TraqtorApiTestUtils.TEST_WORKSPACE_NAME));
|
||||
assertEquals(DONE, result.getStatus());
|
||||
assertEquals(Traqtor.getWorkspace().isDirty(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void newWorkspaceWithNameAndPath() {
|
||||
result = Traqtor.exec(new Traqtor.CreateWorkspace(TraqtorApiTestUtils.TEST_WORKSPACE_NAME, TraqtorApiTestUtils.TEST_WORKSPACE_ROOT));
|
||||
assertEquals(DONE, result.getStatus());
|
||||
assertEquals(Traqtor.getWorkspace().isDirty(), false);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package link.pagan.traqtor.api.workspace;
|
||||
|
||||
//package link.pagan.traqtor.api.workbench;
|
||||
//
|
||||
//import link.pagan.traqtor.api.workbench.command.WorkbenchCommandSaveAs;
|
||||
//import link.pagan.traqtor.api.workbench.command.WorkbenchCommandSave;
|
||||
//import java.io.IOException;
|
||||
//import link.pagan.traqtor._api.PrimedTest;
|
||||
//import link.pagan.traqtor._api.Executor;
|
||||
//import link.pagan.traqtor._api.result.CommandExecResult;
|
||||
//import static link.pagan.traqtor._api.result.CommandExecResultStatus.DONE;
|
||||
//import static link.pagan.traqtor._api.result.CommandExecResultStatus.FAIL;
|
||||
//import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
//import org.junit.jupiter.api.BeforeAll;
|
||||
//import org.junit.jupiter.api.BeforeEach;
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
// */
|
||||
//public class WorkbenchTest {
|
||||
//
|
||||
// @BeforeAll
|
||||
// public static void setup() throws IOException {
|
||||
// Executor.enableParanoindLoggin();
|
||||
// }
|
||||
//
|
||||
// @BeforeEach
|
||||
// public void clean() throws IOException {
|
||||
// killTestRoot();
|
||||
// }
|
||||
//
|
||||
//// @Test
|
||||
//// void initSave() {
|
||||
//// CommandExecResult result = Workbench.init().exec(new WorkbenchCommandSave());
|
||||
//// assertEquals(FAIL, result.getStatus());
|
||||
//// }
|
||||
////
|
||||
//// @Test
|
||||
//// void initSaveAs() {
|
||||
//// CommandExecResult result = Workbench.init().exec(new WorkbenchCommandSaveAs(TEST_ROOT));
|
||||
//// assertEquals(DONE, result.getStatus());
|
||||
//// }
|
||||
////
|
||||
//// @Test
|
||||
//// void initSaveAsSave() {
|
||||
//// Workbench workbench = Workbench.init();
|
||||
//// CommandExecResult result = workbench.exec(new WorkbenchCommandSaveAs(TEST_ROOT));
|
||||
//// assertEquals(DONE, result.getStatus());
|
||||
//// result = workbench.exec(new WorkbenchCommandSave());
|
||||
//// assertEquals(DONE, result.getStatus());
|
||||
//// }
|
||||
//
|
||||
//}
|
||||
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor-framework</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TraQtor / Framework </name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>6.2.0.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>jakarta.el</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cayenne</groupId>
|
||||
<artifactId>cayenne-server</artifactId>
|
||||
<version>4.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -0,0 +1,13 @@
|
||||
package link.pagan.traqtor.framework.data;
|
||||
|
||||
import org.apache.cayenne.BaseDataObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class DatabaseDataObject extends BaseDataObject {
|
||||
|
||||
private static final long serialVersionUID = 1448137394405559485L;
|
||||
|
||||
}
|
||||
@ -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.framework.logic;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class Registry {
|
||||
|
||||
}
|
||||
@ -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.framework.logic;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class Resource {
|
||||
|
||||
}
|
||||
@ -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.framework.logic;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class Service {
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor-generator</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TraQtor / Source generator </name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>traqtor-schema</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
</project>
|
||||
@ -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.generator.blueprint;
|
||||
|
||||
import link.pagan.traqtor.generator.blueprint.util.Name;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class ProjectBlueprint {
|
||||
|
||||
String name;
|
||||
Name rootPackage;
|
||||
String description;
|
||||
|
||||
|
||||
public void assemble() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package link.pagan.traqtor.generator.blueprint;
|
||||
|
||||
import link.pagan.traqtor.generator.blueprint.database.builder.ColumnBlueprintBuilder;
|
||||
import link.pagan.traqtor.generator.blueprint.database.builder.DatabaseBlueprintBuilder;
|
||||
import link.pagan.traqtor.generator.blueprint.database.builder.SchemeBlueprintBuilder;
|
||||
import link.pagan.traqtor.generator.blueprint.database.builder.TableBlueprintBuilder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class R {
|
||||
|
||||
public static DatabaseBlueprintBuilder database() {
|
||||
return new DatabaseBlueprintBuilder();
|
||||
}
|
||||
|
||||
public static SchemeBlueprintBuilder schema() {
|
||||
return new SchemeBlueprintBuilder();
|
||||
}
|
||||
|
||||
public static TableBlueprintBuilder table() {
|
||||
return new TableBlueprintBuilder();
|
||||
}
|
||||
|
||||
public static ColumnBlueprintBuilder column() {
|
||||
return new ColumnBlueprintBuilder();
|
||||
}
|
||||
|
||||
}
|
||||
@ -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.generator.blueprint.backend;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class BackendBlueprint {
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.generator.blueprint.database;
|
||||
|
||||
import link.pagan.traqtor.generator.blueprint.util.Name;
|
||||
import link.pagan.traqtor.schema.data.DataType;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class ColumnBlueprint {
|
||||
|
||||
Name name;
|
||||
DataType dataType;
|
||||
|
||||
public ColumnBlueprint(Name name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package link.pagan.traqtor.generator.blueprint.database;
|
||||
|
||||
import java.util.List;
|
||||
import link.pagan.traqtor.schema.data.mapping.database.DatabaseAdapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class DatabaseBlueprint {
|
||||
|
||||
String name;
|
||||
private List<SchemeBlueprint> schemas;
|
||||
private DatabaseAdapter databaseAdapter;
|
||||
|
||||
public DatabaseBlueprint(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.generator.blueprint.database;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class SchemeBlueprint {
|
||||
|
||||
String name;
|
||||
ArrayList<TableBlueprint> tables;
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.generator.blueprint.database;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class TableBlueprint {
|
||||
|
||||
String name;
|
||||
ArrayList<ColumnBlueprint> columns;
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package link.pagan.traqtor.generator.blueprint.database.builder;
|
||||
|
||||
import link.pagan.traqtor.generator.blueprint.database.ColumnBlueprint;
|
||||
import link.pagan.traqtor.generator.blueprint.util.Name;
|
||||
import link.pagan.traqtor.schema.data.DataType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class ColumnBlueprintBuilder {
|
||||
|
||||
private Name name;
|
||||
private boolean pk;
|
||||
private DataType dataType;
|
||||
|
||||
public ColumnBlueprintBuilder() {
|
||||
this.pk = false;
|
||||
}
|
||||
|
||||
public boolean pk() {
|
||||
return this.pk;
|
||||
}
|
||||
|
||||
public ColumnBlueprintBuilder pk(boolean pk) {
|
||||
this.pk = pk;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ColumnBlueprintBuilder name(Name name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Name name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public DataType dataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public ColumnBlueprintBuilder dataType(DataType dataType) {
|
||||
this.dataType = dataType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ColumnBlueprint build() {
|
||||
return new ColumnBlueprint(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package link.pagan.traqtor.generator.blueprint.database.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import link.pagan.traqtor.generator.blueprint.util.Name;
|
||||
import link.pagan.traqtor.schema.data.mapping.database.DatabaseAdapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class DatabaseBlueprintBuilder {
|
||||
|
||||
private Name name;
|
||||
private DatabaseAdapter adapter;
|
||||
private final List<SchemeBlueprintBuilder> schemas;
|
||||
|
||||
public DatabaseBlueprintBuilder() {
|
||||
this.schemas = new ArrayList<SchemeBlueprintBuilder>();
|
||||
}
|
||||
|
||||
public Name name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public DatabaseBlueprintBuilder name(Name name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatabaseAdapter adapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
public DatabaseBlueprintBuilder adapter(DatabaseAdapter adapter) {
|
||||
this.adapter = adapter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatabaseBlueprintBuilder schemas(SchemeBlueprintBuilder... schemas) {
|
||||
if (schemas != null) {
|
||||
Collections.addAll(this.schemas, schemas);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemeBlueprintBuilder scheme(Name name) {
|
||||
for (SchemeBlueprintBuilder sbb : schemas) {
|
||||
if (sbb.name().equals(name)) {
|
||||
return sbb;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package link.pagan.traqtor.generator.blueprint.database.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import link.pagan.traqtor.generator.blueprint.util.Name;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class SchemeBlueprintBuilder {
|
||||
|
||||
private Name name;
|
||||
private final List<TableBlueprintBuilder> tables;
|
||||
|
||||
public SchemeBlueprintBuilder() {
|
||||
this.tables = new ArrayList<TableBlueprintBuilder>();
|
||||
}
|
||||
|
||||
public Name name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SchemeBlueprintBuilder name(Name name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SchemeBlueprintBuilder tables(TableBlueprintBuilder... tables) {
|
||||
if (tables != null) {
|
||||
Collections.addAll(this.tables, tables);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableBlueprintBuilder table(String name) {
|
||||
for (TableBlueprintBuilder tbb : tables) {
|
||||
if (tbb.name().equals(name)) {
|
||||
return tbb;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package link.pagan.traqtor.generator.blueprint.database.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import link.pagan.traqtor.generator.blueprint.util.Name;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class TableBlueprintBuilder {
|
||||
|
||||
private Name name;
|
||||
private final List<ColumnBlueprintBuilder> columns;
|
||||
|
||||
public TableBlueprintBuilder() {
|
||||
this.columns = new ArrayList<ColumnBlueprintBuilder>();
|
||||
}
|
||||
|
||||
public Name name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public TableBlueprintBuilder name(Name name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableBlueprintBuilder columns(ColumnBlueprintBuilder... columns) {
|
||||
if (columns != null) {
|
||||
Collections.addAll(this.columns, columns);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ColumnBlueprintBuilder column(String name) {
|
||||
for (ColumnBlueprintBuilder cbb : columns) {
|
||||
if (cbb.name().equals(name)) {
|
||||
return cbb;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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.generator.blueprint.frontend;
|
||||
|
||||
import link.pagan.traqtor.generator.blueprint.backend.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class FrontendBlueprint {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.generator.blueprint.mdl.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import link.pagan.traqtor.generator.blueprint.mdl.security.permission.PermissionBlueprint;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class EndpointBlueprint {
|
||||
|
||||
ArrayList<PermissionBlueprint> permissions;
|
||||
String name;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.generator.blueprint.mdl.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class RegistryBlueprint {
|
||||
|
||||
ArrayList<EndpointBlueprint> endpoints;
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.generator.blueprint.mdl.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class ResourceBlueprint {
|
||||
|
||||
String name;
|
||||
ArrayList<EndpointBlueprint> endpoints;
|
||||
|
||||
}
|
||||
@ -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.generator.blueprint.mdl.logic;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class ServiceBlueprint {
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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.generator.blueprint.mdl.security.permission;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class PermissionBlueprint {
|
||||
|
||||
String name;
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.generator.blueprint.mdl.security.permission;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class PermissionDomainBlueprint {
|
||||
|
||||
String name;
|
||||
ArrayList<PermissionBlueprint> permissions;
|
||||
ArrayList<PermissionDomainBlueprint> subdomains;
|
||||
|
||||
}
|
||||
@ -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.generator.blueprint.mdl.security.role;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class RoleBlueprint {
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.generator.blueprint.util;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class Name {
|
||||
|
||||
String [] parts;
|
||||
|
||||
public Name(String[] parts) {
|
||||
this.parts = parts;
|
||||
}
|
||||
|
||||
public static Name of (String... parts) {
|
||||
if (parts == null) {
|
||||
throw new NullPointerException("name can not be null");
|
||||
}
|
||||
if (parts.length < 1) {
|
||||
throw new IllegalArgumentException("name can not be empty");
|
||||
}
|
||||
return new Name(parts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor-schema-ref</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TraQtor / Scheme / Reference implementation</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>traqtor-schema</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -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.schema.basic;
|
||||
|
||||
import java.util.List;
|
||||
import link.pagan.traqtor.schema.logic.EndpointSchema;
|
||||
import link.pagan.traqtor.schema.logic.EndpointTemplate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class EndpointSchemaImpl implements EndpointSchema {
|
||||
|
||||
@Override
|
||||
public List<EndpointTemplate> getPatterns() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package link.pagan.traqtor.schema.basic.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import link.pagan.traqtor.schema.basic.data.mapping.MappingSchemaImpl;
|
||||
import link.pagan.traqtor.schema.data.DataType;
|
||||
import link.pagan.traqtor.schema.data.DataTypeSchema;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingSchema;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class DataTypeSchemaImpl implements DataTypeSchema {
|
||||
|
||||
// ARRAY(""),
|
||||
// LIST(""),
|
||||
// SET(""),
|
||||
// MAP(""),
|
||||
public static final DataType BOOLEAN = new DataType("boolean");
|
||||
public static final DataType BYTE = new DataType("byte");
|
||||
public static final DataType SHORT = new DataType("short");
|
||||
public static final DataType INTEGER = new DataType("int");
|
||||
public static final DataType LONG = new DataType("long");
|
||||
public static final DataType FLOAT = new DataType("float");
|
||||
public static final DataType DOUBLE = new DataType("double");
|
||||
public static final DataType STRING = new DataType("string");
|
||||
public static final DataType DATE = new DataType("date");
|
||||
public static final DataType TIME = new DataType("time");
|
||||
public static final DataType TIMESTAMP = new DataType("timestamp");
|
||||
public static final DataType ID = new DataType("id");
|
||||
public static final DataType UUID = new DataType("uuid");
|
||||
|
||||
private static final List<DataType> dataTypes = List.of(BOOLEAN, BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE, STRING,
|
||||
DATE, TIME, TIMESTAMP, ID, UUID);
|
||||
|
||||
private static final List<MappingSchema> mappingSchemas = List.of(new MappingSchemaImpl());
|
||||
|
||||
@Override
|
||||
public List<DataType> getDataTypes() {
|
||||
return dataTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "basic";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MappingSchema> getMappingSchema() {
|
||||
return mappingSchemas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, DataType> register() {
|
||||
return new HashMap<String, DataType>(){{
|
||||
put(BOOLEAN.getName(), BOOLEAN);
|
||||
put(BYTE.getName(), BYTE);
|
||||
put(SHORT.getName(), SHORT);
|
||||
put(INTEGER.getName(), INTEGER);
|
||||
put(LONG.getName(), LONG);
|
||||
put(FLOAT.getName(), FLOAT);
|
||||
put(DOUBLE.getName(), DOUBLE);
|
||||
put(STRING.getName(), STRING);
|
||||
put(BOOLEAN.getName(), BOOLEAN);
|
||||
put(DATE.getName(), DATE);
|
||||
put(TIME.getName(), TIME);
|
||||
put(TIMESTAMP.getName(), TIMESTAMP);
|
||||
put(ID.getName(), ID);
|
||||
put(UUID.getName(), UUID);
|
||||
}};
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package link.pagan.traqtor.schema.basic.data.mapping;
|
||||
|
||||
import java.util.List;
|
||||
import link.pagan.traqtor.schema.basic.data.DataTypeSchemaImpl;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingSchema;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class MappingSchemaImpl implements MappingSchema {
|
||||
|
||||
public static final MappingEntry NULLABLE_BOOLEAN = new MappingEntry(DataTypeSchemaImpl.BOOLEAN , true , false );
|
||||
public static final MappingEntry BOOLEAN = new MappingEntry(DataTypeSchemaImpl.BOOLEAN , false , true );
|
||||
public static final MappingEntry NULLABLE_BYTE = new MappingEntry(DataTypeSchemaImpl.BYTE , true , false );
|
||||
public static final MappingEntry BYTE = new MappingEntry(DataTypeSchemaImpl.BYTE , false , true );
|
||||
public static final MappingEntry NULLABLE_SHORT = new MappingEntry(DataTypeSchemaImpl.SHORT , true , false );
|
||||
public static final MappingEntry SHORT = new MappingEntry(DataTypeSchemaImpl.SHORT , false , true );
|
||||
public static final MappingEntry NULLABLE_INTEGER = new MappingEntry(DataTypeSchemaImpl.INTEGER , true , false );
|
||||
public static final MappingEntry INTEGER = new MappingEntry(DataTypeSchemaImpl.INTEGER , false , true );
|
||||
public static final MappingEntry NULLABLE_LONG = new MappingEntry(DataTypeSchemaImpl.LONG , true , false );
|
||||
public static final MappingEntry LONG = new MappingEntry(DataTypeSchemaImpl.LONG , false , true );
|
||||
public static final MappingEntry NULLABLE_FLOAT = new MappingEntry(DataTypeSchemaImpl.FLOAT , true , false );
|
||||
public static final MappingEntry FLOAT = new MappingEntry(DataTypeSchemaImpl.FLOAT , false , false );
|
||||
public static final MappingEntry NULLABLE_DOUBLE = new MappingEntry(DataTypeSchemaImpl.DOUBLE , true , false );
|
||||
public static final MappingEntry DOUBLE = new MappingEntry(DataTypeSchemaImpl.DOUBLE , false , false );
|
||||
public static final MappingEntry STRING = new MappingEntry(DataTypeSchemaImpl.STRING , true , false );
|
||||
public static final MappingEntry DATE = new MappingEntry(DataTypeSchemaImpl.DATE , true , false );
|
||||
public static final MappingEntry TIME = new MappingEntry(DataTypeSchemaImpl.TIME , true , false );
|
||||
public static final MappingEntry TIMESTAMP = new MappingEntry(DataTypeSchemaImpl.TIMESTAMP , true , false );
|
||||
public static final MappingEntry ID = new MappingEntry(DataTypeSchemaImpl.ID , true , true );
|
||||
public static final MappingEntry UUID = new MappingEntry(DataTypeSchemaImpl.UUID , true , true );
|
||||
|
||||
private static final List<MappingEntry> mappings = List.of(NULLABLE_BOOLEAN, BOOLEAN,
|
||||
NULLABLE_BYTE, BYTE,
|
||||
NULLABLE_SHORT, SHORT,
|
||||
NULLABLE_INTEGER, INTEGER,
|
||||
NULLABLE_LONG, LONG,
|
||||
NULLABLE_FLOAT, FLOAT,
|
||||
NULLABLE_DOUBLE, DOUBLE,
|
||||
STRING,
|
||||
DATE, TIME, TIMESTAMP,
|
||||
ID, UUID);
|
||||
|
||||
@Override
|
||||
public List<MappingEntry> getMappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "basic";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package link.pagan.traqtor.schema.basic.data.mapping.backend;
|
||||
|
||||
import java.util.HashMap;
|
||||
import link.pagan.traqtor.schema.basic.data.mapping.MappingSchemaImpl;
|
||||
import link.pagan.traqtor.schema.data.mapping.backend.BackendMapping;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class JavaBackendMapping extends BackendMapping {
|
||||
|
||||
public JavaBackendMapping() {
|
||||
super("Java", new HashMap<MappingEntry, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put(MappingSchemaImpl.NULLABLE_BOOLEAN, "Boolean");
|
||||
put(MappingSchemaImpl.NULLABLE_BYTE, "Byte");
|
||||
put(MappingSchemaImpl.NULLABLE_SHORT, "Short");
|
||||
put(MappingSchemaImpl.NULLABLE_INTEGER, "Integer");
|
||||
put(MappingSchemaImpl.NULLABLE_LONG, "Long");
|
||||
|
||||
put(MappingSchemaImpl.BOOLEAN, "boolean");
|
||||
put(MappingSchemaImpl.BYTE, "byte");
|
||||
put(MappingSchemaImpl.SHORT, "short");
|
||||
put(MappingSchemaImpl.INTEGER, "integer");
|
||||
put(MappingSchemaImpl.LONG, "long");
|
||||
|
||||
put(MappingSchemaImpl.NULLABLE_DOUBLE, "Double");
|
||||
put(MappingSchemaImpl.NULLABLE_FLOAT, "Float");
|
||||
|
||||
put(MappingSchemaImpl.DOUBLE, "double");
|
||||
put(MappingSchemaImpl.FLOAT, "float");
|
||||
|
||||
put(MappingSchemaImpl.ID, "long");
|
||||
put(MappingSchemaImpl.UUID, "String");
|
||||
|
||||
put(MappingSchemaImpl.STRING, "String");
|
||||
put(MappingSchemaImpl.DATE, "Date");
|
||||
put(MappingSchemaImpl.TIME, "Time");
|
||||
put(MappingSchemaImpl.TIMESTAMP, "Timestamp");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.schema.basic.data.mapping.database;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import link.pagan.traqtor.schema.data.mapping.database.DatabaseAdapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class PostgresDatabaseAdapter extends DatabaseAdapter {
|
||||
|
||||
private static final String NAME = "PostgreSQL";
|
||||
|
||||
public PostgresDatabaseAdapter() {
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, DatabaseAdapter> register() {
|
||||
return new HashMap<String, DatabaseAdapter>(){{
|
||||
put(NAME, new PostgresDatabaseAdapter());
|
||||
}};
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package link.pagan.traqtor.schema.basic.data.mapping.database;
|
||||
|
||||
import java.util.HashMap;
|
||||
import link.pagan.traqtor.schema.basic.data.mapping.MappingSchemaImpl;
|
||||
import link.pagan.traqtor.schema.data.mapping.database.DatabaseMapping;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class PostgresDatabaseMapping extends DatabaseMapping {
|
||||
|
||||
public PostgresDatabaseMapping() {
|
||||
super("PostgreSQL", new HashMap<MappingEntry, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put(MappingSchemaImpl.NULLABLE_BOOLEAN, "boolean");
|
||||
put(MappingSchemaImpl.NULLABLE_BYTE, "smallint");
|
||||
put(MappingSchemaImpl.NULLABLE_SHORT, "smallint");
|
||||
put(MappingSchemaImpl.NULLABLE_INTEGER, "integer");
|
||||
put(MappingSchemaImpl.NULLABLE_LONG, "bigint");
|
||||
|
||||
put(MappingSchemaImpl.BOOLEAN, "boolean");
|
||||
put(MappingSchemaImpl.BYTE, "smallint");
|
||||
put(MappingSchemaImpl.SHORT, "smallint");
|
||||
put(MappingSchemaImpl.INTEGER, "integer");
|
||||
put(MappingSchemaImpl.LONG, "bigint");
|
||||
|
||||
put(MappingSchemaImpl.NULLABLE_DOUBLE, "double precision");
|
||||
put(MappingSchemaImpl.NULLABLE_FLOAT, "real");
|
||||
|
||||
put(MappingSchemaImpl.DOUBLE, "double precision");
|
||||
put(MappingSchemaImpl.FLOAT, "real");
|
||||
|
||||
put(MappingSchemaImpl.ID, "bigserial");
|
||||
put(MappingSchemaImpl.UUID, "uuid");
|
||||
|
||||
put(MappingSchemaImpl.STRING, "String");
|
||||
put(MappingSchemaImpl.DATE, "date");
|
||||
put(MappingSchemaImpl.TIME, "time");
|
||||
put(MappingSchemaImpl.TIMESTAMP, "timestamp");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package link.pagan.traqtor.schema.basic.data.mapping.frontend;
|
||||
|
||||
import java.util.HashMap;
|
||||
import link.pagan.traqtor.schema.basic.data.mapping.MappingSchemaImpl;
|
||||
import link.pagan.traqtor.schema.data.mapping.frontend.FrontendMapping;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class JavaScriptFrontendMapping extends FrontendMapping {
|
||||
|
||||
public JavaScriptFrontendMapping() {
|
||||
super("JavaScript", new HashMap<MappingEntry, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put(MappingSchemaImpl.NULLABLE_BOOLEAN, "Boolean");
|
||||
put(MappingSchemaImpl.NULLABLE_BYTE, "Number");
|
||||
put(MappingSchemaImpl.NULLABLE_SHORT, "Number");
|
||||
put(MappingSchemaImpl.NULLABLE_INTEGER, "Number");
|
||||
put(MappingSchemaImpl.NULLABLE_LONG, "BigInt");
|
||||
|
||||
put(MappingSchemaImpl.BOOLEAN, "Boolean");
|
||||
put(MappingSchemaImpl.BYTE, "Number");
|
||||
put(MappingSchemaImpl.SHORT, "Number");
|
||||
put(MappingSchemaImpl.INTEGER, "Number");
|
||||
put(MappingSchemaImpl.LONG, "BigInt");
|
||||
|
||||
put(MappingSchemaImpl.NULLABLE_DOUBLE, "Number");
|
||||
put(MappingSchemaImpl.NULLABLE_FLOAT, "Number");
|
||||
|
||||
put(MappingSchemaImpl.DOUBLE, "Number");
|
||||
put(MappingSchemaImpl.FLOAT, "Number");
|
||||
|
||||
put(MappingSchemaImpl.ID, "BigInt");
|
||||
put(MappingSchemaImpl.UUID, "String");
|
||||
|
||||
put(MappingSchemaImpl.STRING, "String");
|
||||
put(MappingSchemaImpl.DATE, "Date");
|
||||
put(MappingSchemaImpl.TIME, "Date");
|
||||
put(MappingSchemaImpl.TIMESTAMP, "Date");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>link.pagan</groupId>
|
||||
<artifactId>traqtor-schema</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TraQtor / Scheme </name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
|
||||
|
||||
<!--<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.mgpu.mesh.loader</groupId>
|
||||
<artifactId>traqtor-mdl</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>6.2.0.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>jakarta.el</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cayenne</groupId>
|
||||
<artifactId>cayenne-server</artifactId>
|
||||
<version>4.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
</project>-->
|
||||
@ -0,0 +1,19 @@
|
||||
package link.pagan.traqtor.schema.data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class DataType {
|
||||
|
||||
private final String name;
|
||||
|
||||
public DataType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package link.pagan.traqtor.schema.data;
|
||||
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingSchema;
|
||||
import link.pagan.traqtor.util.Named;
|
||||
import java.util.List;
|
||||
import link.pagan.traqtor.util.Registrable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public interface DataTypeSchema extends Named, Registrable<DataType> {
|
||||
|
||||
public List<DataType> getDataTypes();
|
||||
public List<MappingSchema> getMappingSchema();
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package link.pagan.traqtor.schema.data.mapping;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public abstract class Mapping {
|
||||
|
||||
private final String name;
|
||||
private final HashMap<MappingEntry, String> mapping;
|
||||
|
||||
protected Mapping(String name, HashMap<MappingEntry, String> mapping) {
|
||||
this.mapping = mapping;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public HashMap<MappingEntry, String> getMapping() {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package link.pagan.traqtor.schema.data.mapping;
|
||||
|
||||
import link.pagan.traqtor.schema.data.DataType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class MappingEntry {
|
||||
|
||||
|
||||
|
||||
private final DataType dataType;
|
||||
private final boolean nullable;
|
||||
private final boolean keyable;
|
||||
|
||||
public MappingEntry(DataType dataType, boolean nullable, boolean keyable) {
|
||||
this.dataType = dataType;
|
||||
this.nullable = nullable;
|
||||
this.keyable = keyable;
|
||||
}
|
||||
|
||||
public DataType getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
return nullable;
|
||||
}
|
||||
|
||||
public boolean isKeyable() {
|
||||
return keyable;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.schema.data.mapping;
|
||||
|
||||
import link.pagan.traqtor.util.Named;
|
||||
import java.util.List;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public interface MappingSchema extends Named {
|
||||
|
||||
public List<MappingEntry> getMappings ();
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package link.pagan.traqtor.schema.data.mapping.backend;
|
||||
|
||||
import java.util.HashMap;
|
||||
import link.pagan.traqtor.schema.data.mapping.Mapping;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class BackendMapping extends Mapping {
|
||||
|
||||
public BackendMapping(String name, HashMap<MappingEntry, String> mapping) {
|
||||
super(name, mapping);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package link.pagan.traqtor.schema.data.mapping.database;
|
||||
|
||||
import link.pagan.traqtor.util.Named;
|
||||
import link.pagan.traqtor.util.Registrable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public abstract class DatabaseAdapter implements Named, Registrable<DatabaseAdapter> {
|
||||
|
||||
private final String name;
|
||||
|
||||
protected DatabaseAdapter(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package link.pagan.traqtor.schema.data.mapping.database;
|
||||
|
||||
import java.util.HashMap;
|
||||
import link.pagan.traqtor.schema.data.mapping.Mapping;
|
||||
import link.pagan.traqtor.schema.data.mapping.Mapping;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class DatabaseMapping extends Mapping {
|
||||
|
||||
public DatabaseMapping(String name, HashMap<MappingEntry, String> mapping) {
|
||||
super(name, mapping);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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.schema.data.mapping.database;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public interface DatabaseNamingScheme {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package link.pagan.traqtor.schema.data.mapping.frontend;
|
||||
|
||||
import java.util.HashMap;
|
||||
import link.pagan.traqtor.schema.data.mapping.Mapping;
|
||||
import link.pagan.traqtor.schema.data.mapping.Mapping;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
import link.pagan.traqtor.schema.data.mapping.MappingEntry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class FrontendMapping extends Mapping {
|
||||
|
||||
public FrontendMapping(String name, HashMap<MappingEntry, String> mapping) {
|
||||
super(name, mapping);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.schema.logic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public interface EndpointSchema {
|
||||
|
||||
public List<EndpointTemplate> getPatterns();
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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.schema.logic;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public class EndpointTemplate {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package link.pagan.traqtor.util;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public interface Named {
|
||||
|
||||
public String getName();
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import java.util.Map;
|
||||
import link.pagan.traqtor.schema.data.mapping.database.DatabaseAdapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||
*/
|
||||
public interface Registrable<T> {
|
||||
|
||||
public Map<String, T> register();
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue