forked from 2pm.tech/traqtor
Proceeding to project API
parent
7ae7d38b11
commit
84fb87ce56
@ -0,0 +1,24 @@
|
|||||||
|
package link.pagan.traqtor._api;
|
||||||
|
|
||||||
|
import link.pagan.traqtor._api.result.CommandExecResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public abstract class BinaryCommand<T extends Commanded, R extends Commanded> extends UnaryCommand<T> {
|
||||||
|
|
||||||
|
protected R arg2;
|
||||||
|
|
||||||
|
public CommandExecResult subexec(BinaryCommand<T, R> subcommand) {
|
||||||
|
subcommand.setResultHolder(result);
|
||||||
|
subcommand.setArg(arg);
|
||||||
|
subcommand.setArg2(arg2);
|
||||||
|
return subcommand.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArg2(R arg2) {
|
||||||
|
this.arg2 = arg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,40 +1,31 @@
|
|||||||
package link.pagan.traqtor._api;
|
//package link.pagan.traqtor._api;
|
||||||
|
//
|
||||||
import link.pagan.traqtor._api.result.CommandExecResult;
|
//import link.pagan.traqtor._api.result.CommandExecResult;
|
||||||
import link.pagan.traqtor._api.result.CommandExecResultStatus;
|
//import link.pagan.traqtor._api.result.CommandExecResultStatus;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
*
|
// *
|
||||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
// * @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
*/
|
// */
|
||||||
public abstract class Executor<T extends Executor<T>> extends Commanded<T> {
|
//public abstract class Executor<T extends Executor<T>> extends Commanded<T> {
|
||||||
|
//
|
||||||
private static boolean paranoindLoggin = false;
|
//
|
||||||
private static boolean mute = true;
|
//
|
||||||
|
// @SuppressWarnings("unchecked")
|
||||||
@SuppressWarnings("unchecked")
|
// public CommandExecResult execute(Command<T> command) {
|
||||||
public CommandExecResult execute(Command<T> command) {
|
// CommandExecResult result = new CommandExecResult();
|
||||||
CommandExecResult result = new CommandExecResult();
|
// command.setResultHolder(result);
|
||||||
command.setResultHolder(result);
|
// command.exec((T) this);
|
||||||
command.exec((T) this);
|
// if (!mute) {
|
||||||
if (!mute) {
|
// if (paranoindLoggin) {
|
||||||
if (paranoindLoggin) {
|
// result.print();
|
||||||
result.print();
|
// } else {
|
||||||
} else {
|
// if (result.getStatus() != CommandExecResultStatus.DONE) {
|
||||||
if (result.getStatus() != CommandExecResultStatus.DONE) {
|
// result.print();
|
||||||
result.print();
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// return result;
|
||||||
return result;
|
// }
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
public static void enableParanoindLoggin() {
|
|
||||||
enableLog();
|
|
||||||
paranoindLoggin = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void enableLog() {
|
|
||||||
mute = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -0,0 +1,303 @@
|
|||||||
|
package link.pagan.traqtor.api;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import link.pagan.traqtor._api.UnaryCommand;
|
||||||
|
import link.pagan.traqtor._api.result.CommandExecResult;
|
||||||
|
import link.pagan.traqtor._api.result.message.CommandExecMessage;
|
||||||
|
import link.pagan.traqtor._api.result.message.CommandExecMessageStatus;
|
||||||
|
import link.pagan.traqtor.api.project.Project;
|
||||||
|
import link.pagan.traqtor.api.project.universe.UniverseProject;
|
||||||
|
import link.pagan.traqtor.api.workspace.Workspace;
|
||||||
|
import link.pagan.traqtor.schema.data.DataTypeSchema;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class API {
|
||||||
|
|
||||||
|
private static boolean workspaceExists (CommandExecResult result, Traqtor traqtor) {
|
||||||
|
if (traqtor.workspace() == null) {
|
||||||
|
result.add(new CommandExecMessage(CommandExecMessageStatus.FAIL, "No workspace initialized"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CreateWorkspace extends UnaryCommand<Traqtor> {
|
||||||
|
|
||||||
|
private final Name name;
|
||||||
|
private final String path;
|
||||||
|
|
||||||
|
public CreateWorkspace() {
|
||||||
|
this(Workspace.DEFAULT_WORKSPACE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateWorkspace(Name name) {
|
||||||
|
this(name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateWorkspace(Name name, String path) {
|
||||||
|
this.name = name;
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandExecResult exec() {
|
||||||
|
if (arg.workspace() != null) {
|
||||||
|
return fail("There is an open workspace - please close this first, before creating new one");
|
||||||
|
}
|
||||||
|
arg.workspace(new Workspace());
|
||||||
|
arg.workspace().name(name);
|
||||||
|
subexec(new API.WorkspaceLoadDataTypeSchema(Name.of("traqtor", "basic")));
|
||||||
|
if (!result.OK()) {
|
||||||
|
arg.workspace(null);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path != null) {
|
||||||
|
subexec(new SaveAsWorkspace(path));
|
||||||
|
if (!result.OK()) {
|
||||||
|
arg.workspace(null);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SaveAsWorkspace extends UnaryCommand<Traqtor> {
|
||||||
|
|
||||||
|
private final String workspacePath;
|
||||||
|
|
||||||
|
public SaveAsWorkspace(String workspacePath) {
|
||||||
|
this.workspacePath = workspacePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandExecResult exec() {
|
||||||
|
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 = arg.workspace().root();
|
||||||
|
arg.workspace().root(workspacePath);
|
||||||
|
subexec(new SaveWorkspace());
|
||||||
|
if (!result.OK()) {
|
||||||
|
arg.workspace().root(hold);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SaveWorkspace extends UnaryCommand<Traqtor> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandExecResult exec() {
|
||||||
|
String workspacePath = arg.workspace().root();
|
||||||
|
if (arg.workspace().root() == 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 {
|
||||||
|
arg.workspace().mapper().writeValue(workspaceFile, arg.workspace());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
System.err.println(ex);
|
||||||
|
return fail("Failed to write " + Workspace.JSON_FILENAME + ".json");
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO add project save
|
||||||
|
// for (Project project : arg.workspace().projects()) {
|
||||||
|
// subexec(new )
|
||||||
|
// }
|
||||||
|
|
||||||
|
arg.workspace().dirty(false);
|
||||||
|
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LoadWorkspace extends UnaryCommand<Traqtor> {
|
||||||
|
|
||||||
|
private final String workspacePath;
|
||||||
|
|
||||||
|
public LoadWorkspace(String workspacePath) {
|
||||||
|
this.workspacePath = workspacePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandExecResult exec() {
|
||||||
|
File workspaceFile = new File(workspacePath, Workspace.JSON_FILENAME + ".json");
|
||||||
|
if (!workspaceFile.exists()) {
|
||||||
|
return fail("No " + Workspace.JSON_FILENAME + ".json file found in selected directory, missed?");
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
SimpleModule module = new SimpleModule();
|
||||||
|
module.addDeserializer(Workspace.class, new Workspace.WorkspaceDeserializer());
|
||||||
|
mapper.registerModule(module);
|
||||||
|
|
||||||
|
Workspace workspace = null;
|
||||||
|
try {
|
||||||
|
workspace = mapper.readValue(workspaceFile, Workspace.class);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
System.err.println(ex);
|
||||||
|
return fail("Failed to read " + workspaceFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
workspace.root(workspacePath);
|
||||||
|
HashMap<Name, DataTypeSchema> schemas = workspace.dataTypeSchemas();
|
||||||
|
for (Name name : schemas.keySet()) {
|
||||||
|
if (schemas.get(name) == null) {
|
||||||
|
DataTypeSchema loaded = arg.dataTypeSchemas.get(name);
|
||||||
|
if (loaded == null) {
|
||||||
|
warn("Shema with name " + name.asDotted() + " was not found in system. Preload or give up");
|
||||||
|
} else {
|
||||||
|
schemas.put(name, loaded);
|
||||||
|
info("Shema " + name.asDotted() + " was found and loaded into workspace on load");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arg.workspace(workspace);
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WorkspaceLoadDataTypeSchema extends UnaryCommand<Traqtor> {
|
||||||
|
|
||||||
|
private final Name name;
|
||||||
|
|
||||||
|
public WorkspaceLoadDataTypeSchema(Name name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandExecResult exec() {
|
||||||
|
if (!workspaceExists(result, arg)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
DataTypeSchema schema = arg.dataTypeSchemas.get(this.name);
|
||||||
|
if (schema == null) {
|
||||||
|
return fail("Unable to load data type schema by name " + name.asDotted());
|
||||||
|
}
|
||||||
|
arg.workspace().dataTypeSchemas().put(schema.getName(), schema);
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WorkspaceCreateUniverseProject extends UnaryCommand<Traqtor> {
|
||||||
|
|
||||||
|
private final Name name;
|
||||||
|
private final Name schema;
|
||||||
|
|
||||||
|
public WorkspaceCreateUniverseProject(Name name, Name schema) {
|
||||||
|
this.name = name;
|
||||||
|
this.schema = schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandExecResult exec() {
|
||||||
|
if (!workspaceExists(result, arg)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Workspace workspace = arg.workspace();
|
||||||
|
DataTypeSchema dataTypeSchema = workspace.dataTypeSchemas().get(schema);
|
||||||
|
if (dataTypeSchema == null) {
|
||||||
|
return fail("Data type schema with name " + schema.asDotted() + " was not found");
|
||||||
|
}
|
||||||
|
if (workspace.projects().containsKey(this.name)) {
|
||||||
|
return fail("Project with name " + this.name + " already exists");
|
||||||
|
}
|
||||||
|
|
||||||
|
Project project = new UniverseProject(name, dataTypeSchema);
|
||||||
|
workspace.projects().put(project.name(), project);
|
||||||
|
workspace.dirty(true);
|
||||||
|
|
||||||
|
CommandExecResult saveResult = arg.execute(new API.SaveWorkspace());
|
||||||
|
if (!saveResult.OK()) {
|
||||||
|
return fail("Failed to save workspace, after project addition");
|
||||||
|
}
|
||||||
|
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ProjectSave extends UnaryCommand<Traqtor> {
|
||||||
|
|
||||||
|
private final Name name;
|
||||||
|
private final Name schema;
|
||||||
|
|
||||||
|
public ProjectSave(Name name, Name schema) {
|
||||||
|
this.name = name;
|
||||||
|
this.schema = schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandExecResult exec() {
|
||||||
|
if (!workspaceExists(result, arg)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Workspace workspace = arg.workspace();
|
||||||
|
DataTypeSchema dataTypeSchema = workspace.dataTypeSchemas().get(schema);
|
||||||
|
if (dataTypeSchema == null) {
|
||||||
|
return fail("Data type schema with name " + schema.asDotted() + " was not found");
|
||||||
|
}
|
||||||
|
if (workspace.projects().containsKey(this.name)) {
|
||||||
|
return fail("Project with name " + this.name + " already exists");
|
||||||
|
}
|
||||||
|
|
||||||
|
Project project = new UniverseProject(name, dataTypeSchema);
|
||||||
|
workspace.projects().put(project.name(), project);
|
||||||
|
workspace.dirty(true);
|
||||||
|
|
||||||
|
CommandExecResult saveResult = arg.execute(new API.SaveWorkspace());
|
||||||
|
if (!saveResult.OK()) {
|
||||||
|
return fail("Failed to save workspace, after project addition");
|
||||||
|
}
|
||||||
|
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,9 +1,42 @@
|
|||||||
package link.pagan.traqtor.api.project;
|
package link.pagan.traqtor.api.project;
|
||||||
|
|
||||||
|
import link.pagan.traqtor._api.Commanded;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
*/
|
*/
|
||||||
public abstract class Project {
|
public abstract class Project implements Commanded {
|
||||||
|
|
||||||
|
private final ProjectType type;
|
||||||
|
private Name name;
|
||||||
|
private boolean dirty;
|
||||||
|
|
||||||
|
public Project(ProjectType type, Name name) {
|
||||||
|
this.type = type;
|
||||||
|
this.name = name;
|
||||||
|
this.dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectType type() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Name name() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void name(Name name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean dirty() {
|
||||||
|
return dirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dirty(boolean dirty) {
|
||||||
|
this.dirty = dirty;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,74 @@
|
|||||||
|
package link.pagan.traqtor.api.project;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public enum ProjectType {
|
||||||
|
UNIVERSE("universe"),
|
||||||
|
DATABASE("database"),
|
||||||
|
FRONTEND("frontend"),
|
||||||
|
BACKEND("backend");
|
||||||
|
|
||||||
|
String jsonValue;
|
||||||
|
|
||||||
|
private ProjectType(String jsonValue) {
|
||||||
|
this.jsonValue = jsonValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class ProjectTypeSerializer extends StdSerializer<ProjectType> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public ProjectTypeSerializer() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectTypeSerializer(Class<ProjectType> t) {
|
||||||
|
super(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(ProjectType value, JsonGenerator gen, SerializerProvider provider) throws IOException {
|
||||||
|
gen.writeString(value.jsonValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class ProjectTypeDeserializer extends StdDeserializer<ProjectType> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public ProjectTypeDeserializer() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectTypeDeserializer(Class<ProjectType> t) {
|
||||||
|
super(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProjectType deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||||
|
JsonNode stringType = parser.getCodec().readTree(parser);
|
||||||
|
String type = stringType.asText();
|
||||||
|
for (ProjectType pt : values()) {
|
||||||
|
if (pt.jsonValue.equals(type)) {
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.project;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
|
||||||
*/
|
|
||||||
public class UniverseProject extends Project {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.project.backend;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.api.project.Project;
|
||||||
|
import link.pagan.traqtor.api.project.ProjectType;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class BackendProject extends Project {
|
||||||
|
|
||||||
|
public BackendProject(Name name) {
|
||||||
|
super(ProjectType.BACKEND, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.project.database;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.api.project.Project;
|
||||||
|
import link.pagan.traqtor.api.project.ProjectType;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class DatabaseProject extends Project {
|
||||||
|
|
||||||
|
public DatabaseProject(Name name) {
|
||||||
|
super(ProjectType.DATABASE, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.project.frontend;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.api.project.Project;
|
||||||
|
import link.pagan.traqtor.api.project.ProjectType;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class FrontendProject extends Project {
|
||||||
|
|
||||||
|
public FrontendProject(Name name) {
|
||||||
|
super(ProjectType.FRONTEND, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package link.pagan.traqtor.api.project.universe;
|
||||||
|
|
||||||
|
import link.pagan.traqtor.api.project.Project;
|
||||||
|
import link.pagan.traqtor.api.project.ProjectType;
|
||||||
|
import link.pagan.traqtor.schema.data.DataTypeSchema;
|
||||||
|
import link.pagan.traqtor.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
||||||
|
*/
|
||||||
|
public class UniverseProject extends Project {
|
||||||
|
|
||||||
|
DataTypeSchema dataTypeSchema;
|
||||||
|
|
||||||
|
public UniverseProject(Name name, DataTypeSchema dataTypeSchema) {
|
||||||
|
super(ProjectType.UNIVERSE, name);
|
||||||
|
this.dataTypeSchema = dataTypeSchema;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,55 +1,35 @@
|
|||||||
package link.pagan.traqtor.api.workspace;
|
package link.pagan.traqtor.api.workspace;
|
||||||
|
|
||||||
//package link.pagan.traqtor.api.workbench;
|
import java.io.IOException;
|
||||||
//
|
import link.pagan.traqtor._api.TraqtorApiTestUtils;
|
||||||
//import link.pagan.traqtor.api.workbench.command.WorkbenchCommandSaveAs;
|
import link.pagan.traqtor._api.result.CommandExecResult;
|
||||||
//import link.pagan.traqtor.api.workbench.command.WorkbenchCommandSave;
|
import static link.pagan.traqtor._api.result.CommandExecResultStatus.DONE;
|
||||||
//import java.io.IOException;
|
import link.pagan.traqtor.api.API;
|
||||||
//import link.pagan.traqtor._api.PrimedTest;
|
import link.pagan.traqtor.api.Traqtor;
|
||||||
//import link.pagan.traqtor._api.Executor;
|
import link.pagan.traqtor.util.Name;
|
||||||
//import link.pagan.traqtor._api.result.CommandExecResult;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
//import static link.pagan.traqtor._api.result.CommandExecResultStatus.DONE;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
//import static link.pagan.traqtor._api.result.CommandExecResultStatus.FAIL;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
//import static org.junit.jupiter.api.Assertions.assertEquals;
|
import org.junit.jupiter.api.Test;
|
||||||
//import org.junit.jupiter.api.BeforeAll;
|
|
||||||
//import org.junit.jupiter.api.BeforeEach;
|
public class WorkspaceTest {
|
||||||
//import org.junit.jupiter.api.Test;
|
|
||||||
//
|
CommandExecResult result;
|
||||||
///**
|
|
||||||
// *
|
@BeforeEach
|
||||||
// * @author Edward M. Kagan {@literal <}kaganem{@literal @}2pm.tech{@literal >}
|
public void cleanTestDir() throws IOException {
|
||||||
// */
|
TraqtorApiTestUtils.killTestRoot();
|
||||||
//public class WorkbenchTest {
|
// Executor.enableParanoindLoggin();
|
||||||
//
|
}
|
||||||
// @BeforeAll
|
|
||||||
// public static void setup() throws IOException {
|
@Test
|
||||||
// Executor.enableParanoindLoggin();
|
@DisplayName("Create project")
|
||||||
// }
|
void newSaveLoad() {
|
||||||
//
|
Traqtor traqtor = Traqtor.init();
|
||||||
// @BeforeEach
|
result = traqtor.execute(new API.CreateWorkspace(TraqtorApiTestUtils.TEST_WORKSPACE_NAME, TraqtorApiTestUtils.TEST_WORKSPACE_ROOT));
|
||||||
// public void clean() throws IOException {
|
assertEquals(DONE, result.getStatus());
|
||||||
// killTestRoot();
|
assertEquals(traqtor.workspace().dirty(), false);
|
||||||
// }
|
traqtor.execute(new API.WorkspaceCreateUniverseProject(Name.of("universe"), Name.of("traqtor", "basic")));
|
||||||
//
|
}
|
||||||
//// @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());
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue