Skip to content

Commit

Permalink
Initial SQLite work.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Aug 25, 2024
1 parent 0dead75 commit 8d7ab1f
Show file tree
Hide file tree
Showing 52 changed files with 4,440 additions and 69 deletions.
176 changes: 176 additions & 0 deletions com.io7m.laurel.filemodel/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?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>
<parent>
<groupId>com.io7m.laurel</groupId>
<artifactId>com.io7m.laurel</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>com.io7m.laurel.filemodel</artifactId>

<packaging>jar</packaging>
<name>com.io7m.laurel.filemodel</name>
<description>Image caption management (File model)</description>
<url>https://www.io7m.com/software/laurel/</url>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>com.io7m.laurel.model</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.io7m.jattribute</groupId>
<artifactId>com.io7m.jattribute.core</artifactId>
</dependency>
<dependency>
<groupId>com.io7m.lanark</groupId>
<artifactId>com.io7m.lanark.core</artifactId>
</dependency>
<dependency>
<groupId>com.io7m.jmulticlose</groupId>
<artifactId>com.io7m.jmulticlose.core</artifactId>
</dependency>
<dependency>
<groupId>com.io7m.darco</groupId>
<artifactId>com.io7m.darco.sqlite</artifactId>
</dependency>
<dependency>
<groupId>com.io7m.darco</groupId>
<artifactId>com.io7m.darco.api</artifactId>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>

<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.bundle</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>

<dependencies>
<dependency>
<groupId>com.io7m.trasco</groupId>
<artifactId>com.io7m.trasco.api</artifactId>
<version>${com.io7m.trasco.version}</version>
</dependency>
<dependency>
<groupId>com.io7m.trasco</groupId>
<artifactId>com.io7m.trasco.vanilla</artifactId>
<version>${com.io7m.trasco.version}</version>
</dependency>
<dependency>
<groupId>com.io7m.trasco</groupId>
<artifactId>com.io7m.trasco.xml.schemas</artifactId>
<version>${com.io7m.trasco.version}</version>
</dependency>
</dependencies>

<executions>
<execution>
<id>generate-sql</id>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.io7m.trasco.vanilla.TrSchemaRevisionSetSQLMain</mainClass>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>false</includeProjectDependencies>
<arguments>
<argument>${project.basedir}/src/main/resources/com/io7m/laurel/filemodel/internal/database.xml</argument>
<argument>${project.build.directory}/database.sql</argument>
<argument>ROLES</argument>
<argument>GRANTS</argument>
<argument>FUNCTIONS</argument>
<argument>TRIGGERS</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${org.jooq.version}</version>
<configuration>
<configurationFile>src/main/jooq/configuration.xml</configurationFile>
</configuration>
<executions>
<execution>
<id>jooq-codegen</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>${org.jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-postgres-extensions</artifactId>
<version>${org.jooq.version}</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-jooq-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/jooq</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
* Copyright © 2024 Mark Raynsford <[email protected]> https://www.io7m.com
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/


package com.io7m.laurel.filemodel;

import com.io7m.jattribute.core.AttributeReadableType;
import com.io7m.laurel.model.LException;
import com.io7m.laurel.model.LImage;
import com.io7m.laurel.model.LTag;

import java.net.URI;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

/**
* The interface to a file model.
*/

public interface LFileModelType
extends AutoCloseable
{
/**
* Add a tag.
*
* @param text The tag
*
* @return The operation in progress
*/

CompletableFuture<?> tagAdd(
LTag text);

/**
* Load an image and add it to the file.
*
* @param name The (unique) name
* @param file The file
* @param source The URI source, if any
*
* @return The operation in progress
*/

CompletableFuture<?> imageAdd(
String name,
Path file,
Optional<URI> source
);

/**
* Select an image.
*
* @param name The name
*
* @return The operation in progress
*/

CompletableFuture<?> imageSelect(
Optional<String> name);

@Override
void close()
throws LException;

/**
* @return The currently selected image
*/

AttributeReadableType<Optional<LImage>> imageSelected();

/**
* @return The current complete list of images
*/

AttributeReadableType<List<LImage>> imageList();

/**
* @return The current complete list of tags
*/

AttributeReadableType<List<LTag>> tagList();

/**
* @return The list of tags assigned to the current image
*/

AttributeReadableType<List<LTag>> tagsAssigned();

/**
* @return Text describing the top of the undo stack, if any
*/

AttributeReadableType<Optional<String>> undoText();

/**
* Undo the operation on the top of the undo stack
*
* @return The operation in progress
*/

CompletableFuture<?> undo();

/**
* Redo the operation on the top of the redo stack
*
* @return The operation in progress
*/

CompletableFuture<?> redo();

/**
* @return Text describing the top of the redo stack, if any
*/

AttributeReadableType<Optional<String>> redoText();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright © 2024 Mark Raynsford <[email protected]> https://www.io7m.com
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/


package com.io7m.laurel.filemodel;

import com.io7m.laurel.filemodel.internal.LFileModel;
import com.io7m.laurel.model.LException;

import java.nio.file.Path;

/**
* The file models.
*/

public final class LFileModels
{
private LFileModels()
{

}

/**
* Open a file model.
*
* @param file The file
* @param readOnly {@code true} if the file should be read-only
*
* @return A file model
*
* @throws LException On errors
*/

public static LFileModelType open(
final Path file,
final boolean readOnly)
throws LException
{
return LFileModel.open(file, readOnly);
}
}
Loading

0 comments on commit 8d7ab1f

Please sign in to comment.