Loading .gitignore +6 −1 Original line number Diff line number Diff line Loading @@ -19,3 +19,8 @@ tmp/ ### Mac .DS_Store ### FIDENTIS instance files fidentis.log fidentis.mv.db fidentis.trace.db No newline at end of file .gitlab-ci.yml +5 −12 Original line number Diff line number Diff line Loading @@ -85,22 +85,15 @@ build-bundles: image: ubuntu:latest script: - apt-get update -qq && apt-get install -y -qq maven openjdk-21-jdk zip unzip curl mkisofs - mvn clean install javadoc:javadoc javadoc:aggregate $MAVEN_JAVADOC_OPTS $MAVEN_CLI_OPTS -DskipTests -Pcreate-linux-package -Pcreate-win64-package #-Pcreate-win32-package #-Pcreate-macosx-package - export VERSION=$(grep -oP '^([^\s]*)' $DEPLOYMENT_INFO_VERSION_FILE) - ./scripts/build.sh tags: - shared-fi rules: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' changes: - VERSION.txt - if: '$CI_COMMIT_BRANCH' when: never when: manual artifacts: paths: - target/site/apidocs/ - application/target/$PROJECT_ARTIFACT_ID-*.zip - application/target/linux-$PROJECT_ARTIFACT_ID-*.tar.gz - application/target/win*-$PROJECT_ARTIFACT_ID-*.zip # - application/target/ios-$PROJECT_ARTIFACT_ID-*.dmg # TOO BIG (ISO IMAGE) FOR CI/CD - application/target/fidentis-analyst*.tar.gz expire_in: 20 mins when: on_success Loading FaceData/pom.xml +7 −31 Original line number Diff line number Diff line Loading @@ -7,30 +7,11 @@ <version>master-SNAPSHOT</version> </parent> <artifactId>FaceData</artifactId> <packaging>nbm</packaging> <build> <plugins> <plugin> <groupId>org.apache.netbeans.utilities</groupId> <artifactId>nbm-maven-plugin</artifactId> <extensions>true</extensions> <configuration> <useOSGiDependencies>true</useOSGiDependencies> <publicPackages> <!-- expose API/packages to other modules --> <publicPackage>cz.fidentis.analyst.data.face</publicPackage> <publicPackage>cz.fidentis.analyst.data.face.impl</publicPackage><!-- due to deserialization --> <publicPackage>cz.fidentis.analyst.data.face.events</publicPackage> </publicPackages> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> </archive> </configuration> </plugin> <!-- Check code style --> <plugin> Loading Loading @@ -124,11 +105,6 @@ <artifactId>h2</artifactId> <version>2.3.232</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>eclipselink</artifactId> <version>4.0.5</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> Loading @@ -139,20 +115,20 @@ <artifactId>jaxb-api</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.service.jdbc</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> <version>3.17.0</version> </dependency> <dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> <version>3.4.2</version> <version>4.31.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <version>3.4.4</version> </dependency> </dependencies> <properties> Loading FaceData/src/main/java/cz/fidentis/analyst/data/face/AbstractRepository.javadeleted 100644 → 0 +0 −105 Original line number Diff line number Diff line package cz.fidentis.analyst.data.face; import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.Query; import java.util.List; import java.util.function.Function; /** * * @author Marek Seďa */ public abstract class AbstractRepository<T extends BaseEntity> { protected final EntityManagerFactory entityManagerFactory; private final Class<T> entityClass; public AbstractRepository(Class<T> clazz, EntityManagerFactory entityManagerFactory) { this.entityClass = clazz; this.entityManagerFactory = entityManagerFactory; } /** * Find entity by id or return null if not found * * @param id * @return entity */ public T findByIdOrNull(long id) { return runInTransaction(entityManager -> entityManager.find(entityClass, id) ); } /** * Find all entities * @return entities */ public List<T> findAll() { return runInTransaction(entityManager -> { Query query = entityManager.createQuery("SELECT entity FROM " + entityClass.getSimpleName() + " entity order by entity.id", BaseEntity.class); return (List<T>) query.getResultList(); } ); } /** * Update entity * @param entity * @return updated entity */ public T update(T entity) { return runInTransaction(entityManager -> { entityManager.merge(entity); return entity; }); } /** * Save entity * @param entity * @return saved entity */ public T save(T entity) { return runInTransaction(entityManager -> { entityManager.persist(entity); return entity; }); } /** * Delete entity by id * @param id */ public void deleteById(long id) { runInTransaction(entityManager -> { T entity = entityManager.find(entityClass, id); if (entity != null) { entityManager.remove(entityManager.find(entityClass, id)); } return null; }); } protected <V> V runInTransaction(Function<EntityManager, V> function) { EntityManager entityManager = entityManagerFactory.createEntityManager(); entityManager.getTransaction().begin(); V result; try { result = function.apply(entityManager); entityManager.getTransaction().commit(); } catch (Exception e) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } e.printStackTrace(); throw e; } return result; } } FaceData/src/main/java/cz/fidentis/analyst/data/face/Aca.java 0 → 100644 +42 −0 Original line number Diff line number Diff line package cz.fidentis.analyst.data.face; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; /** * A singleton class that provides access to the Spring application context. * This class is used to retrieve beans from the application context. * * @author Marek Seďa */ @Service public class Aca { private static Aca instance; public static Aca getInstance() { return instance; } private ApplicationContext context; /** * Constructor that initializes the Aca instance with the provided application context. * * @param context The Spring application context. */ public Aca(ApplicationContext context) { this.context = context; instance = this; } /** * Retrieves a bean of the specified class from the application context. * * @param clazz The class of the bean to retrieve. * @param <T> The type of the bean. * @return An instance of the specified bean type. */ public <T> T getBean(Class<T> clazz) { return context.getBean(clazz); } } Loading
.gitignore +6 −1 Original line number Diff line number Diff line Loading @@ -19,3 +19,8 @@ tmp/ ### Mac .DS_Store ### FIDENTIS instance files fidentis.log fidentis.mv.db fidentis.trace.db No newline at end of file
.gitlab-ci.yml +5 −12 Original line number Diff line number Diff line Loading @@ -85,22 +85,15 @@ build-bundles: image: ubuntu:latest script: - apt-get update -qq && apt-get install -y -qq maven openjdk-21-jdk zip unzip curl mkisofs - mvn clean install javadoc:javadoc javadoc:aggregate $MAVEN_JAVADOC_OPTS $MAVEN_CLI_OPTS -DskipTests -Pcreate-linux-package -Pcreate-win64-package #-Pcreate-win32-package #-Pcreate-macosx-package - export VERSION=$(grep -oP '^([^\s]*)' $DEPLOYMENT_INFO_VERSION_FILE) - ./scripts/build.sh tags: - shared-fi rules: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' changes: - VERSION.txt - if: '$CI_COMMIT_BRANCH' when: never when: manual artifacts: paths: - target/site/apidocs/ - application/target/$PROJECT_ARTIFACT_ID-*.zip - application/target/linux-$PROJECT_ARTIFACT_ID-*.tar.gz - application/target/win*-$PROJECT_ARTIFACT_ID-*.zip # - application/target/ios-$PROJECT_ARTIFACT_ID-*.dmg # TOO BIG (ISO IMAGE) FOR CI/CD - application/target/fidentis-analyst*.tar.gz expire_in: 20 mins when: on_success Loading
FaceData/pom.xml +7 −31 Original line number Diff line number Diff line Loading @@ -7,30 +7,11 @@ <version>master-SNAPSHOT</version> </parent> <artifactId>FaceData</artifactId> <packaging>nbm</packaging> <build> <plugins> <plugin> <groupId>org.apache.netbeans.utilities</groupId> <artifactId>nbm-maven-plugin</artifactId> <extensions>true</extensions> <configuration> <useOSGiDependencies>true</useOSGiDependencies> <publicPackages> <!-- expose API/packages to other modules --> <publicPackage>cz.fidentis.analyst.data.face</publicPackage> <publicPackage>cz.fidentis.analyst.data.face.impl</publicPackage><!-- due to deserialization --> <publicPackage>cz.fidentis.analyst.data.face.events</publicPackage> </publicPackages> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> </archive> </configuration> </plugin> <!-- Check code style --> <plugin> Loading Loading @@ -124,11 +105,6 @@ <artifactId>h2</artifactId> <version>2.3.232</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>eclipselink</artifactId> <version>4.0.5</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> Loading @@ -139,20 +115,20 @@ <artifactId>jaxb-api</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.service.jdbc</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> <version>3.17.0</version> </dependency> <dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> <version>3.4.2</version> <version>4.31.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <version>3.4.4</version> </dependency> </dependencies> <properties> Loading
FaceData/src/main/java/cz/fidentis/analyst/data/face/AbstractRepository.javadeleted 100644 → 0 +0 −105 Original line number Diff line number Diff line package cz.fidentis.analyst.data.face; import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.Query; import java.util.List; import java.util.function.Function; /** * * @author Marek Seďa */ public abstract class AbstractRepository<T extends BaseEntity> { protected final EntityManagerFactory entityManagerFactory; private final Class<T> entityClass; public AbstractRepository(Class<T> clazz, EntityManagerFactory entityManagerFactory) { this.entityClass = clazz; this.entityManagerFactory = entityManagerFactory; } /** * Find entity by id or return null if not found * * @param id * @return entity */ public T findByIdOrNull(long id) { return runInTransaction(entityManager -> entityManager.find(entityClass, id) ); } /** * Find all entities * @return entities */ public List<T> findAll() { return runInTransaction(entityManager -> { Query query = entityManager.createQuery("SELECT entity FROM " + entityClass.getSimpleName() + " entity order by entity.id", BaseEntity.class); return (List<T>) query.getResultList(); } ); } /** * Update entity * @param entity * @return updated entity */ public T update(T entity) { return runInTransaction(entityManager -> { entityManager.merge(entity); return entity; }); } /** * Save entity * @param entity * @return saved entity */ public T save(T entity) { return runInTransaction(entityManager -> { entityManager.persist(entity); return entity; }); } /** * Delete entity by id * @param id */ public void deleteById(long id) { runInTransaction(entityManager -> { T entity = entityManager.find(entityClass, id); if (entity != null) { entityManager.remove(entityManager.find(entityClass, id)); } return null; }); } protected <V> V runInTransaction(Function<EntityManager, V> function) { EntityManager entityManager = entityManagerFactory.createEntityManager(); entityManager.getTransaction().begin(); V result; try { result = function.apply(entityManager); entityManager.getTransaction().commit(); } catch (Exception e) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } e.printStackTrace(); throw e; } return result; } }
FaceData/src/main/java/cz/fidentis/analyst/data/face/Aca.java 0 → 100644 +42 −0 Original line number Diff line number Diff line package cz.fidentis.analyst.data.face; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; /** * A singleton class that provides access to the Spring application context. * This class is used to retrieve beans from the application context. * * @author Marek Seďa */ @Service public class Aca { private static Aca instance; public static Aca getInstance() { return instance; } private ApplicationContext context; /** * Constructor that initializes the Aca instance with the provided application context. * * @param context The Spring application context. */ public Aca(ApplicationContext context) { this.context = context; instance = this; } /** * Retrieves a bean of the specified class from the application context. * * @param clazz The class of the bean to retrieve. * @param <T> The type of the bean. * @return An instance of the specified bean type. */ public <T> T getBean(Class<T> clazz) { return context.getBean(clazz); } }