Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions checkstyle-project-fqn.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
<property name="id" value="sparkImportsAtSparkEdge"/>
<property name="files" value=".*[/\\]thingifier[/\\]src[/\\]main[/\\]java[/\\]uk[/\\]co[/\\]compendiumdev[/\\]thingifier[/\\]htmlgui[/\\]routing[/\\].*"/>
</module>
<module name="SuppressionSingleFilter">
<property name="id" value="sparkImportsAtSparkEdge"/>
<property name="files" value=".*[/\\]thingifier-crud-ui[/\\]src[/\\]main[/\\]java[/\\]uk[/\\]co[/\\]compendiumdev[/\\]thingifier[/\\]crudui[/\\]adapter[/\\]spark[/\\].*"/>
</module>
<module name="SuppressionSingleFilter">
<property name="id" value="sparkImportsAtSparkEdge"/>
<property name="files" value=".*[/\\]challenger[/\\]src[/\\]main[/\\]java[/\\].*"/>
Expand Down Expand Up @@ -136,6 +140,10 @@
<property name="id" value="yamlAdapterTypesStayInYamlModule"/>
<property name="files" value=".*[/\\]thingifier-yaml[/\\]src[/\\](main|test)[/\\]java[/\\].*"/>
</module>
<module name="SuppressionSingleFilter">
<property name="id" value="yamlAdapterTypesStayInYamlModule"/>
<property name="files" value=".*[/\\]thingifier-crud-ui[/\\]src[/\\](main|test)[/\\]java[/\\].*"/>
</module>
<module name="SuppressionSingleFilter">
<property name="id" value="schemaDefinitionSpecsNoMutableRuntimeSchema"/>
<property name="files" value=".*[/\\]src[/\\]test[/\\]java[/\\].*"/>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<module>thingifier</module>
<module>thingifier-yaml</module>
<module>examplemodels</module>
<module>thingifier-crud-ui</module>
<module>todoManagerRestAuto</module>
<module>challenger</module>
<module>challengerAuto</module>
Expand Down
100 changes: 100 additions & 0 deletions thingifier-crud-ui/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<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>uk.co.compendiumdev.thingifier</groupId>
<artifactId>thingifier-root</artifactId>
<version>1.5.6-SNAPSHOT</version>
</parent>

<groupId>uk.co.compendiumdev</groupId>
<artifactId>thingifier-crud-ui</artifactId>
<packaging>jar</packaging>

<name>thingifier crud ui</name>
<url>https://compendiumdev.co.uk</url>

<dependencies>
<dependency>
<groupId>uk.co.compendiumdev</groupId>
<artifactId>thingifier</artifactId>
<version>${thingifier.version}</version>
</dependency>
<dependency>
<groupId>uk.co.compendiumdev</groupId>
<artifactId>thingifier-yaml</artifactId>
<version>${thingifier.version}</version>
</dependency>
<dependency>
<groupId>uk.co.compendiumdev.thingifier</groupId>
<artifactId>examplemodels</artifactId>
<version>${thingifier.version}</version>
</dependency>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>thingifier-crud-ui-${project.version}-full</finalName>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>uk.co.compendiumdev.thingifier.crudui.CrudUiMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package uk.co.compendiumdev.thingifier.crudui;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import uk.co.compendiumdev.thingifier.Thingifier;
import uk.co.compendiumdev.thingifier.apiconfig.ThingifierApiConfigProfile;
import uk.co.compendiumdev.thingifier.application.examples.TodoManagerThingifier;
import uk.co.compendiumdev.thingifier.application.schema.definition.ThingifierModelDefinition;
import uk.co.compendiumdev.thingifier.application.schema.definition.ThingifierModelExporter;
import uk.co.compendiumdev.thingifier.yaml.ThingifierYamlExporter;
import uk.co.compendiumdev.thingifier.yaml.ThingifierYamlLoader;

public final class ActiveThingifierWorkspace implements AutoCloseable {

private final ThingifierModelExporter modelExporter;
private final ThingifierYamlExporter yamlExporter;
private final ThingifierYamlLoader yamlLoader;
private Thingifier thingifier;
private ThingifierModelDefinition definition;
private String schemaYaml;
private long version;

private ActiveThingifierWorkspace(final Thingifier thingifier) {
modelExporter = new ThingifierModelExporter();
yamlExporter = new ThingifierYamlExporter();
yamlLoader = new ThingifierYamlLoader();
replaceWith(thingifier);
version = 1L;
}

public static ActiveThingifierWorkspace defaultTodoManagerWorkspace() {
Thingifier todoManager = new TodoManagerThingifier().get();
ThingifierApiConfigProfile defaultProfile = todoManager.apiConfigProfiles().getDefault();
if (defaultProfile != null) {
todoManager.configureWithProfile(defaultProfile);
}
return new ActiveThingifierWorkspace(todoManager);
}

public synchronized WorkspaceSnapshot snapshot() {
return new WorkspaceSnapshot(version, thingifier, definition, schemaYaml);
}

public synchronized WorkspaceSnapshot replaceWithYaml(final String yamlText) {
Thingifier newThingifier = yamlLoader.loadThingifier(yamlText);
Thingifier oldThingifier = thingifier;
replaceWith(newThingifier);
version++;
if (oldThingifier != null) {
oldThingifier.close();
}
return snapshot();
}

public synchronized WorkspaceSnapshot replaceWithYaml(final Path path) throws IOException {
return replaceWithYaml(Files.readString(path));
}

private void replaceWith(final Thingifier newThingifier) {
thingifier = newThingifier;
definition = modelExporter.export(newThingifier);
schemaYaml = yamlExporter.export(definition);
}

@Override
public synchronized void close() {
if (thingifier != null) {
thingifier.close();
}
}
}
Loading
Loading