+ *
+ * @param generic type of the {@link GenericRevisionedRepository} interface.
+ * @param generic type of the managed {@link net.sf.mmm.util.entity.api.PersistenceEntity entity}.
+ * @param generic type of the {@link net.sf.mmm.util.entity.api.PersistenceEntity#getId() primary key} of the
+ * entity.
+ *
+ * @since 3.0.0
+ */
+public class GenericRevisionedRepositoryFactoryBean, E, ID extends Serializable>
+ extends JpaRepositoryFactoryBean {
+
+ /**
+ * Creates a new {@link JpaRepositoryFactoryBean} for the given repository interface.
+ *
+ * @param repositoryInterface must not be {@literal null}.
+ */
+ public GenericRevisionedRepositoryFactoryBean(Class extends R> repositoryInterface) {
+
+ super(repositoryInterface);
+ }
+
+ @Override
+ protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) {
+
+ return new GenericRevisionedRepositoryFactory(entityManager);
+ }
+
+ private static class GenericRevisionedRepositoryFactory extends JpaRepositoryFactory {
+
+ /**
+ * The constructor.
+ *
+ * @param entityManager the {@link EntityManager}.
+ */
+ public GenericRevisionedRepositoryFactory(EntityManager entityManager) {
+
+ super(entityManager);
+ }
+
+ @Override
+ protected Class> getRepositoryBaseClass(RepositoryMetadata metadata) {
+
+ return GenericRevisionedRepositoryImpl.class;
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/modules/jpa-spring-data/src/main/java/io/oasp/module/jpa/dataaccess/impl/data/GenericRevisionedRepositoryImpl.java b/modules/jpa-spring-data/src/main/java/io/oasp/module/jpa/dataaccess/impl/data/GenericRevisionedRepositoryImpl.java
new file mode 100644
index 000000000..2e009b0f1
--- /dev/null
+++ b/modules/jpa-spring-data/src/main/java/io/oasp/module/jpa/dataaccess/impl/data/GenericRevisionedRepositoryImpl.java
@@ -0,0 +1,107 @@
+package io.oasp.module.jpa.dataaccess.impl.data;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.persistence.EntityManager;
+
+import net.sf.mmm.util.entity.api.MutableRevisionedEntity;
+import net.sf.mmm.util.exception.api.ObjectNotFoundUserException;
+
+import org.hibernate.envers.AuditReader;
+import org.hibernate.envers.AuditReaderFactory;
+import org.springframework.data.jpa.repository.support.JpaEntityInformation;
+
+import com.querydsl.core.alias.Alias;
+import com.querydsl.jpa.impl.JPAQuery;
+
+import io.oasp.module.jpa.dataaccess.api.AdvancedRevisionEntity;
+import io.oasp.module.jpa.dataaccess.api.QueryUtil;
+import io.oasp.module.jpa.dataaccess.api.RevisionMetadata;
+import io.oasp.module.jpa.dataaccess.api.RevisionMetadataType;
+import io.oasp.module.jpa.dataaccess.api.data.GenericRevisionedRepository;
+import io.oasp.module.jpa.dataaccess.impl.LazyRevisionMetadata;
+
+/**
+ * Implementation of {@link GenericRevisionedRepository}.
+ *
+ * @param generic type of the managed {@link #getEntityClass() entity}.
+ * @param generic type of the {@link net.sf.mmm.util.entity.api.PersistenceEntity#getId() primary key} of the
+ * entity.
+ *
+ * @since 3.0.0
+ */
+public class GenericRevisionedRepositoryImpl extends GenericRepositoryImpl
+ implements GenericRevisionedRepository {
+
+ /**
+ * The constructor.
+ *
+ * @param entityInformation the {@link JpaEntityInformation}.
+ * @param entityManager the JPA {@link EntityManager}.
+ */
+ public GenericRevisionedRepositoryImpl(JpaEntityInformation entityInformation, EntityManager entityManager) {
+
+ super(entityInformation, entityManager);
+ }
+
+ @Override
+ public E find(ID id, Number revision) {
+
+ AuditReader auditReader = AuditReaderFactory.get(this.entityManager);
+ E entity = auditReader.find(this.entityInformation.getJavaType(), id, revision);
+ if (entity instanceof MutableRevisionedEntity) {
+ ((MutableRevisionedEntity>) entity).setRevision(revision);
+ }
+ return entity;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List getRevisionHistoryMetadata(ID id, boolean lazy) {
+
+ AuditReader auditReader = AuditReaderFactory.get(this.entityManager);
+ List revisionList = auditReader.getRevisions(getEntityClass(), id);
+ if (revisionList.isEmpty()) {
+ return Collections.emptyList();
+ }
+ if (lazy) {
+ List result = new ArrayList<>(revisionList.size());
+ for (Number revision : revisionList) {
+ Long revisionLong = Long.valueOf(revision.longValue());
+ result.add(new LazyRevisionMetadata(this.entityManager, revisionLong));
+ }
+ return result;
+ } else {
+ AdvancedRevisionEntity rev = Alias.alias(AdvancedRevisionEntity.class);
+ JPAQuery query = new JPAQuery(this.entityManager)
+ .from(Alias.$(rev));
+ @SuppressWarnings("rawtypes")
+ List revList = revisionList;
+ QueryUtil.get().whereIn(query, Alias.$(rev.getId()), (List) revList);
+ query.orderBy(Alias.$(rev.getId()).asc());
+ List resultList = query.fetch();
+ return resultList.stream().map(x -> RevisionMetadataType.of(x)).collect(Collectors.toList());
+ }
+ }
+
+ @Override
+ public RevisionMetadata getLastRevisionHistoryMetadata(ID id) {
+
+ AuditReader auditReader = AuditReaderFactory.get(this.entityManager);
+ List revisionList = auditReader.getRevisions(getEntityClass(), id);
+ if (revisionList.isEmpty()) {
+ return null;
+ }
+ Number lastRevision = revisionList.get(revisionList.size() - 1);
+ AdvancedRevisionEntity revisionEntity = this.entityManager.find(AdvancedRevisionEntity.class, lastRevision);
+ if (revisionEntity == null) {
+ throw new ObjectNotFoundUserException(AdvancedRevisionEntity.class, id);
+ }
+ return RevisionMetadataType.of(revisionEntity);
+ }
+
+}
diff --git a/modules/jpa/pom.xml b/modules/jpa/pom.xml
index 982f4254c..4c8462df7 100644
--- a/modules/jpa/pom.xml
+++ b/modules/jpa/pom.xml
@@ -17,70 +17,8 @@
io.oasp.java.modules
- oasp4j-basic
+ oasp4j-jpa-dao
-
- org.hibernate.javax.persistence
- hibernate-jpa-2.1-api
-
-
- javax.transaction
- javax.transaction-api
-
-
- com.mysema.querydsl
- querydsl-jpa
-
-
- org.hibernate
- hibernate-entitymanager
- true
-
-
- org.springframework
- spring-beans
-
-
- net.sf.m-m-m
- mmm-util-search
-
-
-
- io.oasp.java.modules
- oasp4j-test
- test
-
-
- io.oasp.java.modules
- oasp4j-configuration
- test
-
-
- org.springframework
- spring-orm
- test
-
-
- org.springframework.boot
- spring-boot-starter
- test
-
-
- org.springframework
- spring-context
- test
-
-
- com.h2database
- h2
- test
-
-
- io.oasp.java.modules
- oasp4j-beanmapping
- test
-
-
\ No newline at end of file
diff --git a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/OrderByTo.java b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/OrderByTo.java
index f96b6d7c3..776caf34a 100644
--- a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/OrderByTo.java
+++ b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/OrderByTo.java
@@ -4,7 +4,10 @@
/**
* Transfer object to transmit order criteria
+ *
+ * @deprecated use org.springframework.data.domain.Sort instead
*/
+@Deprecated
public class OrderByTo extends AbstractTo {
private static final long serialVersionUID = 1L;
@@ -22,9 +25,30 @@ public OrderByTo() {
}
/**
- * Returns the field 'name'.
+ * The constructor.
+ *
+ * @param name the {@link #getName() field name}.
+ */
+ public OrderByTo(String name) {
+
+ this(name, OrderDirection.ASC);
+ }
+
+ /**
+ * The constructor.
*
- * @return Value of name
+ * @param name the {@link #getName() field name}.
+ * @param direction the {@link #getDirection() sort order direction}.
+ */
+ public OrderByTo(String name, OrderDirection direction) {
+
+ super();
+ this.name = name;
+ this.direction = direction;
+ }
+
+ /**
+ * @return the name of the field to order by.
*/
public String getName() {
@@ -32,9 +56,7 @@ public String getName() {
}
/**
- * Sets the field 'name'.
- *
- * @param name New value for name
+ * @param name the new value of {@link #getName()}.
*/
public void setName(String name) {
@@ -42,19 +64,18 @@ public void setName(String name) {
}
/**
- * Returns the field 'direction'.
- *
- * @return Value of direction
+ * @return the {@link OrderDirection} defining the sort order direction.
*/
public OrderDirection getDirection() {
+ if (this.direction == null) {
+ return OrderDirection.ASC;
+ }
return this.direction;
}
/**
- * Sets the field 'direction'.
- *
- * @param direction New value for direction
+ * @param direction the new value of {@link #getDirection()}.
*/
public void setDirection(OrderDirection direction) {
diff --git a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/OrderDirection.java b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/OrderDirection.java
index 15fa1d734..04a4457e9 100644
--- a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/OrderDirection.java
+++ b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/OrderDirection.java
@@ -2,7 +2,8 @@
/**
* {@link Enum} for sort order.
- *
+ *
+ * @deprecated user org.springframework.data.domain.Sort.Direction instead
*/
public enum OrderDirection {
diff --git a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginatedListTo.java b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginatedListTo.java
index 5ba3808af..6e726e98a 100644
--- a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginatedListTo.java
+++ b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginatedListTo.java
@@ -13,7 +13,9 @@
* @param is the generic type of the objects. Will usually be a {@link PersistenceEntity persistent entity} when
* used in the data layer, or a {@link TransferObject transfer object}.
*
+ * @deprecated use org.springframework.data.domain.Page instead.
*/
+@Deprecated
public class PaginatedListTo extends AbstractTo {
/** UID for serialization. */
@@ -29,6 +31,7 @@ public class PaginatedListTo extends AbstractTo {
* The constructor.
*/
public PaginatedListTo() {
+
super();
}
diff --git a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginationResultTo.java b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginationResultTo.java
index eaa106aa0..445363ab4 100644
--- a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginationResultTo.java
+++ b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginationResultTo.java
@@ -7,7 +7,9 @@
/**
* Pagination information about a paginated query.
*
+ * @deprecated use org.springframework.data.domain.Page instead.
*/
+@Deprecated
public class PaginationResultTo extends AbstractTo {
/** UID for serialization. */
@@ -26,6 +28,7 @@ public class PaginationResultTo extends AbstractTo {
* The constructor.
*/
public PaginationResultTo() {
+
super();
}
diff --git a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginationTo.java b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginationTo.java
index b0b9e569d..683681eeb 100644
--- a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginationTo.java
+++ b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/PaginationTo.java
@@ -1,14 +1,16 @@
package io.oasp.module.jpa.common.api.to;
-import io.oasp.module.basic.common.api.to.AbstractTo;
-
import net.sf.mmm.util.exception.api.NlsIllegalArgumentException;
+import io.oasp.module.basic.common.api.to.AbstractTo;
+
/**
* A {@link net.sf.mmm.util.transferobject.api.TransferObject transfer-object} containing criteria for paginating
* queries.
*
+ * @deprecated use org.springframework.data.domain.Pageable instead.
*/
+@Deprecated
public class PaginationTo extends AbstractTo {
/**
diff --git a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/SearchCriteriaTo.java b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/SearchCriteriaTo.java
index 90eb686b5..5292e0dc4 100644
--- a/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/SearchCriteriaTo.java
+++ b/modules/jpa/src/main/java/io/oasp/module/jpa/common/api/to/SearchCriteriaTo.java
@@ -1,5 +1,6 @@
package io.oasp.module.jpa.common.api.to;
+import java.util.ArrayList;
import java.util.List;
import io.oasp.module.basic.common.api.to.AbstractTo;
@@ -12,7 +13,9 @@
* This interface only holds the necessary settings for the pagination part of a query. For your individual search, you
* extend {@link SearchCriteriaTo} to create a java bean with all the fields for your search.
*
+ * @deprecated create your own TO and use org.springframework.data.domain.Pageable for pagination
*/
+@Deprecated
public class SearchCriteriaTo extends AbstractTo {
/** UID for serialization. */
@@ -102,6 +105,18 @@ public List getSort() {
return this.sort;
}
+ /**
+ * @param orderBy the {@link OrderByTo} to add to {@link #getSort() sort}. {@link List} will be created if
+ * {@code null}.
+ */
+ public void addSort(OrderByTo orderBy) {
+
+ if (this.sort == null) {
+ this.sort = new ArrayList<>();
+ }
+ this.sort.add(orderBy);
+ }
+
/**
* @param sort Set the sort criterias list
*/
diff --git a/modules/jpa/src/main/java/io/oasp/module/jpa/common/base/LegacyDaoQuerySupport.java b/modules/jpa/src/main/java/io/oasp/module/jpa/common/base/LegacyDaoQuerySupport.java
new file mode 100644
index 000000000..b2861ab63
--- /dev/null
+++ b/modules/jpa/src/main/java/io/oasp/module/jpa/common/base/LegacyDaoQuerySupport.java
@@ -0,0 +1,194 @@
+package io.oasp.module.jpa.common.base;
+
+import java.util.List;
+
+import javax.persistence.Query;
+
+import net.sf.mmm.util.search.base.AbstractSearchCriteria;
+
+import com.querydsl.core.types.Expression;
+import com.querydsl.jpa.impl.JPAQuery;
+
+import io.oasp.module.jpa.common.api.to.PaginatedListTo;
+import io.oasp.module.jpa.common.api.to.PaginationResultTo;
+import io.oasp.module.jpa.common.api.to.PaginationTo;
+import io.oasp.module.jpa.common.api.to.SearchCriteriaTo;
+
+/**
+ * @deprecated wird nur bereitgestellt, um die alte Funktionalität aus AbstractGenericDao für SearchCriteriaTo und die
+ * Paginierung temporär beibehalten zu können. Dieses Modul {@code oasp4j-jpa} wird in Zukunft nicht mehr
+ * unterstützt.
+ */
+@Deprecated
+public class LegacyDaoQuerySupport {
+
+ /**
+ * Returns a paginated list of entities according to the supplied {@link SearchCriteriaTo criteria}.
+ *
+ * @see #findPaginated(SearchCriteriaTo, JPAQuery, Expression)
+ *
+ * @param type to query
+ * @param criteria contains information about the requested page.
+ * @param query is a query which is preconfigured with the desired conditions for the search.
+ * @return a paginated list.
+ */
+ public static PaginatedListTo findPaginated(SearchCriteriaTo criteria, JPAQuery query) {
+
+ return findPaginated(criteria, query, null);
+ }
+
+ /**
+ * Returns a paginated list of entities according to the supplied {@link SearchCriteriaTo criteria}.
+ *
+ * Applies {@code limit} and {@code offset} values to the supplied {@code query} according to the supplied
+ * {@link PaginationTo pagination} information inside {@code criteria}.
+ *
+ * If a {@link PaginationTo#isTotal() total count} of available entities is requested, will also execute a second
+ * query, without pagination parameters applied, to obtain said count.
+ *
+ * Will install a query timeout if {@link SearchCriteriaTo#getSearchTimeout()} is not null.
+ *
+ * @param type to query
+ * @param criteria contains information about the requested page.
+ * @param query is a query which is preconfigured with the desired conditions for the search.
+ * @param expr is used for the final mapping from the SQL result to the entities.
+ * @return a paginated list.
+ */
+ @SuppressWarnings("unchecked")
+ public static PaginatedListTo findPaginated(SearchCriteriaTo criteria, JPAQuery> query, Expression expr) {
+
+ applyCriteria(criteria, query);
+
+ PaginationTo pagination = criteria.getPagination();
+
+ PaginationResultTo paginationResult = createPaginationResult(pagination, query);
+
+ applyPagination(pagination, query);
+ JPAQuery finalQuery;
+ if (expr == null) {
+ finalQuery = (JPAQuery) query;
+ } else {
+ finalQuery = query.select(expr);
+ }
+ List paginatedList = finalQuery.fetch();
+
+ return new PaginatedListTo<>(paginatedList, paginationResult);
+ }
+
+ /**
+ * Creates a {@link PaginationResultTo pagination result} for the given {@code pagination} and {@code query}.
+ *
+ * Needs to be called before pagination is applied to the {@code query}.
+ *
+ * @param pagination contains information about the requested page.
+ * @param query is a query preconfigured with the desired conditions for the search.
+ * @return information about the applied pagination.
+ */
+ protected static PaginationResultTo createPaginationResult(PaginationTo pagination, JPAQuery> query) {
+
+ Long total = calculateTotalBeforePagination(pagination, query);
+
+ return new PaginationResultTo(pagination, total);
+ }
+
+ /**
+ * Calculates the total number of entities the given {@link JPAQuery query} would return without pagination applied.
+ *
+ * Needs to be called before pagination is applied to the {@code query}.
+ *
+ * @param pagination is the pagination information as requested by the client.
+ * @param query is the {@link JPAQuery query} for which to calculate the total.
+ * @return the total count, or {@literal null} if {@link PaginationTo#isTotal()} is {@literal false}.
+ */
+ protected static Long calculateTotalBeforePagination(PaginationTo pagination, JPAQuery> query) {
+
+ Long total = null;
+ if (pagination.isTotal()) {
+ total = query.clone().fetchCount();
+ }
+
+ return total;
+ }
+
+ /**
+ * Applies the {@link PaginationTo pagination criteria} to the given {@link JPAQuery}.
+ *
+ * @param pagination is the {@link PaginationTo pagination criteria} to apply.
+ * @param query is the {@link JPAQuery} to apply to.
+ */
+ public static void applyPagination(PaginationTo pagination, JPAQuery> query) {
+
+ if (pagination == PaginationTo.NO_PAGINATION) {
+ return;
+ }
+
+ Integer limit = pagination.getSize();
+ if (limit != null) {
+ query.limit(limit);
+
+ int page = pagination.getPage();
+ if (page > 0) {
+ query.offset((page - 1) * limit);
+ }
+ }
+ }
+
+ /**
+ * Applies the meta-data of the given {@link AbstractSearchCriteria search criteria} to the given {@link JPAQuery}.
+ *
+ * @param criteria is the {@link AbstractSearchCriteria search criteria} to apply.
+ * @param query is the {@link JPAQuery} to apply to.
+ */
+ protected static void applyCriteria(AbstractSearchCriteria criteria, JPAQuery> query) {
+
+ Integer limit = criteria.getMaximumHitCount();
+ if (limit != null) {
+ query.limit(limit);
+ }
+ int offset = criteria.getHitOffset();
+ if (offset > 0) {
+ query.offset(offset);
+ }
+ Long timeout = criteria.getSearchTimeout();
+ if (timeout != null) {
+ query.setHint("javax.persistence.query.timeout", timeout.intValue());
+ }
+ }
+
+ /**
+ * Applies the meta-data of the given {@link AbstractSearchCriteria search criteria} to the given {@link Query}.
+ *
+ * @param criteria is the {@link AbstractSearchCriteria search criteria} to apply.
+ * @param query is the {@link Query} to apply to.
+ */
+ protected static void applyCriteria(AbstractSearchCriteria criteria, Query query) {
+
+ Integer limit = criteria.getMaximumHitCount();
+ if (limit != null) {
+ query.setMaxResults(limit);
+ }
+ int offset = criteria.getHitOffset();
+ if (offset > 0) {
+ query.setFirstResult(offset);
+ }
+ Long timeout = criteria.getSearchTimeout();
+ if (timeout != null) {
+ query.setHint("javax.persistence.query.timeout", timeout.intValue());
+ }
+ }
+
+ /**
+ * Applies the meta-data of the given {@link SearchCriteriaTo search criteria} to the given {@link Query}.
+ *
+ * @param criteria is the {@link AbstractSearchCriteria search criteria} to apply.
+ * @param query is the {@link JPAQuery} to apply to.
+ */
+ protected static void applyCriteria(SearchCriteriaTo criteria, JPAQuery> query) {
+
+ Integer timeout = criteria.getSearchTimeout();
+ if (timeout != null) {
+ query.setHint("javax.persistence.query.timeout", timeout.intValue());
+ }
+ }
+
+}
diff --git a/modules/jpa/src/main/java/io/oasp/module/jpa/dataaccess/api/MutablePersistenceEntity.java b/modules/jpa/src/main/java/io/oasp/module/jpa/dataaccess/api/MutablePersistenceEntity.java
deleted file mode 100644
index f5a173354..000000000
--- a/modules/jpa/src/main/java/io/oasp/module/jpa/dataaccess/api/MutablePersistenceEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
- * http://www.apache.org/licenses/LICENSE-2.0 */
-package io.oasp.module.jpa.dataaccess.api;
-
-import net.sf.mmm.util.entity.api.MutableGenericEntity;
-import net.sf.mmm.util.entity.api.PersistenceEntity;
-
-/**
- * This is the interface for a {@link PersistenceEntity} in OASP.
- *
- * @param is the type of the {@link #getId() primary key}.
- *
- * @see AbstractPersistenceEntity
- *
- */
-public interface MutablePersistenceEntity extends PersistenceEntity, MutableGenericEntity {
-
- /**
- * This method sets the {@link #getRevision() revision} of this entity.
- * ATTENTION:
- * This operation should only be used in specific cases and if you are aware of what you are doing as this attribute
- * is managed by the persistence. However, for final freedom we decided to add this method to the API (e.g. to copy
- * from transfer-object to persistent-entity and vice-versa).
- *
- * @param revision is the new value of {@link #getRevision()}.
- */
- void setRevision(Number revision);
-
-}
diff --git a/modules/jpa/src/main/java/io/oasp/module/jpa/dataaccess/base/AbstractGenericDao.java b/modules/jpa/src/main/java/io/oasp/module/jpa/dataaccess/base/AbstractGenericDao.java
deleted file mode 100644
index 544e22f23..000000000
--- a/modules/jpa/src/main/java/io/oasp/module/jpa/dataaccess/base/AbstractGenericDao.java
+++ /dev/null
@@ -1,372 +0,0 @@
-package io.oasp.module.jpa.dataaccess.base;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityNotFoundException;
-import javax.persistence.LockModeType;
-import javax.persistence.PersistenceContext;
-import javax.persistence.Query;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Root;
-
-import net.sf.mmm.util.entity.api.PersistenceEntity;
-import net.sf.mmm.util.exception.api.ObjectNotFoundUserException;
-import net.sf.mmm.util.search.base.AbstractSearchCriteria;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.mysema.query.jpa.impl.JPAQuery;
-import com.mysema.query.types.Expression;
-
-import io.oasp.module.basic.common.api.reference.Ref;
-import io.oasp.module.jpa.common.api.to.PaginatedListTo;
-import io.oasp.module.jpa.common.api.to.PaginationResultTo;
-import io.oasp.module.jpa.common.api.to.PaginationTo;
-import io.oasp.module.jpa.common.api.to.SearchCriteriaTo;
-import io.oasp.module.jpa.dataaccess.api.GenericDao;
-
-/**
- * This is the abstract base-implementation of the {@link GenericDao} interface.
- *
- * @param is the generic type if the {@link PersistenceEntity#getId() primary key}.
- * @param is the generic type of the managed {@link PersistenceEntity}.
- *
- */
-// @Repository
-public abstract class AbstractGenericDao> implements GenericDao {
-
- /** Logger instance. */
- private static final Logger LOG = LoggerFactory.getLogger(AbstractGenericDao.class);
-
- private EntityManager entityManager;
-
- /**
- * The constructor.
- */
- public AbstractGenericDao() {
-
- super();
- }
-
- /**
- * @return the {@link Class} reflecting the managed entity.
- */
- protected abstract Class getEntityClass();
-
- /**
- * @return the {@link EntityManager} instance.
- */
- protected EntityManager getEntityManager() {
-
- return this.entityManager;
- }
-
- /**
- * @param entityManager the {@link EntityManager} to inject.
- */
- @PersistenceContext
- public void setEntityManager(EntityManager entityManager) {
-
- this.entityManager = entityManager;
- }
-
- /**
- * @return the name of the managed entity.
- */
- protected String getEntityName() {
-
- return getEntityClass().getSimpleName();
- }
-
- @Override
- public E save(E entity) {
-
- if (isNew(entity)) {
- getEntityManager().persist(entity);
- LOG.debug("Saved new {} with id {}.", getEntityName(), entity.getId());
- return entity;
- } else {
- if (getEntityManager().find(entity.getClass(), entity.getId()) != null) {
- E update = getEntityManager().merge(entity);
- LOG.debug("Updated {} with id {}.", getEntityName(), entity.getId());
- return update;
- } else {
- throw new EntityNotFoundException("Entity not found");
- }
- }
- }
-
- /**
- * Determines if the given {@link PersistenceEntity} is {@link PersistenceEntity#STATE_NEW new}.
- *
- * @param entity is the {@link PersistenceEntity} to check.
- * @return {@code true} if {@link PersistenceEntity#STATE_NEW new}, {@code false} otherwise (e.g.
- * {@link PersistenceEntity#STATE_DETACHED detached} or {@link PersistenceEntity#STATE_MANAGED managed}.
- */
- protected boolean isNew(E entity) {
-
- return entity.getId() == null;
- }
-
- @Override
- public void save(Iterable extends E> entities) {
-
- for (E entity : entities) {
- save(entity);
- }
- }
-
- @Override
- public void forceIncrementModificationCounter(E entity) {
-
- getEntityManager().lock(entity, LockModeType.OPTIMISTIC_FORCE_INCREMENT);
- }
-
- @Override
- public E findOne(ID id) {
-
- E entity = getEntityManager().find(getEntityClass(), id);
- return entity;
- }
-
- @Override
- public E find(ID id) throws ObjectNotFoundUserException {
-
- E entity = findOne(id);
- if (entity == null) {
- throw new ObjectNotFoundUserException(getEntityClass().getSimpleName(), id);
- }
- return entity;
- }
-
- @Override
- public E get(Ref reference) {
-
- if (reference == null) {
- return null;
- }
- return getEntityManager().getReference(getEntityClass(), reference.getId());
- }
-
- @Override
- public boolean exists(ID id) {
-
- // pointless...
- return findOne(id) != null;
- }
-
- /**
- * @return an {@link Iterable} to find ALL {@link #getEntityClass() managed entities} from the persistent store. Not
- * exposed to API by default as this might not make sense for all kind of entities.
- */
- public List findAll() {
-
- CriteriaQuery query = getEntityManager().getCriteriaBuilder().createQuery(getEntityClass());
- Root root = query.from(getEntityClass());
- query.select(root);
- TypedQuery typedQuery = getEntityManager().createQuery(query);
- List resultList = typedQuery.getResultList();
- LOG.debug("Query for all {} objects returned {} hit(s).", getEntityName(), resultList.size());
- return resultList;
- }
-
- @Override
- public List findAll(Iterable ids) {
-
- CriteriaBuilder builder = getEntityManager().getCriteriaBuilder();
- CriteriaQuery query = builder.createQuery(getEntityClass());
- Root root = query.from(getEntityClass());
- query.select(root);
- query.where(root.get("id").in(ids));
- TypedQuery typedQuery = getEntityManager().createQuery(query);
- List resultList = typedQuery.getResultList();
- LOG.debug("Query for selection of {} objects returned {} hit(s).", getEntityName(), resultList.size());
- return resultList;
- }
-
- @Override
- public void delete(ID id) {
-
- E entity = getEntityManager().getReference(getEntityClass(), id);
- getEntityManager().remove(entity);
- LOG.debug("Deleted {} with ID {}.", getEntityName(), id);
- }
-
- @Override
- public void delete(E entity) {
-
- // entity might be detached and could cause trouble in entityManager on remove
- if (getEntityManager().contains(entity)) {
- getEntityManager().remove(entity);
- LOG.debug("Deleted {} with ID {}.", getEntityName(), entity.getId());
- } else {
- delete(entity.getId());
- }
-
- }
-
- @Override
- public void delete(Iterable extends E> entities) {
-
- for (E entity : entities) {
- delete(entity);
- }
- }
-
- @SuppressWarnings("javadoc")
- protected PaginatedListTo findPaginated(SearchCriteriaTo criteria, Query query, Expression expr) {
-
- throw new UnsupportedOperationException("Pagination is not yet supported for generic JPA queries.");
- }
-
- /**
- * Returns a paginated list of entities according to the supplied {@link SearchCriteriaTo criteria}.
- *
- * Applies {@code limit} and {@code offset} values to the supplied {@code query} according to the supplied
- * {@link PaginationTo pagination} information inside {@code criteria}.
- *
- * If a {@link PaginationTo#isTotal() total count} of available entities is requested, will also execute a second
- * query, without pagination parameters applied, to obtain said count.
- *
- * Will install a query timeout if {@link SearchCriteriaTo#getSearchTimeout()} is not null.
- *
- * @param criteria contains information about the requested page.
- * @param query is a query which is preconfigured with the desired conditions for the search.
- * @param expr is used for the final mapping from the SQL result to the entities.
- * @return a paginated list.
- */
- protected PaginatedListTo findPaginated(SearchCriteriaTo criteria, JPAQuery query, Expression expr) {
-
- applyCriteria(criteria, query);
-
- PaginationTo pagination = criteria.getPagination();
-
- PaginationResultTo paginationResult = createPaginationResult(pagination, query);
-
- applyPagination(pagination, query);
- List paginatedList = query.list(expr);
-
- return new PaginatedListTo<>(paginatedList, paginationResult);
- }
-
- /**
- * Creates a {@link PaginationResultTo pagination result} for the given {@code pagination} and {@code query}.
- *
- * Needs to be called before pagination is applied to the {@code query}.
- *
- * @param pagination contains information about the requested page.
- * @param query is a query preconfigured with the desired conditions for the search.
- * @return information about the applied pagination.
- */
- protected PaginationResultTo createPaginationResult(PaginationTo pagination, JPAQuery query) {
-
- Long total = calculateTotalBeforePagination(pagination, query);
-
- return new PaginationResultTo(pagination, total);
- }
-
- /**
- * Calculates the total number of entities the given {@link JPAQuery query} would return without pagination applied.
- *
- * Needs to be called before pagination is applied to the {@code query}.
- *
- * @param pagination is the pagination information as requested by the client.
- * @param query is the {@link JPAQuery query} for which to calculate the total.
- * @return the total count, or {@literal null} if {@link PaginationTo#isTotal()} is {@literal false}.
- */
- protected Long calculateTotalBeforePagination(PaginationTo pagination, JPAQuery query) {
-
- Long total = null;
- if (pagination.isTotal()) {
- total = query.clone().count();
- }
-
- return total;
- }
-
- /**
- * Applies the {@link PaginationTo pagination criteria} to the given {@link JPAQuery}.
- *
- * @param pagination is the {@link PaginationTo pagination criteria} to apply.
- * @param query is the {@link JPAQuery} to apply to.
- */
- protected void applyPagination(PaginationTo pagination, JPAQuery query) {
-
- if (pagination == PaginationTo.NO_PAGINATION) {
- return;
- }
-
- Integer limit = pagination.getSize();
- if (limit != null) {
- query.limit(limit);
-
- int page = pagination.getPage();
- if (page > 0) {
- query.offset((page - 1) * limit);
- }
- }
- }
-
- /**
- * Applies the meta-data of the given {@link AbstractSearchCriteria search criteria} to the given {@link JPAQuery}.
- *
- * @param criteria is the {@link AbstractSearchCriteria search criteria} to apply.
- * @param query is the {@link JPAQuery} to apply to.
- */
- protected void applyCriteria(AbstractSearchCriteria criteria, JPAQuery query) {
-
- Integer limit = criteria.getMaximumHitCount();
- if (limit != null) {
- query.limit(limit);
- }
- int offset = criteria.getHitOffset();
- if (offset > 0) {
- query.offset(offset);
- }
- Long timeout = criteria.getSearchTimeout();
- if (timeout != null) {
- query.setHint("javax.persistence.query.timeout", timeout.intValue());
- }
- }
-
- /**
- * Applies the meta-data of the given {@link AbstractSearchCriteria search criteria} to the given {@link Query}.
- *
- * @param criteria is the {@link AbstractSearchCriteria search criteria} to apply.
- * @param query is the {@link Query} to apply to.
- */
- protected void applyCriteria(AbstractSearchCriteria criteria, Query query) {
-
- Integer limit = criteria.getMaximumHitCount();
- if (limit != null) {
- query.setMaxResults(limit);
- }
- int offset = criteria.getHitOffset();
- if (offset > 0) {
- query.setFirstResult(offset);
- }
- Long timeout = criteria.getSearchTimeout();
- if (timeout != null) {
- query.setHint("javax.persistence.query.timeout", timeout.intValue());
- }
- }
-
- /**
- * Applies the meta-data of the given {@link SearchCriteriaTo search criteria} to the given {@link Query}.
- *
- * @param criteria is the {@link AbstractSearchCriteria search criteria} to apply.
- * @param query is the {@link JPAQuery} to apply to.
- */
- protected void applyCriteria(SearchCriteriaTo criteria, JPAQuery query) {
-
- Integer timeout = criteria.getSearchTimeout();
- if (timeout != null) {
- query.setHint("javax.persistence.query.timeout", timeout.intValue());
- }
- }
-
-}
diff --git a/modules/pom.xml b/modules/pom.xml
index 3e7d99fbb..36fec2956 100644
--- a/modules/pom.xml
+++ b/modules/pom.xml
@@ -28,7 +28,10 @@
cxf-server-wssecurityjpa
+ jpa-basic
+ jpa-daojpa-envers
+ jpa-spring-datatest-jpabatchweb
diff --git a/modules/security/src/main/java/io/oasp/module/security/common/base/accesscontrol/AbstractAccessControlProvider.java b/modules/security/src/main/java/io/oasp/module/security/common/base/accesscontrol/AbstractAccessControlProvider.java
index ec85c7fe7..fa637a8ae 100644
--- a/modules/security/src/main/java/io/oasp/module/security/common/base/accesscontrol/AbstractAccessControlProvider.java
+++ b/modules/security/src/main/java/io/oasp/module/security/common/base/accesscontrol/AbstractAccessControlProvider.java
@@ -8,6 +8,7 @@
import net.sf.mmm.util.collection.base.NodeCycle;
import net.sf.mmm.util.collection.base.NodeCycleException;
+import net.sf.mmm.util.exception.api.DuplicateObjectException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -127,6 +128,26 @@ public AccessControl getAccessControl(String nodeId) {
return this.id2nodeMap.get(nodeId);
}
+ /**
+ * Registers the given {@link AccessControl} and may be used for configuration of access controls during
+ * bootstrapping. This method should not be used after the application startup (bootstrapping) has completed.
+ *
+ * @param accessControl the {@link AccessControl} to register.
+ */
+ protected void addAccessControl(AccessControl accessControl) {
+
+ String id = accessControl.getId();
+ AccessControl existing = this.id2nodeMap.get(id);
+ if (existing == null) {
+ this.id2nodeMap.put(id, accessControl);
+ LOG.debug("Registered access control {}", accessControl);
+ } else if (existing == accessControl) {
+ LOG.debug("Access control {} was already registered.", accessControl);
+ } else {
+ throw new DuplicateObjectException(accessControl, id, existing);
+ }
+ }
+
@Override
public boolean collectAccessControlIds(String groupId, Set permissions) {
diff --git a/modules/security/src/main/java/io/oasp/module/security/common/base/accesscontrol/AccessControlConfig.java b/modules/security/src/main/java/io/oasp/module/security/common/base/accesscontrol/AccessControlConfig.java
new file mode 100644
index 000000000..fef8ae339
--- /dev/null
+++ b/modules/security/src/main/java/io/oasp/module/security/common/base/accesscontrol/AccessControlConfig.java
@@ -0,0 +1,92 @@
+package io.oasp.module.security.common.base.accesscontrol;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sf.mmm.util.exception.api.DuplicateObjectException;
+
+import io.oasp.module.security.common.api.accesscontrol.AccessControl;
+import io.oasp.module.security.common.api.accesscontrol.AccessControlGroup;
+import io.oasp.module.security.common.api.accesscontrol.AccessControlPermission;
+
+/**
+ * {@link AbstractAccessControlProvider} for static configuration of
+ * {@link io.oasp.module.security.common.api.accesscontrol.AccessControlSchema}. Instead of maintaining it as XML file
+ * you can directly configure it as code and therefore define and reference constants in annotations such as
+ * {@link javax.annotation.security.RolesAllowed}.
+ *
+ * @since 3.0.0
+ */
+public abstract class AccessControlConfig extends AbstractAccessControlProvider {
+
+ /**
+ * Creates a new {@link AccessControlPermission} for static configuration of access controls.
+ *
+ * @param id {@link AccessControlPermission#getId() ID} of {@link AccessControlPermission} to get or create.
+ * @return the existing {@link AccessControlPermission} for the given {@link AccessControlPermission#getId() ID} or a
+ * newly created and registered {@link AccessControlPermission}.
+ */
+ protected AccessControlPermission permission(String id) {
+
+ AccessControl accessControl = getAccessControl(id);
+ if (accessControl instanceof AccessControlPermission) {
+ return (AccessControlPermission) accessControl;
+ } else if (accessControl != null) {
+ throw new DuplicateObjectException(AccessControlPermission.class.getSimpleName(), id, accessControl);
+ }
+ AccessControlPermission permission = new AccessControlPermission(id);
+ addAccessControl(permission);
+ return permission;
+ }
+
+ /**
+ * Creates a new {@link AccessControlGroup} for static configuration of access controls.
+ *
+ * @param groupId {@link AccessControlGroup#getId() ID} of {@link AccessControlGroup} to create.
+ * @param permissionIds {@link AccessControlPermission#getId() ID}s of the {@link #permission(String) permissions} to
+ * {@link AccessControlGroup#getPermissions() use}.
+ * @return the newly created and registered {@link AccessControlGroup}.
+ */
+ protected AccessControlGroup group(String groupId, String... permissionIds) {
+
+ return group(groupId, Collections. emptyList(), permissionIds);
+ }
+
+ /**
+ * Creates a new {@link AccessControlGroup} for static configuration of access controls.
+ *
+ * @param groupId {@link AccessControlGroup#getId() ID} of {@link AccessControlGroup} to create.
+ * @param inherit single {@link AccessControlGroup} to {@link AccessControlGroup#getInherits() inherit}.
+ * @param permissionIds {@link AccessControlPermission#getId() ID}s of the {@link #permission(String) permissions} to
+ * {@link AccessControlGroup#getPermissions() use}.
+ * @return the newly created and registered {@link AccessControlGroup}.
+ */
+ protected AccessControlGroup group(String groupId, AccessControlGroup inherit, String... permissionIds) {
+
+ return group(groupId, Collections.singletonList(inherit), permissionIds);
+ }
+
+ /**
+ * Creates a new {@link AccessControlGroup} for static configuration of access controls.
+ *
+ * @param groupId {@link AccessControlGroup#getId() ID} of {@link AccessControlGroup} to create.
+ * @param inherits {@link List} of {@link AccessControlGroup} to {@link AccessControlGroup#getInherits() inherit}.
+ * @param permissionIds {@link AccessControlPermission#getId() ID}s of the {@link #permission(String) permissions} to
+ * {@link AccessControlGroup#getPermissions() use}.
+ * @return the newly created and registered {@link AccessControlGroup}.
+ */
+ protected AccessControlGroup group(String groupId, List inherits, String... permissionIds) {
+
+ AccessControlGroup group = new AccessControlGroup(groupId);
+ group.setInherits(inherits);
+ List permissions = new ArrayList<>(permissionIds.length);
+ for (String permissionId : permissionIds) {
+ permissions.add(permission(permissionId));
+ }
+ group.setPermissions(permissions);
+ addAccessControl(group);
+ return group;
+ }
+
+}
diff --git a/modules/security/src/test/java/io/oasp/module/security/common/impl/accesscontrol/AccessControlConfigSimple.java b/modules/security/src/test/java/io/oasp/module/security/common/impl/accesscontrol/AccessControlConfigSimple.java
new file mode 100644
index 000000000..843ebfc43
--- /dev/null
+++ b/modules/security/src/test/java/io/oasp/module/security/common/impl/accesscontrol/AccessControlConfigSimple.java
@@ -0,0 +1,89 @@
+package io.oasp.module.security.common.impl.accesscontrol;
+
+import javax.inject.Named;
+
+import io.oasp.module.security.common.api.accesscontrol.AccessControlGroup;
+import io.oasp.module.security.common.base.accesscontrol.AccessControlConfig;
+
+/**
+ * Example of {@link AccessControlConfig} that used for testing.
+ */
+@Named
+public class AccessControlConfigSimple extends AccessControlConfig {
+
+ public static final String APP_ID = "MyApp";
+
+ private static final String PREFIX = APP_ID + ".";
+
+ public static final String PERMISSION_FIND_OFFER = PREFIX + "FindOffer";
+
+ public static final String PERMISSION_SAVE_OFFER = PREFIX + "SaveOffer";
+
+ public static final String PERMISSION_DELETE_OFFER = PREFIX + "DeleteOffer";
+
+ public static final String PERMISSION_FIND_PRODUCT = PREFIX + "FindProduct";
+
+ public static final String PERMISSION_SAVE_PRODUCT = PREFIX + "SaveProduct";
+
+ public static final String PERMISSION_DELETE_PRODUCT = PREFIX + "DeleteProduct";
+
+ public static final String PERMISSION_FIND_TABLE = PREFIX + "FindTable";
+
+ public static final String PERMISSION_SAVE_TABLE = PREFIX + "SaveTable";
+
+ public static final String PERMISSION_DELETE_TABLE = PREFIX + "DeleteTable";
+
+ public static final String PERMISSION_FIND_STAFF_MEMBER = PREFIX + "FindStaffMember";
+
+ public static final String PERMISSION_SAVE_STAFF_MEMBER = PREFIX + "SaveStaffMember";
+
+ public static final String PERMISSION_DELETE_STAFF_MEMBER = PREFIX + "DeleteStaffMember";
+
+ public static final String PERMISSION_FIND_ORDER = PREFIX + "FindOrder";
+
+ public static final String PERMISSION_SAVE_ORDER = PREFIX + "SaveOrder";
+
+ public static final String PERMISSION_DELETE_ORDER = PREFIX + "DeleteOrder";
+
+ public static final String PERMISSION_FIND_ORDER_POSITION = PREFIX + "FindOrderPosition";
+
+ public static final String PERMISSION_SAVE_ORDER_POSITION = PREFIX + "SaveOrderPosition";
+
+ public static final String PERMISSION_DELETE_ORDER_POSITION = PREFIX + "DeleteOrderPosition";
+
+ public static final String PERMISSION_FIND_BILL = PREFIX + "FindBill";
+
+ public static final String PERMISSION_SAVE_BILL = PREFIX + "SaveBill";
+
+ public static final String PERMISSION_DELETE_BILL = PREFIX + "DeleteBill";
+
+ public static final String GROUP_READ_MASTER_DATA = PREFIX + "ReadMasterData";
+
+ public static final String GROUP_COOK = PREFIX + "Cook";
+
+ public static final String GROUP_BARKEEPER = PREFIX + "Barkeeper";
+
+ public static final String GROUP_WAITER = PREFIX + "Waiter";
+
+ public static final String GROUP_CHIEF = PREFIX + "Chief";
+
+ /**
+ * The constructor.
+ */
+ public AccessControlConfigSimple() {
+
+ super();
+ AccessControlGroup readMasterData = group(GROUP_READ_MASTER_DATA, PERMISSION_FIND_OFFER, PERMISSION_FIND_PRODUCT,
+ PERMISSION_FIND_STAFF_MEMBER, PERMISSION_FIND_TABLE);
+ AccessControlGroup cook = group(GROUP_COOK, readMasterData, PERMISSION_FIND_ORDER, PERMISSION_SAVE_ORDER,
+ PERMISSION_FIND_ORDER_POSITION, PERMISSION_SAVE_ORDER_POSITION);
+ AccessControlGroup barkeeper = group(GROUP_BARKEEPER, cook, PERMISSION_FIND_BILL, PERMISSION_SAVE_BILL,
+ PERMISSION_DELETE_BILL, PERMISSION_DELETE_ORDER);
+ AccessControlGroup waiter = group(GROUP_WAITER, barkeeper, PERMISSION_SAVE_TABLE);
+ // AccessControlGroup chief =
+ group(GROUP_CHIEF, waiter, PERMISSION_SAVE_OFFER, PERMISSION_SAVE_PRODUCT, PERMISSION_SAVE_STAFF_MEMBER,
+ PERMISSION_DELETE_OFFER, PERMISSION_DELETE_PRODUCT, PERMISSION_DELETE_STAFF_MEMBER,
+ PERMISSION_DELETE_ORDER_POSITION, PERMISSION_DELETE_TABLE);
+ }
+
+}
\ No newline at end of file
diff --git a/modules/security/src/test/java/io/oasp/module/security/common/impl/accesscontrol/AccessControlConfigTest.java b/modules/security/src/test/java/io/oasp/module/security/common/impl/accesscontrol/AccessControlConfigTest.java
new file mode 100644
index 000000000..c2a844eb0
--- /dev/null
+++ b/modules/security/src/test/java/io/oasp/module/security/common/impl/accesscontrol/AccessControlConfigTest.java
@@ -0,0 +1,147 @@
+package io.oasp.module.security.common.impl.accesscontrol;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.security.RolesAllowed;
+
+import org.junit.Test;
+
+import io.oasp.module.security.common.api.accesscontrol.AccessControl;
+import io.oasp.module.security.common.api.accesscontrol.AccessControlGroup;
+import io.oasp.module.security.common.base.accesscontrol.AccessControlConfig;
+import io.oasp.module.test.common.base.ModuleTest;
+
+/**
+ * Test of {@link AccessControlConfig}.
+ */
+public class AccessControlConfigTest extends ModuleTest {
+
+ /**
+ * Test of {@link AccessControlConfig#getAccessControl(String)} with top-level chief group.
+ */
+ @Test
+ // @RolesAllowed only used to ensure that the constant can be referenced here
+ @RolesAllowed(AccessControlConfigSimple.PERMISSION_FIND_TABLE)
+ public void testGetAccessControl() {
+
+ // given
+ AccessControlConfigSimple config = new AccessControlConfigSimple();
+ String groupChief = AccessControlConfigSimple.GROUP_CHIEF;
+
+ // when
+ AccessControlGroup chief = (AccessControlGroup) config.getAccessControl(groupChief);
+
+ // then
+ assertThat(chief).isNotNull();
+ assertThat(chief.getId()).isEqualTo(groupChief);
+ assertThat(flatten(chief.getPermissions())).containsExactlyInAnyOrder(
+ AccessControlConfigSimple.PERMISSION_SAVE_OFFER, AccessControlConfigSimple.PERMISSION_SAVE_PRODUCT,
+ AccessControlConfigSimple.PERMISSION_SAVE_STAFF_MEMBER, AccessControlConfigSimple.PERMISSION_DELETE_OFFER,
+ AccessControlConfigSimple.PERMISSION_DELETE_PRODUCT, AccessControlConfigSimple.PERMISSION_DELETE_STAFF_MEMBER,
+ AccessControlConfigSimple.PERMISSION_DELETE_ORDER_POSITION, AccessControlConfigSimple.PERMISSION_DELETE_TABLE);
+ AccessControlGroup waiter = getSingleInherit(chief);
+ assertThat(waiter).isNotNull();
+ assertThat(waiter.getId()).isEqualTo(AccessControlConfigSimple.GROUP_WAITER);
+ assertThat(flatten(waiter.getPermissions()))
+ .containsExactlyInAnyOrder(AccessControlConfigSimple.PERMISSION_SAVE_TABLE);
+ AccessControlGroup barkeeper = getSingleInherit(waiter);
+ assertThat(barkeeper).isNotNull();
+ assertThat(barkeeper.getId()).isEqualTo(AccessControlConfigSimple.GROUP_BARKEEPER);
+ assertThat(flatten(barkeeper.getPermissions())).containsExactlyInAnyOrder(
+ AccessControlConfigSimple.PERMISSION_FIND_BILL, AccessControlConfigSimple.PERMISSION_SAVE_BILL,
+ AccessControlConfigSimple.PERMISSION_DELETE_BILL, AccessControlConfigSimple.PERMISSION_DELETE_ORDER);
+ AccessControlGroup cook = getSingleInherit(barkeeper);
+ assertThat(cook).isNotNull();
+ assertThat(cook.getId()).isEqualTo(AccessControlConfigSimple.GROUP_COOK);
+ assertThat(flatten(cook.getPermissions())).containsExactlyInAnyOrder(
+ AccessControlConfigSimple.PERMISSION_FIND_ORDER, AccessControlConfigSimple.PERMISSION_SAVE_ORDER,
+ AccessControlConfigSimple.PERMISSION_FIND_ORDER_POSITION,
+ AccessControlConfigSimple.PERMISSION_SAVE_ORDER_POSITION);
+ AccessControlGroup readMasterData = getSingleInherit(cook);
+ assertThat(readMasterData).isNotNull();
+ assertThat(readMasterData.getId()).isEqualTo(AccessControlConfigSimple.GROUP_READ_MASTER_DATA);
+ assertThat(flatten(readMasterData.getPermissions())).containsExactlyInAnyOrder(
+ AccessControlConfigSimple.PERMISSION_FIND_OFFER, AccessControlConfigSimple.PERMISSION_FIND_PRODUCT,
+ AccessControlConfigSimple.PERMISSION_FIND_STAFF_MEMBER, AccessControlConfigSimple.PERMISSION_FIND_TABLE);
+ assertThat(readMasterData.getInherits()).isEmpty();
+ }
+
+ /**
+ * Test of {@link AccessControlConfig#collectAccessControlIds(String, Set)} with
+ * {@link AccessControlConfigSimple#GROUP_READ_MASTER_DATA}.
+ */
+ @Test
+ public void testCollectAccessControlIds4ReadMasterData() {
+
+ // given
+ AccessControlConfigSimple config = new AccessControlConfigSimple();
+
+ // when
+ Set permissions = new HashSet<>();
+ config.collectAccessControlIds(AccessControlConfigSimple.GROUP_READ_MASTER_DATA, permissions);
+
+ // then
+ assertThat(permissions).containsExactlyInAnyOrder(AccessControlConfigSimple.GROUP_READ_MASTER_DATA,
+ AccessControlConfigSimple.PERMISSION_FIND_OFFER, AccessControlConfigSimple.PERMISSION_FIND_PRODUCT,
+ AccessControlConfigSimple.PERMISSION_FIND_STAFF_MEMBER, AccessControlConfigSimple.PERMISSION_FIND_TABLE);
+ }
+
+ /**
+ * Test of {@link AccessControlConfig#collectAccessControlIds(String, Set)} with
+ * {@link AccessControlConfigSimple#GROUP_CHIEF}.
+ */
+ @Test
+ public void testCollectAccessControlIds4Chief() {
+
+ // given
+ AccessControlConfigSimple config = new AccessControlConfigSimple();
+ String groupChief = AccessControlConfigSimple.GROUP_CHIEF;
+
+ // when
+ Set permissions = new HashSet<>();
+ config.collectAccessControlIds(groupChief, permissions);
+
+ // then
+ assertThat(permissions).containsExactlyInAnyOrder(AccessControlConfigSimple.GROUP_READ_MASTER_DATA,
+ AccessControlConfigSimple.PERMISSION_FIND_OFFER, AccessControlConfigSimple.PERMISSION_FIND_PRODUCT,
+ AccessControlConfigSimple.PERMISSION_FIND_STAFF_MEMBER, AccessControlConfigSimple.PERMISSION_FIND_TABLE,
+ //
+ AccessControlConfigSimple.GROUP_COOK, AccessControlConfigSimple.PERMISSION_FIND_ORDER,
+ AccessControlConfigSimple.PERMISSION_SAVE_ORDER, AccessControlConfigSimple.PERMISSION_FIND_ORDER_POSITION,
+ AccessControlConfigSimple.PERMISSION_SAVE_ORDER_POSITION,
+ //
+ AccessControlConfigSimple.GROUP_BARKEEPER, AccessControlConfigSimple.PERMISSION_FIND_BILL,
+ AccessControlConfigSimple.PERMISSION_SAVE_BILL, AccessControlConfigSimple.PERMISSION_DELETE_BILL,
+ AccessControlConfigSimple.PERMISSION_DELETE_ORDER,
+ //
+ AccessControlConfigSimple.GROUP_WAITER, AccessControlConfigSimple.PERMISSION_SAVE_TABLE,
+ //
+ groupChief, AccessControlConfigSimple.PERMISSION_SAVE_OFFER, AccessControlConfigSimple.PERMISSION_SAVE_PRODUCT,
+ AccessControlConfigSimple.PERMISSION_SAVE_STAFF_MEMBER, AccessControlConfigSimple.PERMISSION_DELETE_OFFER,
+ AccessControlConfigSimple.PERMISSION_DELETE_PRODUCT, AccessControlConfigSimple.PERMISSION_DELETE_STAFF_MEMBER,
+ AccessControlConfigSimple.PERMISSION_DELETE_ORDER_POSITION, AccessControlConfigSimple.PERMISSION_DELETE_TABLE);
+ }
+
+ private static AccessControlGroup getSingleInherit(AccessControlGroup group) {
+
+ List inherits = group.getInherits();
+ assertThat(inherits).hasSize(1);
+ AccessControlGroup inheritedGroup = inherits.get(0);
+ assertThat(inheritedGroup).isNotNull();
+ return inheritedGroup;
+ }
+
+ private static String[] flatten(Collection extends AccessControl> accessControlList) {
+
+ String[] ids = new String[accessControlList.size()];
+ int i = 0;
+ for (AccessControl accessControl : accessControlList) {
+ ids[i++] = accessControl.getId();
+ }
+ return ids;
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 4257e3be9..053f2c0ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
2014
- bom
+ bomsmodulesstarterstemplates
@@ -23,18 +23,10 @@
UTF-8UTF-83.0.0-SNAPSHOT
- 81oss1.5.3.RELEASE
- src/main/client
- OASP ${project.name} - Service Documentation
- This is the documentation of the REST-Services of ${project.name}.
- oasp-ci.cloudapp.net
- 80
-
- oasp4j-sample/services/rest
- 1.0.0-beta-3
-
+
+ 3.0.1
@@ -137,18 +129,38 @@
org.apache.maven.pluginsmaven-site-plugin
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ default-prepare-agent
+
+ prepare-agent
+
+
+
+ default-report
+
+ report
+
+
+
+ org.apache.maven.pluginsmaven-resources-plugin
- 2.7
+ 3.0.2org.apache.maven.pluginsmaven-compiler-plugin
- 3.2
+ 3.7.0org.apache.maven.plugins
@@ -163,27 +175,27 @@
org.apache.maven.pluginsmaven-clean-plugin
- 2.6
+ 3.0.0org.apache.maven.pluginsmaven-jar-plugin
- 2.5
+ 3.0.2org.apache.maven.pluginsmaven-source-plugin
- 2.4
+ 3.0.1org.apache.maven.pluginsmaven-site-plugin
- 3.4
+ 3.7org.apache.maven.pluginsmaven-checkstyle-plugin
- 2.9.1
+ 3.0.0org.apache.maven.plugins
@@ -193,17 +205,17 @@
org.apache.maven.pluginsmaven-project-info-reports-plugin
- 2.7
+ 2.9org.apache.maven.pluginsmaven-jxr-plugin
- 2.4
+ 2.5org.apache.maven.pluginsmaven-javadoc-plugin
- 2.9.1
+ 3.0.0
@@ -212,14 +224,15 @@
1.2
-
-
- true
+
+
private${project.reporting.outputEncoding}${project.build.sourceEncoding}true
- ${javadoc.params}
+
+ ${javadoc.option.doclint}
+
http://docs.oracle.com/javase/7/docs/api/
http://m-m-m.sourceforge.net/apidocs/
@@ -231,7 +244,7 @@
org.apache.maven.pluginsmaven-surefire-plugin
- 2.17
+ 2.20.1-Duser.language=en -Duser.region=EN
@@ -242,12 +255,12 @@
org.apache.maven.pluginsmaven-surefire-report-plugin
- 2.9
+ 2.20.1org.apache.maven.pluginsmaven-pmd-plugin
- 3.2
+ 3.9.0${java.version}
@@ -255,32 +268,37 @@
org.apache.maven.pluginsmaven-war-plugin
- 2.5
+ 3.2.0org.apache.maven.pluginsmaven-gpg-plugin
- 1.5
+ 1.6org.apache.maven.pluginsmaven-help-plugin2.2
+
+ org.apache.maven.plugins
+ maven-archetype-plugin
+ ${maven.archetype.version}
+ org.codehaus.mojocobertura-maven-plugin
- 2.6
+ 2.7org.codehaus.mojosonar-maven-plugin
- 2.4
+ 3.4.0.905org.codehaus.mojofindbugs-maven-plugin
- 3.0.0
+ 3.0.5org.codehaus.mojo
@@ -290,17 +308,37 @@
org.codehaus.mojoflatten-maven-plugin
- 1.0.0
+ 1.0.1org.codehaus.mojo
- servicedocgen-maven-plugin
- ${servicedocgen.version}
+ license-maven-plugin
+ 1.14
+
+ ${project.build.directory}/generated-resources
+ true
+ true
+ true
+
+
+ Apache Software License, Version 2.0|The Apache Software License, Version 2.0|Apache 2.0|Apache License, Version 2.0
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.0org.owaspdependency-check-maven
- 1.3.6
+ 3.1.1
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 1.5.7.RELEASE
@@ -336,7 +374,9 @@
${project.build.sourceEncoding}true${user.dir}/src/main/javadoc/stylesheet.css
- ${javadoc.params}
+
+ ${javadoc.option.doclint}
+
http://docs.oracle.com/javase/7/docs/api/
@@ -364,8 +404,7 @@
-
-
+ aggregatecheck
@@ -373,26 +412,15 @@
org.codehaus.mojo
- servicedocgen-maven-plugin
-
-
-
- ${servicedoc.info.title}
- ${servicedoc.info.description}
-
- ${servicedoc.host}
- ${servicedoc.port}
- ${servicedoc.basePath}
-
- http
-
-
-
- https://seu.sdm.de/pu/lfuadamas/build/maven/site/apidocs
-
-
-
-
+ license-maven-plugin
+
+
+
+ third-party-report
+ aggregate-third-party-report
+
+
+
@@ -404,20 +432,9 @@
[1.8,)
- -Xdoclint:none
+ -Xdoclint:none
-
- all
-
-
- pom.xml
-
-
-
- samples
-
- security
@@ -495,6 +512,34 @@
+
+ licenses
+
+
+
+ org.codehaus.mojo
+ license-maven-plugin
+
+
+ aggregate-download-licenses
+ generate-resources
+
+ aggregate-download-licenses
+
+
+
+
+ aggregate-add-third-party
+ process-resources
+
+ aggregate-add-third-party
+
+
+
+
+
+
+ eclipse
@@ -590,5 +635,4 @@
file://${user.dir}/target/oasp4j/maven
-
diff --git a/samples/batch/billExport.bat b/samples/batch/billExport.bat
deleted file mode 100644
index 5a8df919a..000000000
--- a/samples/batch/billExport.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-@echo off
-call %~dp0\runbatch.bat classpath:config/app/batch/beans-billexport.xml billExportJob bills.file=bills.csv date(date)=2015/12/20
diff --git a/samples/batch/pom.xml b/samples/batch/pom.xml
deleted file mode 100644
index de96bf98b..000000000
--- a/samples/batch/pom.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
- 4.0.0
-
- io.oasp.java.dev
- oasp4j-samples
- dev-SNAPSHOT
-
- io.oasp.java.samples
- oasp4j-sample-batch
- ${project.artifactId}
- pom
- Batches for the restaurant application - a simple example using the Open Application Standard Platform for Java (OASP4J).
-
-
- ${project.groupId}
- oasp4j-sample-core
- ${project.version}
-
-
- junit
- junit
- test
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy-dependencies
- package
-
- copy-dependencies
-
-
-
- ${project.build.directory}/lib/
-
-
-
-
-
-
-
-
diff --git a/samples/batch/productImport.bat b/samples/batch/productImport.bat
deleted file mode 100644
index 7f17e8f07..000000000
--- a/samples/batch/productImport.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-@echo off
-call %~dp0\runbatch.bat classpath:config/app/batch/beans-productimport.xml productImportJob drinks.file=file:src/test/resources/drinks.csv meals.file=file:src/test/resources/meals.csv date(date)=2015/12/20
diff --git a/samples/batch/readme.txt b/samples/batch/readme.txt
deleted file mode 100644
index 313a08850..000000000
--- a/samples/batch/readme.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-To actually run a batch you have to execute the following command in the oasp4j directory once:
-
- mvn clean install
-
-It might be OK if not all projects can be build successfully.
-
-Afterwards, go to the oasp4j/samples directory and execute (must be executed once after each modification):
-
- mvn clean package
-
-Then you can invoke the batch with
-
- billExport.bat or productImport.bat
-
-When the batch finishes successfully, you will see something like this in the console log:
-
-2016-03-14 14:29:09.955 INFO 5524 --- [main] i.o.m.b.c.b.SpringBootBatchCommandLine : Batch Status: COMPLETED
-2016-03-14 14:29:09.955 INFO 5524 --- [main] i.o.m.b.c.b.SpringBootBatchCommandLine : Return Code: 0
diff --git a/samples/batch/runbatch.bat b/samples/batch/runbatch.bat
deleted file mode 100644
index 6b04f8455..000000000
--- a/samples/batch/runbatch.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-rem This skript demonstrates how to run oasp batches via commandline
-java -cp "%~dp0\target\lib\*" -Doasp.db.port=8143 io.oasp.module.batch.common.base.SpringBootBatchCommandLine io.oasp.gastronomy.restaurant.SpringBootBatchApp %*
\ No newline at end of file
diff --git a/samples/batch/src/test/resources/drinks.csv b/samples/batch/src/test/resources/drinks.csv
deleted file mode 100644
index 5870f32c7..000000000
--- a/samples/batch/src/test/resources/drinks.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-Heineken, Pretty good beer, 1, true
-Dilmah, Very tasty black tea, 2, false
-Pepsi, Nice drink, 3, false
diff --git a/samples/batch/src/test/resources/meals.csv b/samples/batch/src/test/resources/meals.csv
deleted file mode 100644
index 914d8717a..000000000
--- a/samples/batch/src/test/resources/meals.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-Bratwurst, Tasty sausage, 1
-Hamburger, Big bun with meat, 2
-Tofu, Food made from soy milk, 3
-Pierogi, Very good filled dumplings, 4
diff --git a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/MoneyHelper.java b/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/MoneyHelper.java
deleted file mode 100644
index 0ac8d4688..000000000
--- a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/MoneyHelper.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package io.oasp.gastronomy.restaurant.general.common.api;
-
-import io.oasp.gastronomy.restaurant.general.common.api.datatype.Money;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-/**
- * This class is a little helper to deal with {@link Money}. It provides convenience methods to get a {@link Money}.
- *
- */
-public final class MoneyHelper {
-
- /**
- * String representation of the default currency Euro (ISO 4217).
- */
- public static final String DEFAULT_CURRENCY_STRING = "EUR";
-
- /**
- * MonetaryAmount with amount 0 and default currency.
- */
- public static final Money ZERO_MONEY = Money.ZERO;
-
- /**
- * Construction prohibited.
- */
- private MoneyHelper() {
-
- super();
- }
-
- /**
- * Returns a {@link Money} with the default currency and the given amount.
- *
- * @param amount of the {@link Money}
- * @return {@link Money} with default currency
- */
- public static Money getMoneyWithDefaultCurrency(Number amount) {
-
- BigDecimal value;
- if (amount instanceof BigDecimal) {
- value = (BigDecimal) amount;
- } else {
- value = BigDecimal.valueOf(amount.doubleValue());
- }
- return new Money(value);
- }
-
- /**
- *
- * Returns a {@link Money} with the given currency and the given amount.
- *
- * @param amount amount of the {@link Money}
- * @param currencyCode ISO 4217 Code of the currency
- * @return {@link Money} with given currency
- */
- public static Money getMoney(Number amount, String currencyCode) {
-
- return getMoneyWithDefaultCurrency(amount);
- }
-
- /**
- * Sums a list of {@link Money}s. The returned {@link Money} has the currency of the {@link Money}s in the given list.
- * If the list is empty the {@link #ZERO_MONEY} is returned.
- *
- * @param moneyToSum list of {@link Money}s to sum
- * @return sum of given {@link Money}s, {@link #ZERO_MONEY} if list is empty
- */
- public static Money sumMoneys(List moneyToSum) {
-
- Money sum = null;
-
- for (Money monetaryAmount : moneyToSum) {
- if (sum == null) {
- sum = monetaryAmount;
- } else {
- sum = sum.add(monetaryAmount);
- }
- }
-
- if (sum == null) {
- sum = ZERO_MONEY;
- }
-
- return sum;
- }
-
-}
diff --git a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/NlsBundleApplicationRoot.java b/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/NlsBundleApplicationRoot.java
deleted file mode 100644
index a149a0af0..000000000
--- a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/NlsBundleApplicationRoot.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package io.oasp.gastronomy.restaurant.general.common.api;
-
-import javax.inject.Named;
-
-import net.sf.mmm.util.nls.api.NlsBundle;
-import net.sf.mmm.util.nls.api.NlsBundleMessage;
-import net.sf.mmm.util.nls.api.NlsMessage;
-
-/**
- * This is the {@link NlsBundle} for this application.
- *
- */
-public interface NlsBundleApplicationRoot extends NlsBundle {
-
- /**
- * @see io.oasp.gastronomy.restaurant.general.common.api.exception.IllegalEntityStateException
- *
- * @param entity is the entity relevant for the error.
- * @param state is the state of the entity that caused the operation to fail.
- * @return the {@link NlsMessage}.
- */
- @NlsBundleMessage("The entity {entity} is in state {state}!")
- NlsMessage errorIllegalEntityState(@Named("entity") Object entity, @Named("state") Object state);
-
- /**
- * @see io.oasp.gastronomy.restaurant.general.common.api.exception.IllegalEntityStateException
- *
- * @param entity is the entity relevant for the error.
- * @param currentState is the current state of the entity.
- * @param newState is the new state for the entity that is illegal.
- * @return the {@link NlsMessage}.
- */
- @NlsBundleMessage("The entity {entity} in state {currentState} can not be changed to state {newState}!")
- NlsMessage errorIllegalEntityStateChange(@Named("entity") Object entity, @Named("currentState") Object currentState,
- @Named("newState") Object newState);
-
- /**
- * @see io.oasp.gastronomy.restaurant.general.common.api.exception.IllegalEntityStateException
- *
- * @param object is the entity relevant for the error.
- * @param property is the property of the entity that can not be changed.
- * @return the {@link NlsMessage}.
- */
- @NlsBundleMessage("The property {property} of object {object} can not be changed!")
- NlsMessage errorIllegalPropertyChange(@Named("object") Object object, @Named("property") Object property);
-
- /**
- * @see io.oasp.gastronomy.restaurant.general.common.api.exception.NoActiveUserException
- *
- * @return the {@link NlsMessage}.
- */
- @NlsBundleMessage("There is currently no user logged in")
- NlsMessage errorNoActiveUser();
-
- // BEGIN ARCHETYPE SKIP
- /**
- * @see io.oasp.gastronomy.restaurant.offermanagement.common.api.exception.OfferEmptyException
- *
- * @return the {@link NlsMessage}.
- */
- @NlsBundleMessage("The offer is empty - it must contain a drink, meal, or side-dish!")
- NlsMessage errorOfferEmpty();
-
- /**
- * @see io.oasp.gastronomy.restaurant.salesmanagement.common.api.exception.ChangeTableIllegalStateCombinationException
- *
- * @param orderId The id of the order which is going to be transfered to the targetTable
- * @param tableNumber of the targetTable which is causing the problem
- * @return the {@link NlsMessage}.
- */
- @NlsBundleMessage("The order with the Id {orderId} can''t be transfered to the table with the Number {tableNumber}"
- + " because this table is already occupied.")
- NlsMessage errorChangeTableIllegalStateCombination(@Named("orderId") Long orderId,
- @Named("tableNumber") Long tableNumber);
- // END ARCHETYPE SKIP
-
-}
diff --git a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/RestService.java b/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/RestService.java
deleted file mode 100644
index 9cfe326e7..000000000
--- a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/RestService.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package io.oasp.gastronomy.restaurant.general.common.api;
-
-/**
- * A marker interface for REST services. REST service interfaces of components should extend this interface.
- *
- */
-public interface RestService {
-
-}
diff --git a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/UserProfile.java b/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/UserProfile.java
deleted file mode 100644
index ac5b256db..000000000
--- a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/UserProfile.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package io.oasp.gastronomy.restaurant.general.common.api;
-
-import io.oasp.gastronomy.restaurant.general.common.api.datatype.Role;
-
-import java.security.Principal;
-
-/**
- * This is the interface for the profile of a user interacting with this application. Currently this can only be a
- * {@link io.oasp.gastronomy.restaurant.staffmanagement.dataaccess.api.StaffMemberEntity} however in the future a
- * customer may login and make a reservation, etc.
- * TODO: Also an external system may access the application via some service. Then there would be no user profile or it
- * would be empty...
- *
- */
-public interface UserProfile extends Principal {
- /**
- * @return the technical ID of the user for calling REST services.
- */
- Long getId();
-
- /**
- * @return the unique login of the user for authentication and identification.
- */
- String getName();
-
- /**
- * @return the first name of the users real name.
- */
- String getFirstName();
-
- /**
- * @return the last name of the users real name.
- */
- String getLastName();
-
- /**
- * @return {@link Role} of this {@link UserProfile}.
- */
- Role getRole();
-}
diff --git a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/Usermanagement.java b/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/Usermanagement.java
deleted file mode 100644
index 7a84b5f24..000000000
--- a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/Usermanagement.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.oasp.gastronomy.restaurant.general.common.api;
-
-/**
- * Interface to get a user from its login.
- *
- */
-public interface Usermanagement {
-
- /**
- * @param login The login of the requested user.
- * @return The {@link UserProfile} with the given login or {@code null} if no such object exists.
- */
- UserProfile findUserProfileByLogin(String login);
-
-}
diff --git a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/constants/NamedQueries.java b/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/constants/NamedQueries.java
deleted file mode 100644
index 2fefef6f8..000000000
--- a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/constants/NamedQueries.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package io.oasp.gastronomy.restaurant.general.common.api.constants;
-
-/**
- * Constants of the named queries defined in NamedQueries.xml.
- *
- */
-public abstract class NamedQueries {
-
- // put your query names from NamedQueries.xml as constants here (or generate with cobigen)
- // BEGIN ARCHETYPE SKIP
- /** @see io.oasp.gastronomy.restaurant.tablemanagement.dataaccess.impl.dao.TableDaoImpl#getFreeTables() */
- public static final String GET_FREE_TABLES = "get.free.tables";
-
- /** @see io.oasp.gastronomy.restaurant.staffmanagement.dataaccess.impl.dao.StaffMemberDaoImpl#findByLogin(String) */
- public static final String GET_STAFF_MEMBER_BY_LOGIN = "get.staff.member.by.login";
-
- /** @see io.oasp.gastronomy.restaurant.salesmanagement.dataaccess.impl.dao.OrderPositionDaoImpl */
- public static final String GET_ALL_ORDER_POSITIONS = "get.all.order.positions";
-
- /** @see io.oasp.gastronomy.restaurant.salesmanagement.dataaccess.impl.dao.OrderPositionDaoImpl */
- public static final String GET_ALL_OPEN_ORDER_POSITIONS = "get.all.open.order.positions";
-
- /** @see io.oasp.gastronomy.restaurant.salesmanagement.dataaccess.impl.dao.OrderPositionDaoImpl */
- public static final String GET_OPEN_ORDER_POSITIONS_FOR_ORDER = "get.open.order.positions.for.order";
-
- /** @see io.oasp.gastronomy.restaurant.salesmanagement.dataaccess.impl.dao.OrderDaoImpl */
- public static final String GET_OPEN_ORDER_FOR_TABLE = "get.open.order.for.table";
-
- /** @see io.oasp.gastronomy.restaurant.salesmanagement.dataaccess.impl.dao.BillDaoImpl */
- public static final String GET_ALL_IDS_OF_PAYED_BILLS = "get.all.ids.of.payed.bills";
- // END ARCHETYPE SKIP
-}
diff --git a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/constants/PermissionConstants.java b/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/constants/PermissionConstants.java
deleted file mode 100644
index 6746b0a20..000000000
--- a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/constants/PermissionConstants.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package io.oasp.gastronomy.restaurant.general.common.api.constants;
-
-/**
- * Contains constants for the keys of all
- * {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission}s.
- *
- */
-public abstract class PermissionConstants {
-
- // put your permission names from access-control-schema.xml as constants here (or generate with cobigen)
- // BEGIN ARCHETYPE SKIP
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to retrieve offer. */
- public static final String FIND_OFFER = "FindOffer";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to save offer. */
- public static final String SAVE_OFFER = "SaveOffer";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to remove offer. */
- public static final String DELETE_OFFER = "DeleteOffer";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to retrieve product. */
- public static final String FIND_PRODUCT = "FindProduct";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to save product. */
- public static final String SAVE_PRODUCT = "SaveProduct";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to remove product. */
- public static final String DELETE_PRODUCT = "DeleteProduct";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to retrieve product picture. */
- public static final String FIND_PRODUCT_PICTURE = "FindProductPicture";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to save product picture. */
- public static final String SAVE_PRODUCT_PICTURE = "SaveProductPicture";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to remove product picture. */
- public static final String DELETE_PRODUCT_PICTURE = "DeleteProductPicture";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to retrieve order. */
- public static final String FIND_ORDER = "FindOrder";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to save order. */
- public static final String SAVE_ORDER = "SaveOrder";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to remove order. */
- public static final String DELETE_ORDER = "DeleteOrder";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to retrieve order position. */
- public static final String FIND_ORDER_POSITION = "FindOrderPosition";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to save order position. */
- public static final String SAVE_ORDER_POSITION = "SaveOrderPosition";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to remove order position. */
- public static final String DELETE_ORDER_POSITION = "DeleteOrderPosition";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to retrieve bill. */
- public static final String FIND_BILL = "FindBill";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to save bill. */
- public static final String SAVE_BILL = "SaveBill";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to remove bill. */
- public static final String DELETE_BILL = "DeleteBill";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to retrieve staff member. */
- public static final String FIND_STAFF_MEMBER = "FindStaffMember";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to save staff member. */
- public static final String SAVE_STAFF_MEMBER = "SaveStaffMember";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to remove staff member. */
- public static final String DELETE_STAFF_MEMBER = "DeleteStaffMember";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to retrieve table. */
- public static final String FIND_TABLE = "FindTable";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to save table. */
- public static final String SAVE_TABLE = "SaveTable";
-
- /** {@link io.oasp.module.security.common.api.accesscontrol.AccessControlPermission} to remove table. */
- public static final String DELETE_TABLE = "DeleteTable";
- // END ARCHETYPE SKIP
-}
diff --git a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/datatype/Money.java b/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/datatype/Money.java
deleted file mode 100644
index d5b543dc2..000000000
--- a/samples/core/src/main/java/io/oasp/gastronomy/restaurant/general/common/api/datatype/Money.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package io.oasp.gastronomy.restaurant.general.common.api.datatype;
-
-import java.math.BigDecimal;
-import java.util.Currency;
-import java.util.Objects;
-
-import net.sf.mmm.util.lang.api.AbstractSimpleDatatype;
-
-/**
- * This is the implementation of a {@link net.sf.mmm.util.lang.api.Datatype} to represent an amount of money.
- * We recommend to use JSR354 (javax.money.MonetaryAmount) instead. However, we created this when the JSR
- * was still in progress and the API had a licensing model that incompatible with ASL 2.0.
- *
- */
-public class Money extends AbstractSimpleDatatype implements Comparable