| /** |
| * Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Florian Pirchner - Initial implementation |
| */ |
| package org.eclipse.osbp.runtime.common.filter; |
| |
| import java.util.Collection; |
| import java.util.List; |
| import java.util.Map; |
| import java.util.Set; |
| |
| import javax.persistence.EntityManagerFactory; |
| import javax.persistence.LockModeType; |
| |
| import org.eclipse.osbp.runtime.common.validation.IStatus; |
| import org.eclipse.osbp.runtime.common.validation.ValidationKind; |
| |
| /** |
| * The Interface IDTOService. |
| * |
| * @param <A> |
| * the generic type |
| */ |
| public interface IDTOService<A> extends IService { |
| |
| /** The Constant PROP_MAX_COLLECTION_CONTENT. */ |
| public static final int PROP_MAX_COLLECTION_CONTENT = 100000; |
| |
| /** |
| * Checks if historized filter is ignored. |
| * |
| * @return true, if ignore historized filter |
| */ |
| boolean isIgnoreHistorizedFilter(); |
| |
| /** |
| * Sets the historized filter to be ignored. |
| * |
| * @param ignoreHistorizedFilter the new ignore historized filter |
| */ |
| void setIgnoreHistorizedFilter(boolean ignoreHistorizedFilter); |
| |
| /** |
| * Returns the dto for the given id. |
| * |
| * @param id |
| * the id |
| * @return the a |
| */ |
| A get(Object id); |
| A get(Object id, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Reloads the given dto and returns the refreshed values by a new |
| * instance.<br> |
| * If the data basis for the dto is not available anymore. For instance the |
| * entity was deleted, then <code>null</code> will be returned. |
| * |
| * @param dto |
| * the dto |
| * @return A |
| */ |
| A reload(A dto); |
| |
| /** |
| * Returns a collection of dtos matching the filter in the query. <br> |
| * The maximum amount of contained elements is limited by |
| * {@link #PROP_MAX_COLLECTION_CONTENT}. |
| * |
| * @param query |
| * the query |
| * @return the collection |
| */ |
| Collection<A> find(IQuery query, Object ui, LockModeType lockModeType); |
| Collection<A> find(IQuery query); |
| |
| /** |
| * Returns a collection of dtos matching the filter defined in the query and |
| * starting from the given startIndex. <br> |
| * May be used for lazy loading issues. Ensure that a sort order is used in |
| * that case. |
| * |
| * The maximum amount of contained elements is limited by |
| * {@link #PROP_MAX_COLLECTION_CONTENT}. |
| * |
| * @param query |
| * the query |
| * @param startIndex |
| * the start index |
| * @return the collection |
| */ |
| Collection<A> find(IQuery query, int startIndex, Object ui, LockModeType lockModeType); |
| Collection<A> find(IQuery query, int startIndex); |
| |
| /** |
| * Returns a collection of dtos selected by the given jpql. <br> |
| * This method throws an {@link IllegalArgumentException} if the defined |
| * jpql does not select dtos. |
| * |
| * @param query |
| * the query |
| * @return the collection |
| */ |
| Collection<A> findDtos(IJPQL jpql); |
| |
| /** |
| * Returns a list of values selected by the given jpql. <br> |
| * The values are at the same index as in the JPQL "select"-statement. Eg. |
| * "select p.name, p.postalcode from Person p". |
| * |
| * @param query |
| * the query |
| * @return the collection |
| */ |
| List<?> findValues(IJPQL jpql); |
| |
| /** |
| * Updates the given DTO.nverter |
| * |
| * @param dto |
| * the dto |
| */ |
| void update(A dto); |
| void persist(Object dto); |
| |
| /** |
| * Session bound transaction begin. |
| * |
| * @param ui the ui |
| * @return true, if successful |
| */ |
| boolean transactionBegin(Object ui); |
| |
| /** |
| * Session bound transaction commit. |
| * |
| * @param ui the ui |
| * @return true, if successful |
| */ |
| boolean transactionCommit(Object ui); |
| |
| /** |
| * Session bound transaction rollback. |
| * |
| * @param ui the ui |
| * @return true, if successful |
| */ |
| boolean transactionRollback(Object ui); |
| |
| /** |
| * Session bound merge with {@link LockModeType}. |
| * |
| * @param dto the dto to merge |
| * @param ui the ui |
| * @param lockModeType the lock mode type |
| * @return true, if successful |
| */ |
| boolean update(A dto, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Session bound persist with {@link LockModeType}. |
| * |
| * @param dto the dto to persist |
| * @param ui the ui |
| * @param lockModeType the lock mode type |
| * @return true, if successful |
| */ |
| boolean insert(A dto, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Session bound delete with {@link LockModeType}. |
| * |
| * @param dto the dto to delete |
| * @param ui the ui |
| * @param lockModeType the lock mode type |
| * @return true, if successful |
| */ |
| boolean delete(A dto, Object ui, LockModeType lockModeType); |
| /** |
| * Deletes the given DTO. |
| * |
| * @param dto |
| * the dto to delete |
| * @throws DtoServiceException |
| * if the record can not be deleted |
| */ |
| void delete(A dto) throws DtoServiceException; |
| |
| /** |
| * Returns the count of all dto matching the filter. |
| * |
| * @param query |
| * the query |
| * @return the int |
| */ |
| int size(IQuery query); |
| int size(IQuery query, Object ui, LockModeType lockModeType); |
| /** |
| * Returns true, if the dto exists for the given filter. |
| * |
| * @param dto |
| * the dto |
| * @param query |
| * the query |
| * @return true, if successful |
| */ |
| boolean contains(Object dto, IQuery query); |
| boolean contains(Object dto, IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Returns true, if a dto exists for the given filter. |
| * |
| * @param query |
| * the query |
| * @return true, if successful |
| */ |
| boolean contains(IQuery query); |
| boolean contains(IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Returns the next dto for the given one using the filter and the |
| * sortOrder. |
| * |
| * @param dto |
| * the dto |
| * @param query |
| * the query |
| * @return the next |
| */ |
| A getNext(A dto, IQuery query); |
| A getNext(A dto, IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Returns the previous dto for the given one using the filter and the |
| * sortOrder. |
| * |
| * @param dto |
| * the dto |
| * @param query |
| * the query |
| * @return the previous |
| */ |
| A getPrevious(A dto, IQuery query); |
| A getPrevious(A dto, IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Returns the first dto for the given filter and the sortOrder. |
| * |
| * @param query the query |
| * @param lockModeType the lock mode type |
| * @return the first |
| */ |
| A getFirst(IQuery query); |
| A getFirst(IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Returns the last dto for the given filter and the sortOrder. |
| * |
| * @param query the query |
| * @param lockModeType the lock mode type |
| * @return the last |
| */ |
| A getLast(IQuery query); |
| A getLast(IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Returns true, if the given dto is the first one for the filter and |
| * sortOrder. |
| * |
| * @param dto |
| * the dto |
| * @param query |
| * the query |
| * @return true, if is first |
| */ |
| boolean isFirst(A dto, IQuery query); |
| boolean isFirst(A dto, IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Returns true, if the given dto is the last one for the filter and |
| * sortOrder. |
| * |
| * @param dto |
| * the dto |
| * @param query |
| * the query |
| * @return true, if is last |
| */ |
| boolean isLast(A dto, IQuery query); |
| boolean isLast(A dto, IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Returns the index of the given dto for the filter and sortOrder. |
| * |
| * @param dto |
| * the dto |
| * @param query |
| * the query |
| * @return the int |
| */ |
| int indexOf(A dto, IQuery query); |
| |
| /** |
| * Returns the dto for the given index, filter and sortOrder. |
| * |
| * @param index the index |
| * @param query the query |
| * @param lockModeType the lock mode type |
| * @return the by index |
| */ |
| A getByIndex(int index, IQuery query); |
| A getByIndex(int index, IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Returns a list of dtos with size <= numberOfItems, starting from the |
| * startIndex in respect to the filter and sortOrder. |
| * |
| * @param startIndex the start index |
| * @param numberOfItems the number of items |
| * @param query the query |
| * @param lockModeType the lock mode type |
| * @return the by index |
| */ |
| List<A> getByIndex(int startIndex, int numberOfItems, IQuery query); |
| List<A> getByIndex(int startIndex, int numberOfItems, IQuery query, Object ui, LockModeType lockModeType); |
| |
| /** |
| * Validates the given DTO. |
| * |
| * @param object |
| * the object |
| * @param kind |
| * the kind of validation |
| * @param properties |
| * any kind of properties required in validation |
| * @return the sets the |
| * @throws IllegalStateException |
| * if no Validator is available |
| */ |
| Set<IStatus> validate(A object, ValidationKind kind, Map<String, Object> properties) throws IllegalStateException; |
| |
| /** |
| * Gets the id. |
| * |
| * @param dto |
| * the dto |
| * @return the id |
| */ |
| Object getId(A dto); |
| |
| /** |
| * Returns the persistence Id which is used to find the proper |
| * {@link EntityManagerFactory}, |
| * |
| * @return |
| */ |
| String getPersistenceId(); |
| |
| /** |
| * Sets the persistence Id which is used to find the proper |
| * {@link EntityManagerFactory}, |
| * |
| * @param persistenceId |
| */ |
| void setPersistenceId(String persistenceId); |
| |
| } |