Update services layer
Clean code
This commit is contained in:
parent
80887fea4c
commit
7c74c553af
@ -283,6 +283,15 @@
|
|||||||
<version>${commons-io.version}</version>
|
<version>${commons-io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- End Lukman -->
|
<!-- End Lukman -->
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${project.lombok.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<organization>
|
<organization>
|
||||||
<name>Jasa Medika</name>
|
<name>Jasa Medika</name>
|
||||||
|
|||||||
@ -1,40 +0,0 @@
|
|||||||
/*package com.jasamedika.medifirst2000.chace;
|
|
||||||
|
|
||||||
import org.springframework.cache.CacheManager;
|
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
|
||||||
import org.springframework.cache.ehcache.EhCacheCacheManager;
|
|
||||||
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableCaching
|
|
||||||
@ComponentScan({ "com.jasamedika.*" })
|
|
||||||
public class ChaceConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CacheManager cacheManager() {
|
|
||||||
return new EhCacheCacheManager(ehCacheCacheManager().getObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public EhCacheManagerFactoryBean ehCacheCacheManager() {
|
|
||||||
EhCacheManagerFactoryBean cmfb = new EhCacheManagerFactoryBean();
|
|
||||||
cmfb.setConfigLocation(new ClassPathResource("ehcache.xml"));
|
|
||||||
cmfb.setShared(true);
|
|
||||||
|
|
||||||
return cmfb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CacheManager defaultCacheManager() {
|
|
||||||
return new ConcurrentMapCacheManager("books");
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
@ -1,9 +1,9 @@
|
|||||||
package com.jasamedika.medifirst2000.converter.base;
|
package com.jasamedika.medifirst2000.converter.base;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.base.BaseModel;
|
import com.jasamedika.medifirst2000.base.BaseModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base Converter Class between V and VO
|
* Base Converter Class between V and VO
|
||||||
*
|
*
|
||||||
@ -14,28 +14,19 @@ public interface BaseVoConverter<V, T extends BaseModel> {
|
|||||||
/**
|
/**
|
||||||
* transfer value from vo object to domain object for enum value, please do
|
* transfer value from vo object to domain object for enum value, please do
|
||||||
* manually using Enum.values()[ordinal]
|
* manually using Enum.values()[ordinal]
|
||||||
*
|
*
|
||||||
* @param vo
|
*/
|
||||||
* @param model
|
T transferVOToModel(V vo, T model);
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public T transferVOToModel(V vo, T model);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* transfer value from list of domain object to list of vo object
|
* transfer value from list of domain object to list of vo object
|
||||||
*
|
*
|
||||||
* @param models
|
*/
|
||||||
* @param vos
|
List<V> transferListOfModelToListOfVO(List<T> models, List<V> vos);
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<V> transferListOfModelToListOfVO(List<T> models, List<V> vos);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* transfer value from domain object to vo object
|
* transfer value from domain object to vo object
|
||||||
*
|
*
|
||||||
* @param model
|
*/
|
||||||
* @param vo
|
V transferModelToVO(T model, V vo);
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public V transferModelToVO(T model, V vo);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
package com.jasamedika.medifirst2000.dao.custom.base;
|
package com.jasamedika.medifirst2000.dao.custom.base;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.base.BaseModel;
|
import com.jasamedika.medifirst2000.base.BaseModel;
|
||||||
import com.jasamedika.medifirst2000.dao.custom.base.util.PaginationResult;
|
import com.jasamedika.medifirst2000.dao.custom.base.util.PaginationResult;
|
||||||
import com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue;
|
import com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue;
|
||||||
import com.jasamedika.medifirst2000.dao.custom.base.util.QueryOrder;
|
import com.jasamedika.medifirst2000.dao.custom.base.util.QueryOrder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A data access object (DAO) providing persistence and search support for the
|
* A data access object (DAO) providing persistence and search support for the
|
||||||
* entities. Transaction control of the insert(), update() and remove()
|
* entities. Transaction control of the insert(), update() and remove()
|
||||||
* operations can directly support Spring container-managed transactions or they
|
* operations can directly support Spring container-managed transactions, or they
|
||||||
* can be augmented to handle user-managed Spring transactions. Each of these
|
* can be augmented to handle user-managed Spring transactions. Each of these
|
||||||
* methods provides additional information for how to configure it for the
|
* methods provides additional information for how to configure it for the
|
||||||
* desired type of transaction control.
|
* desired type of transaction control.
|
||||||
@ -67,9 +67,9 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* null if not using.
|
* null if not using.
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. <br>
|
* Optional int varargs. <br>
|
||||||
* rowStartIdxAndCount[0] specifies the the row index in the
|
* rowStartIdxAndCount[0] specifies the row index in the
|
||||||
* query result-set to begin collecting the results. <br>
|
* query result-set to begin collecting the results. <br>
|
||||||
* rowStartIdxAndCount[1] specifies the the maximum number of
|
* rowStartIdxAndCount[1] specifies the maximum number of
|
||||||
* results to return.
|
* results to return.
|
||||||
* @return A pagination result
|
* @return A pagination result
|
||||||
*/
|
*/
|
||||||
@ -92,15 +92,15 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* The list of property name and sorting direction pairs. Set to
|
* The list of property name and sorting direction pairs. Set to
|
||||||
* null, if not using.
|
* null, if not using.
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return PagintationResult<T>
|
* @return PagintationResult<T>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
PaginationResult<T> paginateByMapOfProperties(
|
PaginationResult<T> paginateByMapOfProperties(
|
||||||
Map<String, ? extends Object> propertiesMap,
|
Map<String, ?> propertiesMap,
|
||||||
List<String> leftJoinFetchColumns, List<QueryOrder> orders,
|
List<String> leftJoinFetchColumns, List<QueryOrder> orders,
|
||||||
final int... rowStartIdxAndCount);
|
final int... rowStartIdxAndCount);
|
||||||
|
|
||||||
@ -119,21 +119,21 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* Sorting orders. Set to null if not using.
|
* Sorting orders. Set to null if not using.
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. <br>
|
* Optional int varargs. <br>
|
||||||
* rowStartIdxAndCount[0] specifies the the row index in the
|
* rowStartIdxAndCount[0] specifies the row index in the
|
||||||
* query result-set to begin collecting the results. <br>
|
* query result-set to begin collecting the results. <br>
|
||||||
* rowStartIdxAndCount[1] specifies the the maximum number of
|
* rowStartIdxAndCount[1] specifies the maximum number of
|
||||||
* results to return.
|
* results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
PaginationResult<T> paginateLikeMapOfProperties(
|
PaginationResult<T> paginateLikeMapOfProperties(
|
||||||
Map<String, ? extends Object> propertiesMap,
|
Map<String, ?> propertiesMap,
|
||||||
List<String> leftJoinFetchColumns, List<QueryOrder> orders,
|
List<String> leftJoinFetchColumns, List<QueryOrder> orders,
|
||||||
final int... rowStartIdxAndCount);
|
final int... rowStartIdxAndCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters finding and counting instances by several criteria <br>
|
* Filters finding and counting instances by several criteria <br>
|
||||||
* Finds instances using different criteria for different properties. All
|
* Finds instances using different criteria for different properties. All
|
||||||
* criteria are stored in a list and they will all be added up to the query
|
* criteria are stored in a list, and they will all be added up to the query
|
||||||
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
||||||
* filter.
|
* filter.
|
||||||
*
|
*
|
||||||
@ -145,7 +145,7 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
||||||
* three elements typically composed of the name of the property,
|
* three elements typically composed of the name of the property,
|
||||||
* the criteria used to compare and the value to which that
|
* the criteria used to compare and the value to which that
|
||||||
* property should be compared. However there are some criteria
|
* property should be compared. However, there are some criteria
|
||||||
* in which value should be null, or in which the value should be
|
* in which value should be null, or in which the value should be
|
||||||
* a collection of values. <br>
|
* a collection of values. <br>
|
||||||
* Follows a list of the supported queryComparators for criteria
|
* Follows a list of the supported queryComparators for criteria
|
||||||
@ -164,7 +164,7 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* <li>Property is compared with value which is a List or
|
* <li>Property is compared with value which is a List or
|
||||||
* Collection:
|
* Collection:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>BEETWEEN List is advisable as it it ordered, although
|
* <li>BEETWEEN List is advisable as it is ordered, although
|
||||||
* collection is supported
|
* collection is supported
|
||||||
* <li>IN
|
* <li>IN
|
||||||
* </ul>
|
* </ul>
|
||||||
@ -186,9 +186,9 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* Sorting orders. Set to null if not using.
|
* Sorting orders. Set to null if not using.
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. <br>
|
* Optional int varargs. <br>
|
||||||
* rowStartIdxAndCount[0] specifies the the row index in the
|
* rowStartIdxAndCount[0] specifies the row index in the
|
||||||
* query result-set to begin collecting the results. <br>
|
* query result-set to begin collecting the results. <br>
|
||||||
* rowStartIdxAndCount[1] specifies the the maximum number of
|
* rowStartIdxAndCount[1] specifies the maximum number of
|
||||||
* results to return.
|
* results to return.
|
||||||
* @return PaginationResult<T>
|
* @return PaginationResult<T>
|
||||||
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
|
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
|
||||||
@ -201,13 +201,13 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* Finds and counts all elements of the table in order.
|
* Finds and counts all elements of the table in order.
|
||||||
*
|
*
|
||||||
* @param leftJoinFetchColumns
|
* @param leftJoinFetchColumns
|
||||||
* List of left join fetch property name..
|
* List of left join fetch property name.
|
||||||
* @param orders
|
* @param orders
|
||||||
* the orders
|
* the orders
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return PaginationResult<T>
|
* @return PaginationResult<T>
|
||||||
*/
|
*/
|
||||||
@ -228,9 +228,9 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* @param orders
|
* @param orders
|
||||||
* the orders
|
* the orders
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return PaginationResult<T>
|
* @return PaginationResult<T>
|
||||||
*/
|
*/
|
||||||
@ -256,7 +256,7 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* do "OR" Expression (Disjunction). The method will ignore the third and
|
* do "OR" Expression (Disjunction). The method will ignore the third and
|
||||||
* successive parameters in case we have them, such as
|
* successive parameters in case we have them, such as
|
||||||
* removeBulkUsingFilter(filter, true, true, true, false), this would just
|
* removeBulkUsingFilter(filter, true, true, true, false), this would just
|
||||||
* consider the first one (will be consider as "AND" Expression).
|
* consider the first one (will be considered as "AND" Expression).
|
||||||
*
|
*
|
||||||
* @param filter
|
* @param filter
|
||||||
* the list of <code>PropCriteriaAndValue</code> filter.
|
* the list of <code>PropCriteriaAndValue</code> filter.
|
||||||
@ -264,7 +264,7 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
* Comparison expression either is conjunction ("AND") or
|
* Comparison expression either is conjunction ("AND") or
|
||||||
* disjunction ("OR"). Put <code>null</code> will make the
|
* disjunction ("OR"). Put <code>null</code> will make the
|
||||||
* expression is ("AND") by default. "false, true, true" will be
|
* expression is ("AND") by default. "false, true, true" will be
|
||||||
* consider as "OR", "true, false, true" will be consider as
|
* considered as "OR", "true, false, true" will be considered as
|
||||||
* "AND" only take first element, and ignore the rest.
|
* "AND" only take first element, and ignore the rest.
|
||||||
*
|
*
|
||||||
* @return true, if successful {@inheritDoc}
|
* @return true, if successful {@inheritDoc}
|
||||||
@ -274,9 +274,8 @@ public interface CoreDao<T extends BaseModel> extends FindLayerDao<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove object from session cache.
|
* Remove object from session cache.
|
||||||
*
|
*
|
||||||
* @param coreDomain
|
*/
|
||||||
*/
|
|
||||||
void evict(BaseModel coreDomain);
|
void evict(BaseModel coreDomain);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package com.jasamedika.medifirst2000.dao.custom.base;
|
package com.jasamedika.medifirst2000.dao.custom.base;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.base.BaseModel;
|
import com.jasamedika.medifirst2000.base.BaseModel;
|
||||||
import com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue;
|
import com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Roberto
|
* @author Roberto
|
||||||
*
|
*
|
||||||
@ -30,7 +30,7 @@ public interface CountLayerDao<T extends BaseModel> extends KernelDao<T> {
|
|||||||
* searched values, supports <code>null</code>
|
* searched values, supports <code>null</code>
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
Integer countByMapOfProperties(Map<String, ? extends Object> propertiesMap);
|
Integer countByMapOfProperties(Map<String, ?> propertiesMap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the count operation equivalent to the
|
* Performs the count operation equivalent to the
|
||||||
@ -55,7 +55,7 @@ public interface CountLayerDao<T extends BaseModel> extends KernelDao<T> {
|
|||||||
* searched values, supports <code>null</code>
|
* searched values, supports <code>null</code>
|
||||||
* @return Integer
|
* @return Integer
|
||||||
*/
|
*/
|
||||||
Integer countLikeMapOfProperties(Map<String, ? extends Object> propertiesMap);
|
Integer countLikeMapOfProperties(Map<String, ?> propertiesMap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the count operation equivalent to the
|
* Performs the count operation equivalent to the
|
||||||
@ -72,7 +72,7 @@ public interface CountLayerDao<T extends BaseModel> extends KernelDao<T> {
|
|||||||
/**
|
/**
|
||||||
* Counts filtered instances by several criteria <br>
|
* Counts filtered instances by several criteria <br>
|
||||||
* Finds instances using different criteria for different properties. All
|
* Finds instances using different criteria for different properties. All
|
||||||
* criteria are stored in a list and they will all be added up to the query
|
* criteria are stored in a list, and they will all be added up to the query
|
||||||
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
||||||
* filter.
|
* filter.
|
||||||
*
|
*
|
||||||
@ -81,7 +81,7 @@ public interface CountLayerDao<T extends BaseModel> extends KernelDao<T> {
|
|||||||
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
||||||
* three elements typically composed of the name of the property,
|
* three elements typically composed of the name of the property,
|
||||||
* the criteria used for comparation and the value to which that
|
* the criteria used for comparation and the value to which that
|
||||||
* property should be compared. However there are some criteria
|
* property should be compared. However, there are some criteria
|
||||||
* in which value should be null, or in which the value should be
|
* in which value should be null, or in which the value should be
|
||||||
* a collection of values. <br>
|
* a collection of values. <br>
|
||||||
* Follows a list of the supported queryComparators for criteria
|
* Follows a list of the supported queryComparators for criteria
|
||||||
@ -100,7 +100,7 @@ public interface CountLayerDao<T extends BaseModel> extends KernelDao<T> {
|
|||||||
* <li>Property is compared with value which is a List or
|
* <li>Property is compared with value which is a List or
|
||||||
* Collection:
|
* Collection:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>BEETWEEN List is mandatory as it it ordered
|
* <li>BEETWEEN List is mandatory as it is ordered
|
||||||
* <li>IN
|
* <li>IN
|
||||||
* </ul>
|
* </ul>
|
||||||
* <li>Property is checked against criteria regardless value
|
* <li>Property is checked against criteria regardless value
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
package com.jasamedika.medifirst2000.dao.custom.base;
|
package com.jasamedika.medifirst2000.dao.custom.base;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.hibernate.NonUniqueResultException;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.base.BaseModel;
|
import com.jasamedika.medifirst2000.base.BaseModel;
|
||||||
import com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue;
|
import com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue;
|
||||||
import com.jasamedika.medifirst2000.dao.custom.base.util.QueryOrder;
|
import com.jasamedika.medifirst2000.dao.custom.base.util.QueryOrder;
|
||||||
|
import org.hibernate.NonUniqueResultException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Roberto
|
* @author Roberto
|
||||||
@ -16,7 +15,7 @@ import com.jasamedika.medifirst2000.dao.custom.base.util.QueryOrder;
|
|||||||
public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds an instance by its Id.
|
* Finds an instance by its ID.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* the id
|
* the id
|
||||||
@ -26,7 +25,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
T findById(Integer id);
|
T findById(Integer id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds an instance by its Id, eagerly fetching specific child objects.
|
* Finds an instance by its ID, eagerly fetching specific child objects.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* The id to look up for
|
* The id to look up for
|
||||||
@ -41,9 +40,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* Finds all elements of the table.
|
* Finds all elements of the table.
|
||||||
*
|
*
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
@ -53,13 +52,13 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* Finds all elements of the table in order.
|
* Finds all elements of the table in order.
|
||||||
*
|
*
|
||||||
* @param leftJoinFetchColumns
|
* @param leftJoinFetchColumns
|
||||||
* List of left join fetch property name..
|
* List of left join fetch property name.
|
||||||
* @param orders
|
* @param orders
|
||||||
* the orders
|
* the orders
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
@ -75,9 +74,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* @param value
|
* @param value
|
||||||
* The value of the property.
|
* The value of the property.
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
@ -111,9 +110,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* @param orders
|
* @param orders
|
||||||
* The list of property name and sorting direction pairs.
|
* The list of property name and sorting direction pairs.
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
@ -134,9 +133,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* The list of property name and sorting direction pairs.
|
* The list of property name and sorting direction pairs.
|
||||||
*
|
*
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
@ -154,9 +153,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* @param value
|
* @param value
|
||||||
* the value
|
* the value
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
@ -175,9 +174,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* @param orders
|
* @param orders
|
||||||
* The order clause.
|
* The order clause.
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
@ -198,9 +197,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* @param orders
|
* @param orders
|
||||||
* the orders
|
* the orders
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
@ -211,7 +210,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
/**
|
/**
|
||||||
* Filters instances by several criteria <br>
|
* Filters instances by several criteria <br>
|
||||||
* Finds instances using different criteria for different properties. All
|
* Finds instances using different criteria for different properties. All
|
||||||
* criteria are stored in a list and they will all be added up to the query
|
* criteria are stored in a list, and they will all be added up to the query
|
||||||
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
||||||
* filter.
|
* filter.
|
||||||
*
|
*
|
||||||
@ -220,7 +219,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
||||||
* three elements typically composed of the name of the property,
|
* three elements typically composed of the name of the property,
|
||||||
* the criteria used to compare and the value to which that
|
* the criteria used to compare and the value to which that
|
||||||
* property should be compared. However there are some criteria
|
* property should be compared. However, there are some criteria
|
||||||
* in which value should be null, or in which the value should be
|
* in which value should be null, or in which the value should be
|
||||||
* a collection of values. <br>
|
* a collection of values. <br>
|
||||||
* Follows a list of the supported queryComparators for criteria
|
* Follows a list of the supported queryComparators for criteria
|
||||||
@ -239,7 +238,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* <li>Property is compared with value which is a List or
|
* <li>Property is compared with value which is a List or
|
||||||
* Collection:
|
* Collection:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>BEETWEEN List is advisable as it it ordered, although
|
* <li>BEETWEEN List is advisable as it is ordered, although
|
||||||
* collection is supported
|
* collection is supported
|
||||||
* <li>IN
|
* <li>IN
|
||||||
* </ul>
|
* </ul>
|
||||||
@ -258,9 +257,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* </ul>
|
* </ul>
|
||||||
* See <code>PropCriteriaAndValue</code> for more details.
|
* See <code>PropCriteriaAndValue</code> for more details.
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
|
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
|
||||||
@ -271,7 +270,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
/**
|
/**
|
||||||
* Filters instances by several criteria <br>
|
* Filters instances by several criteria <br>
|
||||||
* Finds instances using different criteria for different properties. All
|
* Finds instances using different criteria for different properties. All
|
||||||
* criteria are stored in a list and they will all be added up to the query
|
* criteria are stored in a list, and they will all be added up to the query
|
||||||
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
||||||
* filter.
|
* filter.
|
||||||
*
|
*
|
||||||
@ -280,7 +279,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
||||||
* three elements typically composed of the name of the property,
|
* three elements typically composed of the name of the property,
|
||||||
* the criteria used to compare and the value to which that
|
* the criteria used to compare and the value to which that
|
||||||
* property should be compared. However there are some criteria
|
* property should be compared. However, there are some criteria
|
||||||
* in which value should be null, or in which the value should be
|
* in which value should be null, or in which the value should be
|
||||||
* a collection of values. <br>
|
* a collection of values. <br>
|
||||||
* Follows a list of the supported queryComparators for criteria
|
* Follows a list of the supported queryComparators for criteria
|
||||||
@ -299,7 +298,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* <li>Property is compared with value which is a List or
|
* <li>Property is compared with value which is a List or
|
||||||
* Collection:
|
* Collection:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>BEETWEEN List is advisable as it it ordered, although
|
* <li>BEETWEEN List is advisable as it is ordered, although
|
||||||
* collection is supported
|
* collection is supported
|
||||||
* <li>IN
|
* <li>IN
|
||||||
* </ul>
|
* </ul>
|
||||||
@ -321,9 +320,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* Sorting orders
|
* Sorting orders
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. <br>
|
* Optional int varargs. <br>
|
||||||
* rowStartIdxAndCount[0] specifies the the row index in the
|
* rowStartIdxAndCount[0] specifies the row index in the
|
||||||
* query result-set to begin collecting the results. <br>
|
* query result-set to begin collecting the results. <br>
|
||||||
* rowStartIdxAndCount[1] specifies the the maximum number of
|
* rowStartIdxAndCount[1] specifies the maximum number of
|
||||||
* results to return.
|
* results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
|
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
|
||||||
@ -334,7 +333,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
/**
|
/**
|
||||||
* Filters instances by several criteria <br>
|
* Filters instances by several criteria <br>
|
||||||
* Finds instances using different criteria for different properties. All
|
* Finds instances using different criteria for different properties. All
|
||||||
* criteria are stored in a list and they will all be added up to the query
|
* criteria are stored in a list, and they will all be added up to the query
|
||||||
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
* with <em>AND</em> relationship. Note that this is not an <em>OR</em>
|
||||||
* filter.
|
* filter.
|
||||||
*
|
*
|
||||||
@ -345,7 +344,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
* <code>PropCriteriaAndValue</code> elements, which is a set of
|
||||||
* three elements typically composed of the name of the property,
|
* three elements typically composed of the name of the property,
|
||||||
* the criteria used to compare and the value to which that
|
* the criteria used to compare and the value to which that
|
||||||
* property should be compared. However there are some criteria
|
* property should be compared. However, there are some criteria
|
||||||
* in which value should be null, or in which the value should be
|
* in which value should be null, or in which the value should be
|
||||||
* a collection of values. <br>
|
* a collection of values. <br>
|
||||||
* Follows a list of the supported queryComparators for criteria
|
* Follows a list of the supported queryComparators for criteria
|
||||||
@ -364,7 +363,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* <li>Property is compared with value which is a List or
|
* <li>Property is compared with value which is a List or
|
||||||
* Collection:
|
* Collection:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>BEETWEEN List is advisable as it it ordered, although
|
* <li>BEETWEEN List is advisable as it is ordered, although
|
||||||
* collection is supported
|
* collection is supported
|
||||||
* <li>IN
|
* <li>IN
|
||||||
* </ul>
|
* </ul>
|
||||||
@ -386,9 +385,9 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* Sorting orders
|
* Sorting orders
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. <br>
|
* Optional int varargs. <br>
|
||||||
* rowStartIdxAndCount[0] specifies the the row index in the
|
* rowStartIdxAndCount[0] specifies the row index in the
|
||||||
* query result-set to begin collecting the results. <br>
|
* query result-set to begin collecting the results. <br>
|
||||||
* rowStartIdxAndCount[1] specifies the the maximum number of
|
* rowStartIdxAndCount[1] specifies the maximum number of
|
||||||
* results to return.
|
* results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
|
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
|
||||||
@ -398,7 +397,7 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
final int... rowStartIdxAndCount);
|
final int... rowStartIdxAndCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds instances by a map of properties in an specific order. All
|
* Finds instances by a map of properties in a specific order. All
|
||||||
* properties should be members of the entity. For foreign members do your
|
* properties should be members of the entity. For foreign members do your
|
||||||
* own custom query. In case that one of the properties value is null it
|
* own custom query. In case that one of the properties value is null it
|
||||||
* performs the IS NULL operation for that parameter.
|
* performs the IS NULL operation for that parameter.
|
||||||
@ -409,13 +408,13 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* @param orders
|
* @param orders
|
||||||
* The list of property name and sorting direction pairs.
|
* The list of property name and sorting direction pairs.
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
List<T> findByMapOfProperties(Map<String, ? extends Object> propertiesMap,
|
List<T> findByMapOfProperties(Map<String, ?> propertiesMap,
|
||||||
List<QueryOrder> orders, final int... rowStartIdxAndCount);
|
List<QueryOrder> orders, final int... rowStartIdxAndCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -433,13 +432,13 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* The list of property name and sorting direction pairs.
|
* The list of property name and sorting direction pairs.
|
||||||
*
|
*
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
List<T> findByMapOfProperties(Map<String, ? extends Object> propertiesMap,
|
List<T> findByMapOfProperties(Map<String, ?> propertiesMap,
|
||||||
List<String> leftJoinFetchColumns, List<QueryOrder> orders,
|
List<String> leftJoinFetchColumns, List<QueryOrder> orders,
|
||||||
final int... rowStartIdxAndCount);
|
final int... rowStartIdxAndCount);
|
||||||
|
|
||||||
@ -453,14 +452,14 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* A map containing the properties we're looking up for and their
|
* A map containing the properties we're looking up for and their
|
||||||
* searched values, supports <code>null</code>
|
* searched values, supports <code>null</code>
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
List<T> findLikeMapOfProperties(
|
List<T> findLikeMapOfProperties(
|
||||||
Map<String, ? extends Object> propertiesMap,
|
Map<String, ?> propertiesMap,
|
||||||
final int... rowStartIdxAndCount);
|
final int... rowStartIdxAndCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -475,14 +474,14 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* @param orders
|
* @param orders
|
||||||
* the orders
|
* the orders
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
List<T> findLikeMapOfProperties(
|
List<T> findLikeMapOfProperties(
|
||||||
Map<String, ? extends Object> propertiesMap,
|
Map<String, ?> propertiesMap,
|
||||||
List<QueryOrder> orders, final int... rowStartIdxAndCount);
|
List<QueryOrder> orders, final int... rowStartIdxAndCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -499,14 +498,14 @@ public interface FindLayerDao<T extends BaseModel> extends CountLayerDao<T> {
|
|||||||
* @param orders
|
* @param orders
|
||||||
* the orders
|
* the orders
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* Optional int varargs. rowStartIdxAndCount[0] specifies the the
|
* Optional int varargs. rowStartIdxAndCount[0] specifies the
|
||||||
* row index in the query result-set to begin collecting the
|
* row index in the query result-set to begin collecting the
|
||||||
* results. rowStartIdxAndCount[1] specifies the the maximum
|
* results. rowStartIdxAndCount[1] specifies the maximum
|
||||||
* number of results to return.
|
* number of results to return.
|
||||||
* @return List<T>
|
* @return List<T>
|
||||||
*/
|
*/
|
||||||
List<T> findLikeMapOfProperties(
|
List<T> findLikeMapOfProperties(
|
||||||
Map<String, ? extends Object> propertiesMap,
|
Map<String, ?> propertiesMap,
|
||||||
List<String> leftJoinFetchColumns, List<QueryOrder> orders,
|
List<String> leftJoinFetchColumns, List<QueryOrder> orders,
|
||||||
final int... rowStartIdxAndCount);
|
final int... rowStartIdxAndCount);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
package com.jasamedika.medifirst2000.dao.custom.base;
|
package com.jasamedika.medifirst2000.dao.custom.base;
|
||||||
|
|
||||||
import java.util.List;
|
import com.jasamedika.medifirst2000.base.BaseModel;
|
||||||
|
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
import java.util.List;
|
||||||
import com.jasamedika.medifirst2000.base.BaseModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface KernelDao
|
* The Interface KernelDao
|
||||||
@ -13,72 +12,53 @@ import com.jasamedika.medifirst2000.base.BaseModel;
|
|||||||
*/
|
*/
|
||||||
public interface KernelDao<T extends BaseModel> {
|
public interface KernelDao<T extends BaseModel> {
|
||||||
|
|
||||||
/** The Constant UNCHECKED. */
|
|
||||||
String UNCHECKED = "unchecked";
|
String UNCHECKED = "unchecked";
|
||||||
|
|
||||||
/** The Constant I18N_INSTANCE. */
|
|
||||||
String I18N_INSTANCE = " instance";
|
String I18N_INSTANCE = " instance";
|
||||||
|
|
||||||
/** The Constant I18N_INSERT. */
|
|
||||||
String I18N_INSERT = "insert ";
|
String I18N_INSERT = "insert ";
|
||||||
|
|
||||||
/** The Constant I18N_UPDATE. */
|
|
||||||
String I18N_UPDATE = "update ";
|
String I18N_UPDATE = "update ";
|
||||||
|
|
||||||
/** The Constant I18N_REMOVE. */
|
|
||||||
String I18N_REMOVE = "remove ";
|
String I18N_REMOVE = "remove ";
|
||||||
|
|
||||||
/** The Constant I18N_FIND. */
|
|
||||||
String I18N_FIND = "find ";
|
String I18N_FIND = "find ";
|
||||||
|
|
||||||
/** The Constant I18N_COUNT. */
|
|
||||||
String I18N_COUNT = "count ";
|
String I18N_COUNT = "count ";
|
||||||
|
|
||||||
/** The Constant I18N_FAILED. */
|
|
||||||
String I18N_FAILED = " failed";
|
String I18N_FAILED = " failed";
|
||||||
|
|
||||||
/** The Constant I18N_SUCCEED. */
|
|
||||||
String I18N_SUCCEED = " succesfull";
|
String I18N_SUCCEED = " succesfull";
|
||||||
|
|
||||||
/** The Constant I18N_INSTANCE_WITH_PROPERTY. */
|
String I18N_INSTANCE_WITH_PROPERTY = " " + I18N_INSTANCE + " with property: ";
|
||||||
String I18N_INSTANCE_WITH_PROPERTY = " " + I18N_INSTANCE
|
|
||||||
+ " with property: ";
|
|
||||||
|
|
||||||
/** The Constant I18N_VALUE. */
|
|
||||||
String I18N_VALUE = " value: ";
|
String I18N_VALUE = " value: ";
|
||||||
|
|
||||||
/** The Constant AS_MODEL */
|
|
||||||
String AS_MODEL = " AS model ";
|
String AS_MODEL = " AS model ";
|
||||||
|
|
||||||
/** The Constant WHERE */
|
|
||||||
String WHERE = " WHERE ";
|
String WHERE = " WHERE ";
|
||||||
|
|
||||||
/** The Constant AND */
|
|
||||||
String AND = " AND ";
|
String AND = " AND ";
|
||||||
|
|
||||||
/** The Constant AND */
|
|
||||||
String OR = " OR ";
|
String OR = " OR ";
|
||||||
|
|
||||||
/** The Constant I18N_REMOVE_BULK. */
|
|
||||||
String I18N_REMOVE_BULK = "remove bulk on ";
|
String I18N_REMOVE_BULK = "remove bulk on ";
|
||||||
|
|
||||||
/** The Constant JOIN_TEXT_ESTIMATED_LENGTH */
|
|
||||||
int JOIN_TEXT_ESTIMATED_LENGTH = 32;
|
int JOIN_TEXT_ESTIMATED_LENGTH = 32;
|
||||||
|
|
||||||
/** The Constant JOIN_FETCH_TEXT_ESTIMATED_LENGTH */
|
|
||||||
int ORDER_BY_TEXT_ESTIMATED_LENGTH = 32;
|
int ORDER_BY_TEXT_ESTIMATED_LENGTH = 32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that performs the, optionally paginated, query. It saves
|
* Method that performs the optionally paginated, query. It saves
|
||||||
* duplicating code lines.
|
* duplicating code lines.
|
||||||
*
|
*
|
||||||
* @param query
|
* @param query
|
||||||
* Already well formed query with all parameters passed
|
* Already well-formed query with all parameters passed
|
||||||
* @param rowStartIdxAndCount
|
* @param rowStartIdxAndCount
|
||||||
* rowStartIdxAndCount Optional int varargs.<br>
|
* rowStartIdxAndCount Optional int varargs.<br>
|
||||||
* rowStartIdxAndCount[0] specifies the the row index in the
|
* rowStartIdxAndCount[0] specifies the row index in the
|
||||||
* query result-set to begin collecting the results.<br>
|
* query result-set to begin collecting the results.<br>
|
||||||
* rowStartIdxAndCount[1] specifies the the maximum number of
|
* rowStartIdxAndCount[1] specifies the maximum number of
|
||||||
* results to return.<br>
|
* results to return.<br>
|
||||||
* @return The resulting list of the query
|
* @return The resulting list of the query
|
||||||
* @author Roberto
|
* @author Roberto
|
||||||
|
|||||||
@ -1,18 +1,14 @@
|
|||||||
package com.jasamedika.medifirst2000.exception;
|
package com.jasamedika.medifirst2000.exception;
|
||||||
|
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServiceVOException is class for containing exception that throw in service layer
|
* ServiceVOException is class for containing exception that throw in service layer
|
||||||
*
|
*
|
||||||
* @author Roberto
|
* @author Roberto
|
||||||
*/
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
public class ServiceVOException extends RuntimeException {
|
public class ServiceVOException extends RuntimeException {
|
||||||
/**
|
|
||||||
* serialVersionUID
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public ServiceVOException() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceVOException(String s) {
|
public ServiceVOException(String s) {
|
||||||
super(s);
|
super(s);
|
||||||
|
|||||||
@ -1,81 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.logging;
|
|
||||||
|
|
||||||
import org.aspectj.lang.JoinPoint;
|
|
||||||
import org.aspectj.lang.annotation.AfterReturning;
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.base.BaseMaster;
|
|
||||||
import com.jasamedika.medifirst2000.base.BaseTransaction;
|
|
||||||
import com.jasamedika.medifirst2000.dao.ActivityLogRepository;
|
|
||||||
import com.jasamedika.medifirst2000.entities.ActivityLog;
|
|
||||||
import com.jasamedika.medifirst2000.entities.LoginUser;
|
|
||||||
import com.jasamedika.medifirst2000.service.LoginUserService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Hutagalung
|
|
||||||
*/
|
|
||||||
@Aspect
|
|
||||||
public class LoggingAdvise {
|
|
||||||
|
|
||||||
private final Logger LOG = LoggerFactory.getLogger(LoggingAdvise.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ActivityLogRepository activityLogRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LoginUserService loginUserService;
|
|
||||||
|
|
||||||
private StringBuffer buffer, detail;
|
|
||||||
|
|
||||||
/*@AfterReturning("execution(* com.jasamedika.medifirst2000.service.*.add(*)) && args(object)")
|
|
||||||
public void logAddAction(JoinPoint jp, Object object) throws Throwable {
|
|
||||||
logActivity(" creates new data: ", object);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@AfterReturning("execution(* com.jasamedika.medifirst2000.dao.*.save(*)) && args(object)")
|
|
||||||
public void logUpdateAction(JoinPoint jp, Object object) throws Throwable {
|
|
||||||
logActivity(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void logActivity(Object object) {
|
|
||||||
// get current user
|
|
||||||
LoginUser currentUser = loginUserService.getLoginUser();
|
|
||||||
|
|
||||||
buffer = new StringBuffer();
|
|
||||||
buffer.append(currentUser.getNamaUser());
|
|
||||||
|
|
||||||
// checking action
|
|
||||||
if (object instanceof BaseMaster) {/*
|
|
||||||
if (((BaseMaster) object).getId() == null) {
|
|
||||||
buffer.append(" inserts master record ");
|
|
||||||
} else {
|
|
||||||
buffer.append(" updates master record ");
|
|
||||||
}
|
|
||||||
*/} else if (object instanceof BaseTransaction) {
|
|
||||||
if (((BaseTransaction) object).getNoRec().isEmpty()) {
|
|
||||||
buffer.append(" insert transaction record ");
|
|
||||||
} else {
|
|
||||||
buffer.append(" updates transactionr record ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
detail = new StringBuffer();
|
|
||||||
try {
|
|
||||||
detail.append(ObjectUtil.getColumnNamesAndValues(object));
|
|
||||||
} catch(IllegalAccessException | IllegalArgumentException e) {
|
|
||||||
LOG.error("LogActivity exception: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
ActivityLog activityLog = new ActivityLog();
|
|
||||||
activityLog.setAction(buffer.toString());
|
|
||||||
activityLog.setDetail(detail.toString());
|
|
||||||
activityLogRepository.save(activityLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.logging;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.logging.dao.LoggingJdbcDaoImpl;
|
|
||||||
import com.jasamedika.medifirst2000.logging.entities.Logging;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Kelas Test
|
|
||||||
*
|
|
||||||
* @author Roberto
|
|
||||||
*/
|
|
||||||
public class MainLoggingApp {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
|
||||||
"classpath*:com/jasamedika/**/applicationContext.xml");
|
|
||||||
|
|
||||||
LoggingJdbcDaoImpl loggingJDBCTemplate = (LoggingJdbcDaoImpl) context
|
|
||||||
.getBean("loggingJdbcDaoImpl");
|
|
||||||
|
|
||||||
System.out.println("------Records Creation--------");
|
|
||||||
loggingJDBCTemplate.create("Nama 1", "Desc 1");
|
|
||||||
loggingJDBCTemplate.create("Nama 2", "Desc 2");
|
|
||||||
loggingJDBCTemplate.create("Nama 3", "Desc 3");
|
|
||||||
|
|
||||||
System.out.println("------Listing Multiple Records--------");
|
|
||||||
List<Logging> loggings = loggingJDBCTemplate.listLoggings();
|
|
||||||
for (Logging record : loggings) {
|
|
||||||
System.out.print("ID : " + record.getId());
|
|
||||||
System.out.print(", Nama : " + record.getNama());
|
|
||||||
System.out.println(", Deskripsi : " + record.getDeskripsi());
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("----Updating Record with ID = 2 -----");
|
|
||||||
loggingJDBCTemplate.update(2, "Updated Nama 2", "Updated Desc");
|
|
||||||
|
|
||||||
System.out.println("----Listing Record with ID = 2 -----");
|
|
||||||
Logging logging = loggingJDBCTemplate.getLogging(2);
|
|
||||||
System.out.print("ID : " + logging.getId());
|
|
||||||
System.out.print(", Nama : " + logging.getNama());
|
|
||||||
System.out.println(", Deskripsi : " + logging.getDeskripsi());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.logging;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ObjectUtil {
|
|
||||||
|
|
||||||
private ObjectUtil() {}
|
|
||||||
|
|
||||||
public static Map<String, Object> getColumnNamesAndValues(final Object object)
|
|
||||||
throws IllegalArgumentException, IllegalAccessException {
|
|
||||||
Class<? extends Object> c = object.getClass();
|
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
for (Field field : c.getDeclaredFields()) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
String name = field.getName();
|
|
||||||
Object value = field.get(object);
|
|
||||||
map.put(name, value);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,37 +1,18 @@
|
|||||||
package com.jasamedika.medifirst2000.logging.entities;
|
package com.jasamedika.medifirst2000.logging.entities;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entiti class for Logging, contoh saja
|
* Entity class for Logging
|
||||||
*
|
*
|
||||||
* @author Roberto
|
* @author Roberto
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public class Logging {
|
public class Logging {
|
||||||
|
|
||||||
private String deskripsi;
|
private String deskripsi;
|
||||||
private String nama;
|
private String nama;
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
public String getDeskripsi() {
|
|
||||||
return deskripsi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeskripsi(String deskripsi) {
|
|
||||||
this.deskripsi = deskripsi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNama() {
|
|
||||||
return nama;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNama(String nama) {
|
|
||||||
this.nama = nama;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,18 +1,18 @@
|
|||||||
package com.jasamedika.medifirst2000.logging.entities.wrapper;
|
package com.jasamedika.medifirst2000.logging.entities.wrapper;
|
||||||
|
|
||||||
|
import com.jasamedika.medifirst2000.logging.entities.Logging;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.logging.entities.Logging;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapper class for Logging, contoh saja
|
* Mapper class for Logging
|
||||||
*
|
*
|
||||||
* @author Roberto
|
* @author Roberto
|
||||||
*/
|
*/
|
||||||
public class LoggingMapper implements RowMapper<Logging> {
|
public class LoggingMapper implements RowMapper<Logging> {
|
||||||
|
|
||||||
public Logging mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Logging mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
Logging student = new Logging();
|
Logging student = new Logging();
|
||||||
student.setId(rs.getInt("id"));
|
student.setId(rs.getInt("id"));
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
package com.jasamedika.medifirst2000.logging.hibernate.async;
|
package com.jasamedika.medifirst2000.logging.hibernate.async;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Syamsu
|
||||||
|
*/
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public static final class HttpHeader {
|
public static final class HttpHeader {
|
||||||
public static final String SUPERVISING = "Supervising";
|
public static final String SUPERVISING = "Supervising";
|
||||||
public static final String MODULE = "Module";
|
public static final String MODULE = "Module";
|
||||||
public static final String FORM = "Form";
|
public static final String FORM = "Form";
|
||||||
public static final String ACTION = "Action";
|
public static final String ACTION = "Action";
|
||||||
|
public static final String URL_FORM = "AlamatUrlForm";
|
||||||
public static final String URL_FORM = "AlamatUrlForm"; // syamsu
|
public static final String KD_RUANGAN = "KdRuangan";
|
||||||
public static final String KD_RUANGAN = "KdRuangan"; // syamsu
|
public static final String KD_USER = "KdUser";
|
||||||
public static final String KD_USER = "KdUser"; // syamsu
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,23 +1,9 @@
|
|||||||
package com.jasamedika.medifirst2000.logging.hibernate.async;
|
package com.jasamedika.medifirst2000.logging.hibernate.async;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
@ -26,6 +12,17 @@ import org.springframework.security.core.Authentication;
|
|||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.jasamedika.medifirst2000.logging.hibernate.async.Constants.HttpHeader.SUPERVISING;
|
||||||
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -35,7 +32,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class LoggingSystemAsynchronous {
|
public class LoggingSystemAsynchronous {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoggingSystemAsynchronous.class);
|
private static final Logger LOGGER = getLogger(LoggingSystemAsynchronous.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
DataSource dataSource;
|
DataSource dataSource;
|
||||||
@ -43,25 +40,21 @@ public class LoggingSystemAsynchronous {
|
|||||||
@Autowired
|
@Autowired
|
||||||
HttpServletRequest request;
|
HttpServletRequest request;
|
||||||
|
|
||||||
Map<String, Holder> commit = new HashMap<String, Holder>();
|
Map<String, Holder> commit = new HashMap<>();
|
||||||
|
|
||||||
Object entity;
|
Object entity;
|
||||||
|
|
||||||
private static class Holder {
|
private static class Holder {
|
||||||
String userName;
|
String userName;
|
||||||
String superVisor;
|
String superVisor;
|
||||||
|
|
||||||
String host;
|
String host;
|
||||||
|
|
||||||
String noRecP;
|
String noRecP;
|
||||||
String detilCrud;
|
String detilCrud;
|
||||||
String jSonObject;
|
String jSonObject;
|
||||||
String method;
|
String method;
|
||||||
String object;
|
String object;
|
||||||
int kdHistoryLogin;
|
int kdHistoryLogin;
|
||||||
|
|
||||||
Date crudIn = new Date();
|
Date crudIn = new Date();
|
||||||
|
|
||||||
Object entity;
|
Object entity;
|
||||||
Serializable id;
|
Serializable id;
|
||||||
Object[] currentState;
|
Object[] currentState;
|
||||||
@ -74,14 +67,10 @@ public class LoggingSystemAsynchronous {
|
|||||||
final Object o = new Object();
|
final Object o = new Object();
|
||||||
|
|
||||||
public void saveSignOutLog(String userName, int IdPegawai) {
|
public void saveSignOutLog(String userName, int IdPegawai) {
|
||||||
|
|
||||||
JdbcTemplate jdbcTemplateObject = new JdbcTemplate(dataSource);
|
JdbcTemplate jdbcTemplateObject = new JdbcTemplate(dataSource);
|
||||||
|
|
||||||
asynchMethodtoLogSign(0, 0, userName, IdPegawai, jdbcTemplateObject, false);
|
asynchMethodtoLogSign(0, 0, userName, IdPegawai, jdbcTemplateObject, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SignIn Log
|
|
||||||
|
|
||||||
public void saveSignInLog(int modulaplikasiId, int ruanganId, String userName, int idPegawai) {
|
public void saveSignInLog(int modulaplikasiId, int ruanganId, String userName, int idPegawai) {
|
||||||
String currentPrincipalName = "";
|
String currentPrincipalName = "";
|
||||||
if (userName == null) {
|
if (userName == null) {
|
||||||
@ -117,26 +106,21 @@ public class LoggingSystemAsynchronous {
|
|||||||
+ "nextval('historyloginmodulaplikasi_m_id_seq'), ?, ?, "
|
+ "nextval('historyloginmodulaplikasi_m_id_seq'), ?, ?, "
|
||||||
+ "?, ?, ?, "
|
+ "?, ?, ?, "
|
||||||
+ "?, ?)";
|
+ "?, ?)";
|
||||||
|
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
|
||||||
String host = request.getRemoteHost();
|
String host = request.getRemoteHost();
|
||||||
// String KdRuangan = request.getHeader(Constants.HttpHeader.KD_RUANGAN) == null ? "0"
|
|
||||||
// : request.getHeader(Constants.HttpHeader.KD_RUANGAN);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
jdbcTemplateObject
|
jdbcTemplateObject
|
||||||
.update("INSERT INTO modulaplikasi_s (id, kdprofile, statusenabled, norec, kdmodulaplikasi, modulaplikasi) "
|
.update("INSERT INTO modulaplikasi_s (id, kdprofile, statusenabled, norec, kdmodulaplikasi, modulaplikasi) "
|
||||||
+ "VALUES (0, 0, true, '0000', '0', 'Belum Pilih Modul')");
|
+ "VALUES (0, 0, true, '0000', '0', 'Belum Pilih Modul')");
|
||||||
|
|
||||||
jdbcTemplateObject.update("UPDATE modulaplikasi_s SET kdprofile = 0 WHERE id = 0");
|
jdbcTemplateObject.update("UPDATE modulaplikasi_s SET kdprofile = 0 WHERE id = 0");
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
LOGGER.error(t.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
jdbcTemplateObject.update("UPDATE modulaplikasi_s SET kdprofile = 0 WHERE id = 0");
|
jdbcTemplateObject.update("UPDATE modulaplikasi_s SET kdprofile = 0 WHERE id = 0");
|
||||||
}catch(Throwable t){
|
}catch(Throwable t){
|
||||||
|
LOGGER.error(t.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -144,12 +128,13 @@ public class LoggingSystemAsynchronous {
|
|||||||
.update("INSERT INTO modulaplikasi_m (id, kdprofile, statusenabled, norec, kdmodulaplikasi, modulaplikasi) "
|
.update("INSERT INTO modulaplikasi_m (id, kdprofile, statusenabled, norec, kdmodulaplikasi, modulaplikasi) "
|
||||||
+ "VALUES (0, 0, true, '0000', '0', 'Belum Pilih Modul')");
|
+ "VALUES (0, 0, true, '0000', '0', 'Belum Pilih Modul')");
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
LOGGER.error(t.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
jdbcTemplateObject.update("UPDATE modulaplikasi_m SET kdprofile = 0 WHERE id = 0");
|
jdbcTemplateObject.update("UPDATE modulaplikasi_m SET kdprofile = 0 WHERE id = 0");
|
||||||
}catch(Throwable t){
|
}catch(Throwable t){
|
||||||
|
LOGGER.error(t.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -158,75 +143,56 @@ public class LoggingSystemAsynchronous {
|
|||||||
.update("INSERT INTO ruangan_m (id, kdprofile, statusenabled, norec, kdruangan, namaruangan, qruangan) "
|
.update("INSERT INTO ruangan_m (id, kdprofile, statusenabled, norec, kdruangan, namaruangan, qruangan) "
|
||||||
+ "VALUES (0, 0, true, '0000', '0', 'Belum Pilih Ruangan', 0)");
|
+ "VALUES (0, 0, true, '0000', '0', 'Belum Pilih Ruangan', 0)");
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
LOGGER.error(t.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
jdbcTemplateObject.update("UPDATE ruangan_m SET kdprofile = 0 WHERE id = 0");
|
jdbcTemplateObject.update("UPDATE ruangan_m SET kdprofile = 0 WHERE id = 0");
|
||||||
}catch(Throwable t){
|
}catch(Throwable t){
|
||||||
|
LOGGER.error(t.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
jdbcTemplateObject.update(SQL, 0, "0", "", uuid, "", UserName, idPegawai, modulaplikasiId, host,
|
jdbcTemplateObject.update(SQL, 0, "0", "", uuid, "", UserName, idPegawai, modulaplikasiId, host,
|
||||||
ruanganId, (signin)?new Date():null, (signin)?null:new Date());
|
ruanganId, (signin)?new Date():null, (signin)?null:new Date());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
LOGGER.error(t.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// nextval('historyloginmodulaplikasi_m_id_seq')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SignIn Log
|
|
||||||
|
|
||||||
/// Operation Log //
|
|
||||||
|
|
||||||
public void pushData(Object entity, Serializable id, Object[] currentState, Object[] previousState,
|
public void pushData(Object entity, Serializable id, Object[] currentState, Object[] previousState,
|
||||||
String[] propertyNames, Type[] types) {
|
String[] propertyNames, Type[] types) {
|
||||||
|
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
|
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
String currentPrincipalName = authentication.getName();
|
String currentPrincipalName = authentication.getName();
|
||||||
if ("anonymousUser".equals(currentPrincipalName)) {
|
if ("anonymousUser".equals(currentPrincipalName))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (o) {
|
synchronized (o) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
|
|
||||||
Holder h = new Holder();
|
Holder h = new Holder();
|
||||||
h.userName = currentPrincipalName;
|
h.userName = currentPrincipalName;
|
||||||
|
|
||||||
h.entity = entity;
|
h.entity = entity;
|
||||||
h.id = id;
|
h.id = id;
|
||||||
h.currentState = currentState;
|
h.currentState = currentState;
|
||||||
h.previousState = previousState;
|
h.previousState = previousState;
|
||||||
h.propertyNames = propertyNames;
|
h.propertyNames = propertyNames;
|
||||||
h.types = types;
|
h.types = types;
|
||||||
|
|
||||||
commit.put(h.entity.getClass().getName() + "." + currentPrincipalName, h);
|
commit.put(h.entity.getClass().getName() + "." + currentPrincipalName, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertData(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
|
public void insertData(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
|
||||||
|
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
|
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
String currentPrincipalName = authentication.getName();
|
String currentPrincipalName = authentication.getName();
|
||||||
if ("anonymousUser".equals(currentPrincipalName)) {
|
if ("anonymousUser".equals(currentPrincipalName))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (o) {
|
synchronized (o) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
|
|
||||||
Holder h = new Holder();
|
Holder h = new Holder();
|
||||||
h.userName = currentPrincipalName;
|
h.userName = currentPrincipalName;
|
||||||
|
|
||||||
h.entity = entity;
|
h.entity = entity;
|
||||||
h.id = id;
|
h.id = id;
|
||||||
h.state = state;
|
h.state = state;
|
||||||
@ -234,30 +200,22 @@ public class LoggingSystemAsynchronous {
|
|||||||
h.types = types;
|
h.types = types;
|
||||||
h.previousState = new Object[state.length];
|
h.previousState = new Object[state.length];
|
||||||
h.currentState = state;
|
h.currentState = state;
|
||||||
|
|
||||||
commit.put(h.entity.getClass().getName() + "." + currentPrincipalName, h);
|
commit.put(h.entity.getClass().getName() + "." + currentPrincipalName, h);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void deleteData(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
|
public void deleteData(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
|
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
String currentPrincipalName = authentication.getName();
|
String currentPrincipalName = authentication.getName();
|
||||||
if ("anonymousUser".equals(currentPrincipalName)) {
|
if ("anonymousUser".equals(currentPrincipalName))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (o) {
|
synchronized (o) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
|
|
||||||
Holder h = new Holder();
|
Holder h = new Holder();
|
||||||
h.userName = currentPrincipalName;
|
h.userName = currentPrincipalName;
|
||||||
|
|
||||||
h.entity = entity;
|
h.entity = entity;
|
||||||
h.id = id;
|
h.id = id;
|
||||||
h.state = state;
|
h.state = state;
|
||||||
@ -265,26 +223,18 @@ public class LoggingSystemAsynchronous {
|
|||||||
h.types = types;
|
h.types = types;
|
||||||
h.previousState = state;
|
h.previousState = state;
|
||||||
h.currentState = new Object[state.length];
|
h.currentState = new Object[state.length];
|
||||||
|
|
||||||
commit.put(h.entity.getClass().getName() + "." + currentPrincipalName, h);
|
commit.put(h.entity.getClass().getName() + "." + currentPrincipalName, h);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveOperationLog(String sql) {
|
public void saveOperationLog(String sql) {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
|
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
String currentPrincipalName = authentication.getName();
|
String currentPrincipalName = authentication.getName();
|
||||||
if ("anonymousUser".equals(currentPrincipalName)) {
|
if ("anonymousUser".equals(currentPrincipalName))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
JdbcTemplate jdbcTemplateObject = new JdbcTemplate(dataSource);
|
JdbcTemplate jdbcTemplateObject = new JdbcTemplate(dataSource);
|
||||||
|
|
||||||
asynchMethodtoCreatedLog(sql, currentPrincipalName, jdbcTemplateObject, request);
|
asynchMethodtoCreatedLog(sql, currentPrincipalName, jdbcTemplateObject, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +242,7 @@ public class LoggingSystemAsynchronous {
|
|||||||
try{
|
try{
|
||||||
jObject.put(key, value);
|
jObject.put(key, value);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
LOGGER.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +250,7 @@ public class LoggingSystemAsynchronous {
|
|||||||
try{
|
try{
|
||||||
jObject.put(key, value);
|
jObject.put(key, value);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
LOGGER.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +258,7 @@ public class LoggingSystemAsynchronous {
|
|||||||
try{
|
try{
|
||||||
jObject.put(key, value);
|
jObject.put(key, value);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
LOGGER.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,34 +266,25 @@ public class LoggingSystemAsynchronous {
|
|||||||
try{
|
try{
|
||||||
jArray.put(value);
|
jArray.put(value);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
LOGGER.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void asynchMethodtoCreatedLog(String sql, String UserName, JdbcTemplate jdbcTemplateObject,
|
public void asynchMethodtoCreatedLog(String sql, String UserName, JdbcTemplate jdbcTemplateObject,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
Holder h = commit.get(entity.getClass().getName() + "." + UserName);
|
Holder h = commit.get(entity.getClass().getName() + "." + UserName);
|
||||||
destroy();
|
destroy();
|
||||||
if (h != null) {
|
if (h != null) {
|
||||||
String method = "X";
|
String method = "X";
|
||||||
String object = "";
|
String object = "";
|
||||||
|
|
||||||
StringBuilder infoBuilder = new StringBuilder();
|
StringBuilder infoBuilder = new StringBuilder();
|
||||||
StringBuilder jSonObject = new StringBuilder();
|
StringBuilder jSonObject = new StringBuilder();
|
||||||
|
|
||||||
JSONObject jObject = new JSONObject();
|
JSONObject jObject = new JSONObject();
|
||||||
|
|
||||||
|
|
||||||
jSonObject.append("{\n");
|
jSonObject.append("{\n");
|
||||||
|
|
||||||
String host = request.getRemoteHost();
|
String host = request.getRemoteHost();
|
||||||
|
|
||||||
|
|
||||||
String infoOperasi = "Pengambilan";
|
String infoOperasi = "Pengambilan";
|
||||||
|
|
||||||
if (sql.toUpperCase().contains("INSERT ")) {
|
if (sql.toUpperCase().contains("INSERT ")) {
|
||||||
method = "I";
|
method = "I";
|
||||||
infoBuilder.append("INSERT METOD").append("\n");
|
infoBuilder.append("INSERT METOD").append("\n");
|
||||||
@ -363,88 +304,58 @@ public class LoggingSystemAsynchronous {
|
|||||||
putStringToJSONObject(jObject, "m", "D");
|
putStringToJSONObject(jObject, "m", "D");
|
||||||
infoOperasi = "Penghapusan data";
|
infoOperasi = "Penghapusan data";
|
||||||
}
|
}
|
||||||
|
boolean isSupervising = (request.getHeader(SUPERVISING) != null)
|
||||||
// String AlamatUrlForm =
|
&& ("true".equals(request.getHeader(SUPERVISING)));
|
||||||
// request.getHeader(Constants.HttpHeader.URL_FORM) == null ? ""
|
|
||||||
// : request.getHeader(Constants.HttpHeader.URL_FORM);
|
|
||||||
// String KdRuangan =
|
|
||||||
// request.getHeader(Constants.HttpHeader.KD_RUANGAN) == null ?
|
|
||||||
// "0" : request.getHeader(Constants.HttpHeader.KD_RUANGAN);
|
|
||||||
|
|
||||||
Boolean isSupervising = (request.getHeader(Constants.HttpHeader.SUPERVISING) != null)
|
|
||||||
&& ("true".equals(request.getHeader(Constants.HttpHeader.SUPERVISING))) ? true : false;
|
|
||||||
|
|
||||||
String SQL = "SELECT id FROM HistoryLoginModulAplikasi_S WHERE Kduser = ? AND TglLogin IS NOT NULL ORDER BY id DESC, TglLogin DESC LIMIT 1";
|
String SQL = "SELECT id FROM HistoryLoginModulAplikasi_S WHERE Kduser = ? AND TglLogin IS NOT NULL ORDER BY id DESC, TglLogin DESC LIMIT 1";
|
||||||
int kdHistoryLogin = 1;
|
int kdHistoryLogin = 1;
|
||||||
|
|
||||||
if (isSupervising) {
|
if (isSupervising) {
|
||||||
try {
|
try {
|
||||||
String Username = request.getHeader(Constants.HttpHeader.KD_USER) == null ? ""
|
String Username = request.getHeader(Constants.HttpHeader.KD_USER) == null ? ""
|
||||||
: request.getHeader(Constants.HttpHeader.KD_USER);
|
: request.getHeader(Constants.HttpHeader.KD_USER);
|
||||||
kdHistoryLogin = jdbcTemplateObject.queryForObject(SQL, new Object[] { Username },
|
kdHistoryLogin = jdbcTemplateObject.queryForObject(SQL, new Object[] { Username },
|
||||||
Integer.class);
|
Integer.class);
|
||||||
|
infoBuilder.append(infoOperasi).append(" oleh '").append(Username).append("'").append("\n");
|
||||||
|
infoBuilder.append("Supervisor ").append(UserName).append("\n");
|
||||||
infoBuilder.append(infoOperasi + " oleh '" + Username + "'").append("\n");
|
jSonObject.append("'user':'").append(Username).append("',\n");
|
||||||
infoBuilder.append("Supervisor " + UserName).append("\n");
|
jSonObject.append("'supervisor':'").append(UserName).append("',\n");
|
||||||
|
|
||||||
jSonObject.append("'user':'" + Username + "',\n");
|
|
||||||
jSonObject.append("'supervisor':'" + UserName + "',\n");
|
|
||||||
|
|
||||||
putStringToJSONObject(jObject, "user", Username);
|
putStringToJSONObject(jObject, "user", Username);
|
||||||
putStringToJSONObject(jObject, "supervisor", UserName);
|
putStringToJSONObject(jObject, "supervisor", UserName);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
LOGGER.error(t.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
kdHistoryLogin = jdbcTemplateObject.queryForObject(SQL, new Object[] { UserName },
|
kdHistoryLogin = jdbcTemplateObject.queryForObject(SQL, new Object[] { UserName },
|
||||||
Integer.class);
|
Integer.class);
|
||||||
infoBuilder.append(infoOperasi + " oleh '" + UserName + "'").append("\n");
|
infoBuilder.append(infoOperasi).append(" oleh '").append(UserName).append("'").append("\n");
|
||||||
jSonObject.append("'user':'" + UserName + "',\n");
|
jSonObject.append("'user':'").append(UserName).append("',\n");
|
||||||
jSonObject.append("'supervisor':'-',\n");
|
jSonObject.append("'supervisor':'-',\n");
|
||||||
|
|
||||||
putStringToJSONObject(jObject, "user", UserName);
|
putStringToJSONObject(jObject, "user", UserName);
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
LOGGER.error(t.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Table table = h.entity.getClass().getAnnotation(Table.class);
|
Table table = h.entity.getClass().getAnnotation(Table.class);
|
||||||
|
if ("ActivityPegawai".equals(h.entity.getClass().getSimpleName()))
|
||||||
if ("ActivityPegawai".equals(h.entity.getClass().getSimpleName())) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
String className = h.entity.getClass().getName();
|
String className = h.entity.getClass().getName();
|
||||||
object = className;
|
object = className;
|
||||||
|
infoBuilder.append("Di class '").append(className);
|
||||||
infoBuilder.append("Di class '" + className);
|
infoBuilder.append("' atau entity '").append(h.entity.getClass().getSimpleName());
|
||||||
infoBuilder.append("' atau entity '" + h.entity.getClass().getSimpleName());
|
infoBuilder.append("' pada table '").append(table.name()).append("'.").append("\n");
|
||||||
infoBuilder.append("' pada table '" + table.name() + "'.").append("\n");
|
|
||||||
infoBuilder.append("Yang berubah : ").append("\n");
|
infoBuilder.append("Yang berubah : ").append("\n");
|
||||||
|
jSonObject.append("'class':'").append(className).append("', \n");
|
||||||
jSonObject.append("'class':'" + className + "', \n");
|
jSonObject.append("'entity':'").append(h.entity.getClass().getSimpleName()).append("', \n");
|
||||||
jSonObject.append("'entity':'" + h.entity.getClass().getSimpleName() + "', \n");
|
jSonObject.append("'table':'").append(table.name()).append("', \n");
|
||||||
jSonObject.append("'table':'" + table.name() + "', \n");
|
|
||||||
|
|
||||||
putStringToJSONObject(jObject, "class", className);
|
putStringToJSONObject(jObject, "class", className);
|
||||||
putStringToJSONObject(jObject, "entity", h.entity.getClass().getSimpleName());
|
putStringToJSONObject(jObject, "entity", h.entity.getClass().getSimpleName());
|
||||||
putStringToJSONObject(jObject, "table", table.name());
|
putStringToJSONObject(jObject, "table", table.name());
|
||||||
|
|
||||||
String noRecP = "";
|
String noRecP = "";
|
||||||
int idP = 0;
|
int idP = 0;
|
||||||
JSONArray jArray = new JSONArray();
|
JSONArray jArray = new JSONArray();
|
||||||
|
|
||||||
jSonObject.append("'property' : [");
|
jSonObject.append("'property' : [");
|
||||||
|
|
||||||
putJSONArrayToJSONObject(jObject,"property", jArray);
|
putJSONArrayToJSONObject(jObject,"property", jArray);
|
||||||
|
|
||||||
for (int i = 0; i < h.propertyNames.length; i++) {
|
for (int i = 0; i < h.propertyNames.length; i++) {
|
||||||
|
|
||||||
if ("norec".equalsIgnoreCase(h.propertyNames[i].trim())) {
|
if ("norec".equalsIgnoreCase(h.propertyNames[i].trim())) {
|
||||||
if (h.previousState[i] != null) {
|
if (h.previousState[i] != null) {
|
||||||
noRecP = String.valueOf(h.previousState[i]);
|
noRecP = String.valueOf(h.previousState[i]);
|
||||||
@ -454,7 +365,6 @@ public class LoggingSystemAsynchronous {
|
|||||||
noRecP = "null";
|
noRecP = "null";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("id".equalsIgnoreCase(h.propertyNames[i].trim())) {
|
if ("id".equalsIgnoreCase(h.propertyNames[i].trim())) {
|
||||||
if (h.previousState[i] != null) {
|
if (h.previousState[i] != null) {
|
||||||
idP = (Integer) h.previousState[i];
|
idP = (Integer) h.previousState[i];
|
||||||
@ -464,10 +374,9 @@ public class LoggingSystemAsynchronous {
|
|||||||
idP = 0;
|
idP = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h.previousState.length > i && h.currentState.length > i) {
|
if (h.previousState.length > i && h.currentState.length > i) {
|
||||||
String columName = "";
|
String columName = "";
|
||||||
Class<? extends Object> cl = h.entity.getClass();
|
Class<?> cl = h.entity.getClass();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
try {
|
try {
|
||||||
Field field = cl.getDeclaredField(h.propertyNames[i]);
|
Field field = cl.getDeclaredField(h.propertyNames[i]);
|
||||||
@ -494,26 +403,18 @@ public class LoggingSystemAsynchronous {
|
|||||||
addObject = showPrevNotNull(pObject, infoBuilder, jSonObject, columName, h.propertyNames[i], h.previousState[i]);
|
addObject = showPrevNotNull(pObject, infoBuilder, jSonObject, columName, h.propertyNames[i], h.previousState[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (addObject)
|
||||||
if (addObject){
|
|
||||||
putJSONObjectToJSONArray(jArray, pObject);
|
putJSONObjectToJSONArray(jArray, pObject);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jSonObject.append("{}],\n");
|
jSonObject.append("{}],\n");
|
||||||
jSonObject.append("'id' : '").append(idP).append("',\n");
|
jSonObject.append("'id' : '").append(idP).append("',\n");
|
||||||
|
|
||||||
putIntToJSONObject(jObject, "id", idP);
|
putIntToJSONObject(jObject, "id", idP);
|
||||||
|
|
||||||
jSonObject.append("'noRecP' : '").append(noRecP).append("'");
|
jSonObject.append("'noRecP' : '").append(noRecP).append("'");
|
||||||
putStringToJSONObject(jObject, "noRecP", noRecP);
|
putStringToJSONObject(jObject, "noRecP", noRecP);
|
||||||
|
infoBuilder.append("Dengan id : ").append(idP).append(" dan noRecP : ").append(noRecP);
|
||||||
infoBuilder.append("Dengan id : " + idP + " dan noRecP : " + noRecP);
|
infoBuilder.append(" dari host : ").append(host).append(".").append("\n");
|
||||||
infoBuilder.append(" dari host : " + host + ".").append("\n");
|
|
||||||
|
|
||||||
jSonObject.append("\n}\n");
|
jSonObject.append("\n}\n");
|
||||||
|
|
||||||
|
|
||||||
h.host = host;
|
h.host = host;
|
||||||
h.detilCrud = infoBuilder.toString();
|
h.detilCrud = infoBuilder.toString();
|
||||||
h.noRecP = noRecP;
|
h.noRecP = noRecP;
|
||||||
@ -521,42 +422,31 @@ public class LoggingSystemAsynchronous {
|
|||||||
h.method = method;
|
h.method = method;
|
||||||
h.object = object;
|
h.object = object;
|
||||||
h.kdHistoryLogin = kdHistoryLogin;
|
h.kdHistoryLogin = kdHistoryLogin;
|
||||||
|
|
||||||
commit.put(className, h);
|
commit.put(className, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(Iterator entities) {
|
public void save(Iterator<?> entities) {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
|
if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
String currentPrincipalName = authentication.getName();
|
String currentPrincipalName = authentication.getName();
|
||||||
if ("anonymousUser".equals(currentPrincipalName)) {
|
if ("anonymousUser".equals(currentPrincipalName))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
JdbcTemplate jdbcTemplateObject = new JdbcTemplate(dataSource);
|
JdbcTemplate jdbcTemplateObject = new JdbcTemplate(dataSource);
|
||||||
AsynchMethodSave(entities, jdbcTemplateObject, currentPrincipalName);
|
AsynchMethodSave(entities, jdbcTemplateObject, currentPrincipalName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void AsynchMethodSave(Iterator entities, JdbcTemplate jdbcTemplateObject, String currentPrincipalName) {
|
public void AsynchMethodSave(Iterator<?> entities, JdbcTemplate jdbcTemplateObject, String currentPrincipalName) {
|
||||||
while (entities.hasNext()) {
|
while (entities.hasNext()) {
|
||||||
String keyName = entities.next().getClass().getName() + "." + currentPrincipalName;
|
String keyName = entities.next().getClass().getName() + "." + currentPrincipalName;
|
||||||
Holder h = commit.get(keyName);
|
Holder h = commit.get(keyName);
|
||||||
|
|
||||||
if (h != null) {
|
if (h != null) {
|
||||||
|
|
||||||
// LOGGER.info("\n" + h.detilCrud);
|
|
||||||
// LOGGER.info("\n" + h.jSonObject);
|
|
||||||
|
|
||||||
addLogData(jdbcTemplateObject, h.noRecP, h.jSonObject, h.method, h.object, h.kdHistoryLogin, h.crudIn);
|
addLogData(jdbcTemplateObject, h.noRecP, h.jSonObject, h.method, h.object, h.kdHistoryLogin, h.crudIn);
|
||||||
commit.put(keyName, null);
|
commit.put(keyName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,24 +457,16 @@ public class LoggingSystemAsynchronous {
|
|||||||
+ "NoRecord, TglCrudIn, TglCrudOut) " + "VALUES "
|
+ "NoRecord, TglCrudIn, TglCrudOut) " + "VALUES "
|
||||||
+ "( nextval('historyloginuser_m_id_seq'), ?, true, ?, ?," + "?, ?, " + "?, " + "?, ?, ?, "
|
+ "( nextval('historyloginuser_m_id_seq'), ?, true, ?, ?," + "?, ?, " + "?, " + "?, ?, ?, "
|
||||||
+ "?, ?, ?)";
|
+ "?, ?, ?)";
|
||||||
|
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
jdbcTemplateObject.update(SQL, 0, "0", "", uuid, "",
|
jdbcTemplateObject.update(SQL, 0, "0", "", uuid, "",
|
||||||
jSonObject.replaceAll("\n", "").replaceAll("\t", ""), kdHistoryLogin, method,
|
jSonObject.replaceAll("\n", "").replaceAll("\t", ""), kdHistoryLogin, method,
|
||||||
object, NoRecP, crudIn, new Date());
|
object, NoRecP, crudIn, new Date());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// try{
|
LOGGER.error(t.getMessage());
|
||||||
// LOGGER.warn("operasi 'LogData' gagal di log karena " + t.getMessage());
|
|
||||||
// }catch(Exception e){
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////// private method
|
|
||||||
|
|
||||||
private void destroy() {
|
private void destroy() {
|
||||||
synchronized (o) {
|
synchronized (o) {
|
||||||
this.entity = null;
|
this.entity = null;
|
||||||
@ -593,50 +475,40 @@ public class LoggingSystemAsynchronous {
|
|||||||
|
|
||||||
private boolean showObj(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
private boolean showObj(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
||||||
Object prev, Object curr) {
|
Object prev, Object curr) {
|
||||||
|
|
||||||
jSonObject.append("{\n");
|
jSonObject.append("{\n");
|
||||||
jSonObject.append("\t'name' : '" + property + "', \n");
|
jSonObject.append("\t'name' : '").append(property).append("', \n");
|
||||||
jSonObject.append("\t'column' : '" + columName + "', \n");
|
jSonObject.append("\t'column' : '").append(columName).append("', \n");
|
||||||
jSonObject.append("\t'oldData' : '" + prev + "', \n");
|
jSonObject.append("\t'oldData' : '").append(prev).append("', \n");
|
||||||
jSonObject.append("\t'newData' : '" + curr + "', \n");
|
jSonObject.append("\t'newData' : '").append(curr).append("', \n");
|
||||||
jSonObject.append("},\n");
|
jSonObject.append("},\n");
|
||||||
|
|
||||||
putStringToJSONObject(pObject, "name", property);
|
putStringToJSONObject(pObject, "name", property);
|
||||||
putStringToJSONObject(pObject, "column", columName);
|
putStringToJSONObject(pObject, "column", columName);
|
||||||
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
|
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
|
||||||
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
|
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
|
||||||
|
infoBuilder.append(property).append(" : Sebelumnya ").append(prev).append(" menjadi ").append(curr).append("\n");
|
||||||
infoBuilder.append(property + " : Sebelumnya " + prev + " menjadi " + curr).append("\n");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showDate(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
private boolean showDate(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
||||||
Date prev, Date curr) {
|
Date prev, Date curr) {
|
||||||
|
|
||||||
if (prev.compareTo(curr) != 0) {
|
if (prev.compareTo(curr) != 0) {
|
||||||
infoBuilder.append(property + " : Sebelumnya " + prev + " menjadi " + curr).append("\n");
|
infoBuilder.append(property).append(" : Sebelumnya ").append(prev).append(" menjadi ").append(curr).append("\n");
|
||||||
|
|
||||||
jSonObject.append("{\n");
|
jSonObject.append("{\n");
|
||||||
jSonObject.append("\t'name' : '" + property + "', \n");
|
jSonObject.append("\t'name' : '").append(property).append("', \n");
|
||||||
jSonObject.append("\t'column' : '" + columName + "', \n");
|
jSonObject.append("\t'column' : '").append(columName).append("', \n");
|
||||||
jSonObject.append("\t'oldData' : '" + prev + "', \n");
|
jSonObject.append("\t'oldData' : '").append(prev).append("', \n");
|
||||||
jSonObject.append("\t'newData' : '" + curr + "', \n");
|
jSonObject.append("\t'newData' : '").append(curr).append("', \n");
|
||||||
jSonObject.append("},\n");
|
jSonObject.append("},\n");
|
||||||
|
|
||||||
putStringToJSONObject(pObject, "name", property);
|
putStringToJSONObject(pObject, "name", property);
|
||||||
putStringToJSONObject(pObject, "column", columName);
|
putStringToJSONObject(pObject, "column", columName);
|
||||||
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
|
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
|
||||||
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
|
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int whoIsNull(Object o1, Object o2) {
|
private int whoIsNull(Object o1, Object o2) {
|
||||||
|
|
||||||
if (o1 == null && o2 == null) {
|
if (o1 == null && o2 == null) {
|
||||||
return 3;
|
return 3;
|
||||||
} else if (o1 == null) {
|
} else if (o1 == null) {
|
||||||
@ -646,106 +518,84 @@ public class LoggingSystemAsynchronous {
|
|||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showPrevNotNull(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
private boolean showPrevNotNull(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
||||||
Object prev) {
|
Object prev) {
|
||||||
if (!property.endsWith("Id")) {
|
if (!property.endsWith("Id")) {
|
||||||
jSonObject.append("{\n");
|
jSonObject.append("{\n");
|
||||||
jSonObject.append("\t'name' : '" + property + "', \n");
|
jSonObject.append("\t'name' : '").append(property).append("', \n");
|
||||||
jSonObject.append("\t'column' : '" + columName + "', \n");
|
jSonObject.append("\t'column' : '").append(columName).append("', \n");
|
||||||
jSonObject.append("\t'oldData' : '" + prev + "', \n");
|
jSonObject.append("\t'oldData' : '").append(prev).append("', \n");
|
||||||
jSonObject.append("\t'newData' : 'null', \n");
|
jSonObject.append("\t'newData' : 'null', \n");
|
||||||
jSonObject.append("},\n");
|
jSonObject.append("},\n");
|
||||||
|
|
||||||
putStringToJSONObject(pObject, "name", property);
|
putStringToJSONObject(pObject, "name", property);
|
||||||
putStringToJSONObject(pObject, "column", columName);
|
putStringToJSONObject(pObject, "column", columName);
|
||||||
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
|
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
|
||||||
putStringToJSONObject(pObject, "newData", "null");
|
putStringToJSONObject(pObject, "newData", "null");
|
||||||
|
infoBuilder.append("Property : ").append(property).append(", column name : ").append(columName).append(", Sebelumnya ").append(prev).append(" menjadi null ").append("\n");
|
||||||
infoBuilder.append("Property : " + property + ", column name : " + columName + ", Sebelumnya " + prev
|
|
||||||
+ " menjadi null ").append("\n");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showCurNotNull(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
private boolean showCurNotNull(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
||||||
Object curr) {
|
Object curr) {
|
||||||
jSonObject.append("{\n");
|
jSonObject.append("{\n");
|
||||||
jSonObject.append("\t'name' : '" + property + "', \n");
|
jSonObject.append("\t'name' : '").append(property).append("', \n");
|
||||||
jSonObject.append("\t'column' : '" + columName + "', \n");
|
jSonObject.append("\t'column' : '").append(columName).append("', \n");
|
||||||
jSonObject.append("\t'oldData' : 'null', \n");
|
jSonObject.append("\t'oldData' : 'null', \n");
|
||||||
jSonObject.append("\t'newData' : '" + curr + "', \n");
|
jSonObject.append("\t'newData' : '").append(curr).append("', \n");
|
||||||
jSonObject.append("},\n");
|
jSonObject.append("},\n");
|
||||||
|
|
||||||
putStringToJSONObject(pObject, "name", property);
|
putStringToJSONObject(pObject, "name", property);
|
||||||
putStringToJSONObject(pObject, "column", columName);
|
putStringToJSONObject(pObject, "column", columName);
|
||||||
putStringToJSONObject(pObject, "oldData", "null");
|
putStringToJSONObject(pObject, "oldData", "null");
|
||||||
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
|
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
|
||||||
|
infoBuilder.append("Property : ").append(property).append(", column name ").append(columName).append(", Sebelumnya null menjadi ").append(curr)
|
||||||
infoBuilder.append("Property : " + property + ", column name " + columName + ", Sebelumnya null menjadi " + curr)
|
|
||||||
.append("\n");
|
.append("\n");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showNotAllNull(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
private boolean showNotAllNull(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
|
||||||
Object prev, Object curr) {
|
Object prev, Object curr) {
|
||||||
|
|
||||||
if (prev instanceof String || curr instanceof Character) {
|
if (prev instanceof String || curr instanceof Character) {
|
||||||
if (!(String.valueOf(prev)).equals(String.valueOf(curr))) {
|
if (!(String.valueOf(prev)).equals(String.valueOf(curr))) {
|
||||||
jSonObject.append("{\n");
|
jSonObject.append("{\n");
|
||||||
jSonObject.append("\t'name' : '" + property + "', \n");
|
jSonObject.append("\t'name' : '").append(property).append("', \n");
|
||||||
jSonObject.append("\t'column' : '" + columName + "', \n");
|
jSonObject.append("\t'column' : '").append(columName).append("', \n");
|
||||||
jSonObject.append("\t'oldData' : '" + prev + "', \n");
|
jSonObject.append("\t'oldData' : '").append(prev).append("', \n");
|
||||||
jSonObject.append("\t'newData' : '" + curr + "', \n");
|
jSonObject.append("\t'newData' : '").append(curr).append("', \n");
|
||||||
jSonObject.append("},\n");
|
jSonObject.append("},\n");
|
||||||
|
|
||||||
putStringToJSONObject(pObject, "name", property);
|
putStringToJSONObject(pObject, "name", property);
|
||||||
putStringToJSONObject(pObject, "column", columName);
|
putStringToJSONObject(pObject, "column", columName);
|
||||||
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
|
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
|
||||||
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
|
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
|
||||||
|
infoBuilder.append("Property : ").append(property).append(", column name ").append(columName).append(", Sebelumnya ").append(prev).append(" menjadi ").append(curr).append("\n");
|
||||||
infoBuilder.append("Property : " + property + ", column name " + columName + ", Sebelumnya " + prev
|
|
||||||
+ " menjadi " + curr).append("\n");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (prev instanceof Byte || curr instanceof Byte) {
|
if (prev instanceof Byte || curr instanceof Byte) {
|
||||||
if (Byte.compare((byte) prev, (byte) curr) != 0) {
|
if ((byte) prev != (byte) curr)
|
||||||
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
||||||
}
|
|
||||||
} else if (prev instanceof Short || curr instanceof Short) {
|
} else if (prev instanceof Short || curr instanceof Short) {
|
||||||
if (Short.compare((short) prev, (short) curr) != 0) {
|
if ((short) prev != (short) curr)
|
||||||
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
||||||
}
|
|
||||||
} else if (prev instanceof Integer || curr instanceof Integer) {
|
} else if (prev instanceof Integer || curr instanceof Integer) {
|
||||||
if (Integer.compare((int) prev, (int) curr) != 0) {
|
if ((int) prev != (int) curr)
|
||||||
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
||||||
}
|
|
||||||
} else if (prev instanceof Long || curr instanceof Long) {
|
} else if (prev instanceof Long || curr instanceof Long) {
|
||||||
if (Long.compare((long) prev, (long) curr) != 0) {
|
if ((long) prev != (long) curr)
|
||||||
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
||||||
}
|
|
||||||
} else if (prev instanceof Float || curr instanceof Float) {
|
} else if (prev instanceof Float || curr instanceof Float) {
|
||||||
if (Float.compare((float) prev, (float) curr) != 0) {
|
if (Float.compare((float) prev, (float) curr) != 0)
|
||||||
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
||||||
}
|
|
||||||
} else if (prev instanceof Double || curr instanceof Double) {
|
} else if (prev instanceof Double || curr instanceof Double) {
|
||||||
if (Double.compare((double) prev, (double) curr) != 0) {
|
if (Double.compare((double) prev, (double) curr) != 0)
|
||||||
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
return showObj(pObject, infoBuilder, jSonObject, columName, property, prev, curr);
|
||||||
}
|
} else if (prev instanceof Date && curr instanceof Date) {
|
||||||
} else if (prev instanceof Date || curr instanceof Date) {
|
return showDate(pObject, infoBuilder, jSonObject, columName, property, (Date) prev, (Date) curr);
|
||||||
return showDate(pObject, infoBuilder, jSonObject, columName, property, (Date) prev, (Date) curr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import com.jasamedika.medifirst2000.logging.hibernate.async.LoggingSystemAsynchr
|
|||||||
*
|
*
|
||||||
* @author Syamsu
|
* @author Syamsu
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class HibernateInterceptorBeansHolder {
|
public class HibernateInterceptorBeansHolder {
|
||||||
|
|
||||||
@ -18,6 +17,5 @@ public class HibernateInterceptorBeansHolder {
|
|||||||
@Autowired
|
@Autowired
|
||||||
public void setLoggingSystemAsynchronous(LoggingSystemAsynchronous logging) {
|
public void setLoggingSystemAsynchronous(LoggingSystemAsynchronous logging) {
|
||||||
HibernateInterceptorBeansHolder.loggingSystemAsynchronous = logging;
|
HibernateInterceptorBeansHolder.loggingSystemAsynchronous = logging;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import java.io.Serializable;
|
|||||||
* @author Syamsu
|
* @author Syamsu
|
||||||
*/
|
*/
|
||||||
public class HibernateInterceptor extends EmptyInterceptor {
|
public class HibernateInterceptor extends EmptyInterceptor {
|
||||||
|
|
||||||
private static final long serialVersionUID = 5478574918838397131L;
|
private static final long serialVersionUID = 5478574918838397131L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,14 +43,4 @@ public class HibernateInterceptor extends EmptyInterceptor {
|
|||||||
HibernateInterceptorBeansHolder.loggingSystemAsynchronous.saveOperationLog(sql);
|
HibernateInterceptorBeansHolder.loggingSystemAsynchronous.saveOperationLog(sql);
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Commented by Salman 2024/01/30
|
|
||||||
*
|
|
||||||
* @Desc: Logging sudah tidak dipakai, migrasi ke laravel
|
|
||||||
*/
|
|
||||||
// @Override
|
|
||||||
// public void postFlush(Iterator entities) throws CallbackException {
|
|
||||||
// HibernateInterceptorBeansHolder.loggingSystemAsynchronous.save(entities);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,27 +1,27 @@
|
|||||||
package com.jasamedika.medifirst2000.notification;
|
package com.jasamedika.medifirst2000.notification;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.entities.Pegawai;
|
import com.jasamedika.medifirst2000.entities.Pegawai;
|
||||||
import com.jasamedika.medifirst2000.entities.Ruangan;
|
import com.jasamedika.medifirst2000.entities.Ruangan;
|
||||||
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
|
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
|
||||||
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public interface MessagePublisher<T, V> {
|
public interface MessagePublisher<T, V> {
|
||||||
public String GetSettingDataFixed(String prefix);
|
|
||||||
public void sendDirectNotification(final Map<T,V> data);
|
interface RabbitHole {
|
||||||
|
void connect(String host, String userName, String password, String routingKeyAndQueueName) throws Exception;
|
||||||
public RabbitHole getRabbitHole();
|
void sendRabbitMQNotification(String pesan) throws Exception;
|
||||||
|
void close() throws Exception;
|
||||||
public static interface RabbitHole {
|
void sendNotif(MessagePublisher.RabbitHole rabbitHole, Ruangan dariRuangan, Pegawai pegawai,
|
||||||
public void connect(String host, String userName, String password, String routingKeyAndQueueName) throws Exception;
|
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService,
|
||||||
public void sendRabbitMQNotification(String pesan) throws Exception;
|
Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception;
|
||||||
public void close() throws Exception;
|
|
||||||
public void sendNotif(MessagePublisher.RabbitHole rabbitHole, Ruangan dariRuangan, Pegawai pegawai,
|
|
||||||
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService,
|
|
||||||
Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RabbitHole getRabbitHole();
|
||||||
|
|
||||||
|
String getSettingDataFixed(String prefix);
|
||||||
|
|
||||||
|
void sendDirectNotification(final Map<T, V> data);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,9 @@ package com.jasamedika.medifirst2000.notification;
|
|||||||
import com.rabbitmq.client.Consumer;
|
import com.rabbitmq.client.Consumer;
|
||||||
|
|
||||||
public interface MessageSubscriber {
|
public interface MessageSubscriber {
|
||||||
public void startRabbitMQNotification(String host, String routingKeyAndQueueName) throws Exception;
|
|
||||||
public void listenRabbitMQNotification(String routingKeyAndQueueName, Consumer consumer, boolean autoAck) throws Exception;
|
void startRabbitMQNotification(String host, String routingKeyAndQueueName) throws Exception;
|
||||||
public void stopRabbitMQNotification() throws Exception;
|
void listenRabbitMQNotification(String routingKeyAndQueueName, Consumer consumer, boolean autoAck) throws Exception;
|
||||||
public Consumer getDefaultConsumer();
|
void stopRabbitMQNotification() throws Exception;
|
||||||
|
Consumer getDefaultConsumer();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,53 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.notification;
|
|
||||||
|
|
||||||
//@Configuration
|
|
||||||
//@EnableRabbit
|
|
||||||
public class RabbitMQConfiguration {
|
|
||||||
|
|
||||||
public final static String TOPIC_EXCHANGE_NAME = "jasamedika-medifirst-exchange";
|
|
||||||
public final static String QUEUE_NAME = "internal-queu";
|
|
||||||
public final static String ROUTING_KEY = "ruanganId.*";
|
|
||||||
|
|
||||||
// @Bean
|
|
||||||
// public ConnectionFactory connectionFactory() {
|
|
||||||
// CachingConnectionFactory connectionFactory = new CachingConnectionFactory("localhost");
|
|
||||||
// connectionFactory.setUsername("guest");
|
|
||||||
// connectionFactory.setPassword("guest");
|
|
||||||
// return connectionFactory;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Bean
|
|
||||||
// public RabbitTemplate getRabbitTemplate(){
|
|
||||||
// RabbitTemplate rabbit = new RabbitTemplate(connectionFactory());
|
|
||||||
// rabbit.setExchange(TOPIC_EXCHANGE_NAME);
|
|
||||||
// rabbit.setRoutingKey(ROUTING_KEY);
|
|
||||||
// return rabbit;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Bean
|
|
||||||
// public Queue getQueue() {
|
|
||||||
// return new Queue(QUEUE_NAME, true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Bean
|
|
||||||
// public TopicExchange getTopicExchange() {
|
|
||||||
// return new TopicExchange(TOPIC_EXCHANGE_NAME);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Bean
|
|
||||||
// public SimpleRabbitListenerContainerFactory myRabbitListenerContainerFactory() {
|
|
||||||
// SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
|
|
||||||
// factory.setConnectionFactory(connectionFactory());
|
|
||||||
// factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
|
|
||||||
//
|
|
||||||
// return factory;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // ini ibarat jalan tolnya.. :P
|
|
||||||
// @Bean
|
|
||||||
// public Binding binding(Queue queue, TopicExchange exchange) {
|
|
||||||
// return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,252 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.notification.antrian;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class BackEndAntrian {
|
|
||||||
|
|
||||||
// static boolean listener = false;
|
|
||||||
//
|
|
||||||
// @PostConstruct
|
|
||||||
// public void init() {
|
|
||||||
// if (!listener) {
|
|
||||||
// listener = true;
|
|
||||||
//
|
|
||||||
// this.host = "192.168.12.2";
|
|
||||||
// this.user = "rsab";
|
|
||||||
// this.pass = "rsab";
|
|
||||||
//
|
|
||||||
// this.topikUtama = "antrian";
|
|
||||||
// this.targetLoket = "loket";
|
|
||||||
// this.targetLayar = "layar-utama";
|
|
||||||
// this.sumberLoket = "group-loket";
|
|
||||||
//
|
|
||||||
// if (!Thread.currentThread().isInterrupted()) {
|
|
||||||
// new Thread() {
|
|
||||||
// public void run() {
|
|
||||||
// try {
|
|
||||||
// dengarkanPesanMasuk();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }.start();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private RegistrasiPelayananPasienService registrasiPelayananPasienService;
|
|
||||||
//
|
|
||||||
// Map<Integer, String> daftarLoket = new HashMap<>();
|
|
||||||
//
|
|
||||||
// //Integer antrian = 1;
|
|
||||||
//
|
|
||||||
// String host;
|
|
||||||
// String user;
|
|
||||||
// String pass;
|
|
||||||
//
|
|
||||||
// String topikUtama;
|
|
||||||
// String targetLoket;
|
|
||||||
// String targetLayar;
|
|
||||||
// String sumberLoket;
|
|
||||||
//
|
|
||||||
// int totalLayar;
|
|
||||||
//
|
|
||||||
// AntrianPasien antrianPasienDTO;
|
|
||||||
//
|
|
||||||
// ///////////////////////
|
|
||||||
// // Fokus di sini saja
|
|
||||||
// ///////////////////////
|
|
||||||
// Integer ambilAntrian(String jenis) {
|
|
||||||
//
|
|
||||||
// antrianPasienDTO = registrasiPelayananPasienService.getNomorUrutPasienbyJenis(jenis);
|
|
||||||
//
|
|
||||||
// return antrianPasienDTO.getNoUrut();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void lanjutAntrian(Integer noAntrian, String jenis) {
|
|
||||||
// registrasiPelayananPasienService.updateNomorUrutPasienbyJenis(noAntrian, jenis);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /////////////////////////
|
|
||||||
// /// START BAGIAN PESAN
|
|
||||||
// ////////////////////////
|
|
||||||
// public void olahPesan(Envelope envelope, byte[] body) {
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// JSONObject oPesan = new JSONObject(new String(body));
|
|
||||||
// Integer urutanLoket = oPesan.optInt("urutanLoket", 0);
|
|
||||||
// String tipeLoket = oPesan.optString("tipeLoket", "");
|
|
||||||
// String titleLoket = oPesan.optString("titleLoket", "Loket");
|
|
||||||
// boolean awal = oPesan.optBoolean("awal", false);
|
|
||||||
// boolean lanjut = oPesan.optBoolean("lanjut", false);
|
|
||||||
// boolean ulang = oPesan.optBoolean("ulang", false);
|
|
||||||
//
|
|
||||||
// String pesan = "{}";
|
|
||||||
// if (awal) {
|
|
||||||
// JSONObject kirim = new JSONObject();
|
|
||||||
//
|
|
||||||
// kirim.put("noAntrian", 0);
|
|
||||||
// kirim.put("urutanLoket", urutanLoket);
|
|
||||||
// kirim.put("tipeLoket", tipeLoket);
|
|
||||||
// kirim.put("titleLoket", titleLoket);
|
|
||||||
//
|
|
||||||
// pesan = kirim.toString();
|
|
||||||
// daftarLoket.put(urutanLoket, pesan);
|
|
||||||
//
|
|
||||||
// } else if (lanjut) {
|
|
||||||
// Integer lAntrian = ambilAntrian(tipeLoket);
|
|
||||||
// if (lAntrian == null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// JSONObject kirim = new JSONObject();
|
|
||||||
//
|
|
||||||
// kirim.put("noAntrian", lAntrian.intValue());
|
|
||||||
// kirim.put("urutanLoket", urutanLoket);
|
|
||||||
// kirim.put("tipeLoket", tipeLoket);
|
|
||||||
// kirim.put("titleLoket", titleLoket);
|
|
||||||
//
|
|
||||||
// lanjutAntrian(lAntrian, tipeLoket);
|
|
||||||
//
|
|
||||||
// pesan = kirim.toString();
|
|
||||||
// daftarLoket.put(urutanLoket, pesan);
|
|
||||||
//
|
|
||||||
// } else if (ulang) {
|
|
||||||
// pesan = daftarLoket.get(urutanLoket);
|
|
||||||
// } else {
|
|
||||||
// JSONObject kirim = new JSONObject();
|
|
||||||
//
|
|
||||||
// kirim.put("noAntrian", -1);
|
|
||||||
// kirim.put("urutanLoket", urutanLoket);
|
|
||||||
// kirim.put("tipeLoket", tipeLoket);
|
|
||||||
// kirim.put("titleLoket", titleLoket);
|
|
||||||
//
|
|
||||||
// pesan = kirim.toString();
|
|
||||||
// daftarLoket.put(urutanLoket, pesan);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// kirimAntrian(pesan, urutanLoket);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ///////////////////////////////////
|
|
||||||
// // START BAGIAN PENGIRIMAN
|
|
||||||
// ///////////////////////////////////
|
|
||||||
// void kirimAntrian(String pesan, Integer urutanLoket) throws Exception {
|
|
||||||
//
|
|
||||||
// System.out.println(".. KIRIM PENGUMUMAN ANTRIAN ...");
|
|
||||||
// kirimKeLayarBesar(pesan);
|
|
||||||
// kirimKeTomboldanLayarKecil(pesan, urutanLoket);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void kirimKeTomboldanLayarKecil(String pesan, Integer urutanLoket) throws Exception {
|
|
||||||
//
|
|
||||||
// System.out.println("Kirim antrian ke tombol dan layar kecil");
|
|
||||||
//
|
|
||||||
// ConnectionFactory factory = new ConnectionFactory();
|
|
||||||
// factory.setHost(host);
|
|
||||||
// factory.setUsername(user);
|
|
||||||
// factory.setPassword(pass);
|
|
||||||
//
|
|
||||||
// Connection connection = factory.newConnection();
|
|
||||||
// Channel channel = connection.createChannel();
|
|
||||||
//
|
|
||||||
// AMQP.BasicProperties mProp = MessageProperties.PERSISTENT_TEXT_PLAIN;
|
|
||||||
//
|
|
||||||
// channel.exchangeDeclare(topikUtama, "topic");
|
|
||||||
// channel.basicPublish(topikUtama, targetLoket + "." + urutanLoket, mProp, pesan.getBytes());
|
|
||||||
// channel.basicPublish(topikUtama, targetLayar + "." + urutanLoket, mProp, pesan.getBytes());
|
|
||||||
//
|
|
||||||
// channel.close();
|
|
||||||
// connection.close();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void kirimKeLayarBesar(String pesan) throws Exception {
|
|
||||||
//
|
|
||||||
// System.out.println("Kirim antrian ke layar besar");
|
|
||||||
//
|
|
||||||
// ConnectionFactory factory = new ConnectionFactory();
|
|
||||||
// factory.setHost(host);
|
|
||||||
// factory.setUsername(user);
|
|
||||||
// factory.setPassword(pass);
|
|
||||||
//
|
|
||||||
// Connection connection = factory.newConnection();
|
|
||||||
// Channel channel = connection.createChannel();
|
|
||||||
//
|
|
||||||
// AMQP.BasicProperties mProp = MessageProperties.PERSISTENT_TEXT_PLAIN;
|
|
||||||
//
|
|
||||||
// channel.exchangeDeclare(targetLayar, "fanout");
|
|
||||||
// channel.basicPublish(targetLayar, "", mProp, pesan.getBytes());
|
|
||||||
//
|
|
||||||
// channel.close();
|
|
||||||
// connection.close();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //////////////////////////
|
|
||||||
// // START BAGIAN PENERIMAAN
|
|
||||||
// //////////////////////////
|
|
||||||
// Connection connectionP;
|
|
||||||
// Channel channelP;
|
|
||||||
// AMQP.Queue.DeclareOk Queue;
|
|
||||||
//
|
|
||||||
// void dengarkanPesanMasuk() throws Exception {
|
|
||||||
//
|
|
||||||
// ConnectionFactory factory = new ConnectionFactory();
|
|
||||||
// factory.setHost(host);
|
|
||||||
// factory.setUsername(user);
|
|
||||||
// factory.setPassword(pass);
|
|
||||||
//
|
|
||||||
// connectionP = factory.newConnection();
|
|
||||||
// channelP = connectionP.createChannel();
|
|
||||||
// channelP.basicQos(1);
|
|
||||||
// Queue = channelP.queueDeclare(sumberLoket, true, false, false, null);
|
|
||||||
//
|
|
||||||
// consume();
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void consume() {
|
|
||||||
// final Consumer consumer = new DefaultConsumer(channelP) {
|
|
||||||
// @Override
|
|
||||||
// public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
|
|
||||||
// byte[] body) throws IOException {
|
|
||||||
// String message = new String(body, "UTF-8");
|
|
||||||
// System.out.println("Back End : '" + envelope.getRoutingKey() + "':'" + message + "'");
|
|
||||||
// getChannel().basicAck(envelope.getDeliveryTag(), false);
|
|
||||||
// olahPesan(envelope, body);
|
|
||||||
// try {
|
|
||||||
// tutupConnection();
|
|
||||||
// dengarkanPesanMasuk();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// new Thread() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// try {
|
|
||||||
// System.out.println("Back End - " + topikUtama + " : dengarkan pesan masuk");
|
|
||||||
// System.out.println("Queue.getMessageCount() : " + Queue.getMessageCount());
|
|
||||||
// channelP.basicConsume(sumberLoket, true, consumer);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }.start();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void tutupConnection() {
|
|
||||||
// try {
|
|
||||||
// if (connectionP != null) {
|
|
||||||
// connectionP.close();
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.notification.antrian;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.rabbitmq.client.AMQP;
|
|
||||||
import com.rabbitmq.client.Channel;
|
|
||||||
import com.rabbitmq.client.Connection;
|
|
||||||
import com.rabbitmq.client.ConnectionFactory;
|
|
||||||
import com.rabbitmq.client.MessageProperties;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class InfoTambahanAntrian {
|
|
||||||
|
|
||||||
String host;
|
|
||||||
String user;
|
|
||||||
String pass;
|
|
||||||
|
|
||||||
String topikUtama;
|
|
||||||
String targetLoket;
|
|
||||||
String targetLayar;
|
|
||||||
String sumberLoket;
|
|
||||||
|
|
||||||
public void kirimKeLayarBesar(String pesan, String targetLayar) throws Exception {
|
|
||||||
|
|
||||||
System.out.println("Kirim antrian ke layar besar");
|
|
||||||
|
|
||||||
ConnectionFactory factory = new ConnectionFactory();
|
|
||||||
factory.setHost(host);
|
|
||||||
factory.setUsername(user);
|
|
||||||
factory.setPassword(pass);
|
|
||||||
|
|
||||||
Connection connection = factory.newConnection();
|
|
||||||
Channel channel = connection.createChannel();
|
|
||||||
|
|
||||||
AMQP.BasicProperties mProp = MessageProperties.PERSISTENT_TEXT_PLAIN;
|
|
||||||
|
|
||||||
channel.exchangeDeclare(targetLayar, "fanout");
|
|
||||||
channel.basicPublish(targetLayar, "", mProp, pesan.getBytes());
|
|
||||||
|
|
||||||
channel.close();
|
|
||||||
connection.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void kirimPesan(String pesan, String targetlayar) throws Exception {
|
|
||||||
|
|
||||||
String[] target = targetlayar.split(",");
|
|
||||||
for (String sTarget : target) {
|
|
||||||
JSONObject oPesan = new JSONObject();
|
|
||||||
oPesan.put("umumkan", true);
|
|
||||||
oPesan.put("info", pesan);
|
|
||||||
|
|
||||||
kirimKeLayarBesar(oPesan.toString(), sTarget);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void kirimJumlahAntrian(String labelAntrian, String tipeAntrian, String total, boolean hapus,
|
|
||||||
String targetlayar) throws Exception {
|
|
||||||
String[] target = targetlayar.split(",");
|
|
||||||
for (String sTarget : target) {
|
|
||||||
JSONObject oPesan = new JSONObject();
|
|
||||||
oPesan.put("jenisAntrian", true);
|
|
||||||
oPesan.put("infoLabel", labelAntrian);
|
|
||||||
oPesan.put("infoTipe", tipeAntrian);
|
|
||||||
oPesan.put("infoTotal", total);
|
|
||||||
oPesan.put("hapus", hapus);
|
|
||||||
|
|
||||||
kirimKeLayarBesar(oPesan.toString(), sTarget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
|||||||
import com.jasamedika.medifirst2000.base.vo.BaseMasterVO;
|
import com.jasamedika.medifirst2000.base.vo.BaseMasterVO;
|
||||||
import com.jasamedika.medifirst2000.entities.Pegawai;
|
import com.jasamedika.medifirst2000.entities.Pegawai;
|
||||||
import com.jasamedika.medifirst2000.entities.Ruangan;
|
import com.jasamedika.medifirst2000.entities.Ruangan;
|
||||||
|
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||||
import com.jasamedika.medifirst2000.notification.MessagePublisher;
|
import com.jasamedika.medifirst2000.notification.MessagePublisher;
|
||||||
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
|
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
|
||||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||||
@ -11,48 +12,39 @@ import com.jasamedika.medifirst2000.vo.*;
|
|||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import com.rabbitmq.client.Connection;
|
import com.rabbitmq.client.Connection;
|
||||||
import com.rabbitmq.client.ConnectionFactory;
|
import com.rabbitmq.client.ConnectionFactory;
|
||||||
import com.rabbitmq.client.MessageProperties;
|
|
||||||
import io.socket.client.IO;
|
import io.socket.client.IO;
|
||||||
|
import io.socket.client.Socket;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
import javax.sql.DataSource;
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import static com.rabbitmq.client.MessageProperties.PERSISTENT_TEXT_PLAIN;
|
||||||
import java.util.UUID;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
import static org.springframework.beans.BeanUtils.copyProperties;
|
||||||
|
|
||||||
@Component("messagePublisher")
|
@Component("messagePublisher")
|
||||||
public class MessagePublisherImpl<K, V> implements MessagePublisher<K, V> {
|
public class MessagePublisherImpl<K, V> implements MessagePublisher<K, V> {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(MessagePublisherImpl.class);
|
|
||||||
|
|
||||||
static io.socket.client.Socket socket = null;
|
private static final Logger LOGGER = getLogger(MessagePublisherImpl.class);
|
||||||
|
|
||||||
|
static Socket socket = null;
|
||||||
|
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
protected EntityManager em;
|
protected EntityManager em;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
DataSource dataSource;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = false)
|
@Transactional
|
||||||
public String GetSettingDataFixed(String prefix) {
|
public String getSettingDataFixed(String prefix) {
|
||||||
try{
|
try{
|
||||||
StringBuffer buffer = new StringBuffer();
|
Query query = em.createQuery("select model.nilaiField from SettingDataFixed " + " model where model.namaField ='" + prefix + "' ");
|
||||||
buffer.append("select model.nilaiField from SettingDataFixed ")
|
|
||||||
.append(" model where model.namaField ='" + prefix + "' ");
|
|
||||||
Query query = em.createQuery(buffer.toString());
|
|
||||||
|
|
||||||
return (String) query.getSingleResult();
|
return (String) query.getSingleResult();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
return "127.0.0.1";
|
return "127.0.0.1";
|
||||||
@ -61,43 +53,37 @@ public class MessagePublisherImpl<K, V> implements MessagePublisher<K, V> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendDirectNotification(final Map<K, V> data) {
|
public void sendDirectNotification(final Map<K, V> data) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (socket == null) {
|
if (socket == null) {
|
||||||
socket = IO.socket(GetSettingDataFixed("UrlSocketMessaging"));
|
socket = IO.socket(getSettingDataFixed("UrlSocketMessaging"));
|
||||||
|
socket.on(Socket.EVENT_CONNECT, args -> {
|
||||||
|
try {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JSONObject item = new JSONObject(
|
||||||
|
"{\"to\":\"NOTIF\",\"message\":" + gson.toJson(data) + "}");
|
||||||
|
|
||||||
socket.on(io.socket.client.Socket.EVENT_CONNECT, new io.socket.emitter.Emitter.Listener() {
|
LOGGER.info("socket null: {\"to\":\"NOTIF\",\"message\":{}}", gson.toJson(data));
|
||||||
|
|
||||||
@Override
|
socket.emit("subscribe", item);
|
||||||
public void call(Object... args) {
|
} catch (JSONException e) {
|
||||||
|
LOGGER.error(e.getMessage());
|
||||||
try {
|
}
|
||||||
Gson gson = new Gson();
|
});
|
||||||
JSONObject item = new JSONObject(
|
|
||||||
"{\"to\":\"NOTIF\",\"message\":" + gson.toJson(data) + "}");
|
|
||||||
LOGGER.info("{\"to\":\"NOTIF\",\"message\":" + gson.toJson(data) + "}");
|
|
||||||
socket.emit("subscribe", item);
|
|
||||||
// socket.disconnect();
|
|
||||||
} catch (JSONException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
socket.connect();
|
socket.connect();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
JSONObject item = new JSONObject("{\"to\":\"NOTIF\",\"message\":" + gson.toJson(data) + "}");
|
JSONObject item = new JSONObject("{\"to\":\"NOTIF\",\"message\":" + gson.toJson(data) + "}");
|
||||||
LOGGER.info("{\"to\":\"NOTIF\",\"message\":" + gson.toJson(data) + "}");
|
|
||||||
|
LOGGER.info("socket is not null: {\"to\":\"NOTIF\",\"message\":{}}", gson.toJson(data));
|
||||||
|
|
||||||
socket.emit("subscribe", item);
|
socket.emit("subscribe", item);
|
||||||
// socket.disconnect();
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
LOGGER.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,14 +92,11 @@ public class MessagePublisherImpl<K, V> implements MessagePublisher<K, V> {
|
|||||||
Channel channel;
|
Channel channel;
|
||||||
String routingKeyAndQueueName;
|
String routingKeyAndQueueName;
|
||||||
Gson gson;
|
Gson gson;
|
||||||
//String urlSocket;
|
|
||||||
String host;
|
String host;
|
||||||
|
|
||||||
public DefaultRabbitHole(String host){
|
public DefaultRabbitHole(String host){
|
||||||
this.gson = new Gson();
|
this.gson = new Gson();
|
||||||
this.host = host;
|
this.host = host;
|
||||||
// urlSocket = GetSettingDataFixed("UrlRabbitMQMessaging"); //sementara kunci dulu.
|
|
||||||
//urlSocket = "127.0.0.1";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(String host, String userName, String password, String routingKeyAndQueueName) throws Exception {
|
public void connect(String host, String userName, String password, String routingKeyAndQueueName) throws Exception {
|
||||||
@ -128,7 +111,7 @@ public class MessagePublisherImpl<K, V> implements MessagePublisher<K, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendRabbitMQNotification(String pesan) throws Exception {
|
public void sendRabbitMQNotification(String pesan) throws Exception {
|
||||||
channel.basicPublish("", routingKeyAndQueueName, MessageProperties.PERSISTENT_TEXT_PLAIN, pesan.getBytes());
|
channel.basicPublish("", routingKeyAndQueueName, PERSISTENT_TEXT_PLAIN, pesan.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws Exception {
|
public void close() throws Exception {
|
||||||
@ -139,19 +122,14 @@ public class MessagePublisherImpl<K, V> implements MessagePublisher<K, V> {
|
|||||||
public void sendNotif(MessagePublisher.RabbitHole rabbitHole, Ruangan dariRuangan, Pegawai pegawai,
|
public void sendNotif(MessagePublisher.RabbitHole rabbitHole, Ruangan dariRuangan, Pegawai pegawai,
|
||||||
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService,
|
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService,
|
||||||
Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception {
|
Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception {
|
||||||
|
|
||||||
List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService
|
List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService
|
||||||
.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
|
.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
|
||||||
|
if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs))
|
||||||
if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Integer ruanganTujuanIdtemp = 0;
|
Integer ruanganTujuanIdtemp = 0;
|
||||||
boolean connect = false;
|
boolean connect = false;
|
||||||
RuanganVO dariRuanganVO = convertToVO(new RuanganVO(),dariRuangan);
|
RuanganVO dariRuanganVO = convertToVO(new RuanganVO(),dariRuangan);
|
||||||
PegawaiVO pegawaiVO = convertToVO(new PegawaiVO(),pegawai);
|
PegawaiVO pegawaiVO = convertToVO(new PegawaiVO(),pegawai);
|
||||||
|
|
||||||
for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs) {
|
for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs) {
|
||||||
RuanganVO ruanganTujuan = vo.getRuangan();
|
RuanganVO ruanganTujuan = vo.getRuangan();
|
||||||
ModulAplikasiVO modulAplikasi = vo.getModulAplikasi();
|
ModulAplikasiVO modulAplikasi = vo.getModulAplikasi();
|
||||||
@ -160,23 +138,17 @@ public class MessagePublisherImpl<K, V> implements MessagePublisher<K, V> {
|
|||||||
String titleNotifikasi = vo.getTitleNotifikasi();
|
String titleNotifikasi = vo.getTitleNotifikasi();
|
||||||
String pesanNotifikasi = vo.getPesanNotifikasi();
|
String pesanNotifikasi = vo.getPesanNotifikasi();
|
||||||
String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
|
String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
|
||||||
|
if (Objects.equals(ruanganTujuan.getId(), dariRuanganVO.getId()))
|
||||||
if (ruanganTujuan.getId() == dariRuanganVO.getId()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
if (!Objects.equals(ruanganTujuanIdtemp, ruanganTujuan.getId())) {
|
||||||
|
if (connect)
|
||||||
if (ruanganTujuanIdtemp != ruanganTujuan.getId()) {
|
|
||||||
if (connect) {
|
|
||||||
rabbitHole.close();
|
rabbitHole.close();
|
||||||
}
|
|
||||||
rabbitHole.connect(host, "rsab", "rsab", String.valueOf(ruanganTujuan.getId()));
|
rabbitHole.connect(host, "rsab", "rsab", String.valueOf(ruanganTujuan.getId()));
|
||||||
connect = true;
|
connect = true;
|
||||||
ruanganTujuanIdtemp = ruanganTujuan.getId();
|
ruanganTujuanIdtemp = ruanganTujuan.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ModulAplikasiVO modulAplikasiVO = convertToVO(new ModulAplikasiVO(), modulAplikasi);
|
ModulAplikasiVO modulAplikasiVO = convertToVO(new ModulAplikasiVO(), modulAplikasi);
|
||||||
ObjekModulAplikasiVO objekModulAplikasiVO = convertToVO(new ObjekModulAplikasiVO(), objekModulAplikasi);
|
ObjekModulAplikasiVO objekModulAplikasiVO = convertToVO(new ObjekModulAplikasiVO(), objekModulAplikasi);
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("rec", UUID.randomUUID());
|
map.put("rec", UUID.randomUUID());
|
||||||
map.put("title", titleNotifikasi);
|
map.put("title", titleNotifikasi);
|
||||||
@ -190,39 +162,20 @@ public class MessagePublisherImpl<K, V> implements MessagePublisher<K, V> {
|
|||||||
map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
|
map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
|
||||||
map.put("fromPegawai", pegawaiVO);
|
map.put("fromPegawai", pegawaiVO);
|
||||||
map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
|
map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
|
||||||
|
|
||||||
rabbitHole.sendRabbitMQNotification(gson.toJson(map));
|
rabbitHole.sendRabbitMQNotification(gson.toJson(map));
|
||||||
}
|
}
|
||||||
if (connect) {
|
if (connect)
|
||||||
rabbitHole.close();
|
rabbitHole.close();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<T extends BaseMasterVO> T convertToVO(T target, Object source){
|
<T extends BaseMasterVO> T convertToVO(T target, Object source){
|
||||||
BeanUtils.copyProperties(source, target);
|
copyProperties(source, target);
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RabbitHole getRabbitHole() {
|
public RabbitHole getRabbitHole() {
|
||||||
return new DefaultRabbitHole(GetSettingDataFixed("UrlRabbitMQMessaging"));
|
return new DefaultRabbitHole(getSettingDataFixed("UrlRabbitMQMessaging"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public void sendRabbitMQNotification(String host, String
|
|
||||||
// routingKeyAndQueueName, String pesan) throws Exception {
|
|
||||||
// ConnectionFactory factory = new ConnectionFactory();
|
|
||||||
// factory.setHost(host);
|
|
||||||
// Connection connection = factory.newConnection();
|
|
||||||
// Channel channel = connection.createChannel();
|
|
||||||
// channel.queueDeclare(routingKeyAndQueueName, true, false, false, null);
|
|
||||||
// channel.basicPublish("", routingKeyAndQueueName, null, pesan.getBytes());
|
|
||||||
// channel.close();
|
|
||||||
// connection.close();
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,35 +1,24 @@
|
|||||||
package com.jasamedika.medifirst2000.notification.impl;
|
package com.jasamedika.medifirst2000.notification.impl;
|
||||||
|
|
||||||
|
import com.jasamedika.medifirst2000.notification.MessageSubscriber;
|
||||||
|
import com.rabbitmq.client.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.notification.MessageSubscriber;
|
|
||||||
import com.rabbitmq.client.AMQP;
|
|
||||||
import com.rabbitmq.client.Channel;
|
|
||||||
import com.rabbitmq.client.Connection;
|
|
||||||
import com.rabbitmq.client.ConnectionFactory;
|
|
||||||
import com.rabbitmq.client.Consumer;
|
|
||||||
import com.rabbitmq.client.DefaultConsumer;
|
|
||||||
import com.rabbitmq.client.Envelope;
|
|
||||||
|
|
||||||
@Component("messageSubscriber")
|
@Component("messageSubscriber")
|
||||||
public class MessageSubscriberImpl implements MessageSubscriber {
|
public class MessageSubscriberImpl implements MessageSubscriber {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(MessageSubscriberImpl.class);
|
private static final Logger LOGGER = getLogger(MessageSubscriberImpl.class);
|
||||||
|
|
||||||
Channel channel;
|
Channel channel;
|
||||||
Connection connection;
|
Connection connection;
|
||||||
AMQP.Queue.DeclareOk Queue;
|
AMQP.Queue.DeclareOk Queue;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
DataSource dataSource;
|
|
||||||
|
|
||||||
public void startRabbitMQNotification(String host, String routingKeyAndQueueName) throws Exception {
|
public void startRabbitMQNotification(String host, String routingKeyAndQueueName) throws Exception {
|
||||||
ConnectionFactory factory = new ConnectionFactory();
|
ConnectionFactory factory = new ConnectionFactory();
|
||||||
factory.setHost(host);
|
factory.setHost(host);
|
||||||
@ -40,10 +29,8 @@ public class MessageSubscriberImpl implements MessageSubscriber {
|
|||||||
|
|
||||||
public void listenRabbitMQNotification(String routingKeyAndQueueName, Consumer consumer, boolean autoAck)
|
public void listenRabbitMQNotification(String routingKeyAndQueueName, Consumer consumer, boolean autoAck)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
for (int i = 0; i < Queue.getMessageCount(); i++) {
|
for (int i = 0; i < Queue.getMessageCount(); i++)
|
||||||
channel.basicConsume(routingKeyAndQueueName, autoAck, consumer);
|
channel.basicConsume(routingKeyAndQueueName, autoAck, consumer);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopRabbitMQNotification() throws Exception {
|
public void stopRabbitMQNotification() throws Exception {
|
||||||
@ -57,7 +44,7 @@ public class MessageSubscriberImpl implements MessageSubscriber {
|
|||||||
@Override
|
@Override
|
||||||
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
|
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
|
||||||
byte[] body) throws IOException {
|
byte[] body) throws IOException {
|
||||||
LOGGER.info(new String(body, "UTF-8"));
|
LOGGER.info(new String(body, UTF_8));
|
||||||
getChannel().basicAck(envelope.getDeliveryTag(), false);
|
getChannel().basicAck(envelope.getDeliveryTag(), false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,20 +1,12 @@
|
|||||||
package com.jasamedika.medifirst2000.paging;
|
package com.jasamedika.medifirst2000.paging;
|
||||||
|
|
||||||
public enum Comparison {
|
public enum Comparison {
|
||||||
// equal
|
EQ, // equal
|
||||||
eq,
|
GT, // greaterThan
|
||||||
// greaterThan
|
LT, // lowerThan
|
||||||
gt,
|
NE, // not equal
|
||||||
// lowerThan
|
IS_NULL, // is null
|
||||||
lt,
|
IN,
|
||||||
// not equal
|
INN,
|
||||||
ne,
|
LK
|
||||||
// is null
|
|
||||||
isnull,
|
|
||||||
|
|
||||||
in,
|
|
||||||
|
|
||||||
inn,
|
|
||||||
|
|
||||||
lk
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,53 +1,21 @@
|
|||||||
package com.jasamedika.medifirst2000.paging;
|
package com.jasamedika.medifirst2000.paging;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
public class Condition {
|
public class Condition {
|
||||||
|
|
||||||
public Type type;
|
private Type type;
|
||||||
public Comparison comparison;
|
|
||||||
|
|
||||||
public Object value;
|
private Comparison comparison;
|
||||||
|
|
||||||
public String field;
|
private Object value;
|
||||||
|
|
||||||
public Condition() {
|
private String field;
|
||||||
}
|
|
||||||
|
|
||||||
public Condition(Type type, Comparison comparison, Object value, String field) {
|
|
||||||
this.type = type;
|
|
||||||
this.comparison = comparison;
|
|
||||||
this.value = value;
|
|
||||||
this.field = field;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
private Type type;
|
|
||||||
private Comparison comparison;
|
|
||||||
private Object value;
|
|
||||||
private String field;
|
|
||||||
|
|
||||||
public Builder setType(Type type) {
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setComparison(Comparison comparison) {
|
|
||||||
this.comparison = comparison;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setValue(Object value) {
|
|
||||||
this.value = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setField(String field) {
|
|
||||||
this.field = field;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Condition build() {
|
|
||||||
return new Condition(type, comparison, value, field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,30 +9,12 @@ import javax.persistence.criteria.Root;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [{
|
|
||||||
* "type": "string",
|
|
||||||
* "value": "***",
|
|
||||||
* "field": "model"
|
|
||||||
* },{
|
|
||||||
* "type": "numeric",
|
|
||||||
* "value": "***",
|
|
||||||
* "field": "year",
|
|
||||||
* "comparison": "gt"
|
|
||||||
* }]
|
|
||||||
*/
|
|
||||||
public class Filter implements Specification {
|
public class Filter implements Specification {
|
||||||
|
|
||||||
List<Condition> conditions;
|
private final List<Condition> conditions;
|
||||||
|
|
||||||
public Filter(String json) {
|
|
||||||
// ObjectMapper mapper = new ObjectMapper();
|
|
||||||
// this.conditions = mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, Condition.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Filter() {
|
public Filter() {
|
||||||
conditions = new ArrayList<>();
|
this.conditions = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCondition(Condition condition) {
|
public void addCondition(Condition condition) {
|
||||||
@ -41,47 +23,39 @@ public class Filter implements Specification {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
||||||
List<Predicate> predicates = buildPredicates(root, criteriaQuery, criteriaBuilder);
|
List<Predicate> predicates = buildPredicates(root, criteriaBuilder);
|
||||||
return predicates.size() > 1
|
return predicates.size() > 1
|
||||||
? criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]))
|
? criteriaBuilder.and(predicates.toArray(new Predicate[0]))
|
||||||
: predicates.get(0);
|
: predicates.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Predicate> buildPredicates(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
private List<Predicate> buildPredicates(Root<?> root, CriteriaBuilder criteriaBuilder) {
|
||||||
// return conditions.stream().map(this::buildPredicate).collect(toList());
|
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
for(Condition c:conditions){
|
for(Condition c:conditions){
|
||||||
predicates.add(buildPredicate(c, root, criteriaQuery, criteriaBuilder));
|
predicates.add(buildPredicate(c, root, criteriaBuilder));
|
||||||
}
|
}
|
||||||
|
|
||||||
return predicates;
|
return predicates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Predicate buildPredicate(Condition condition, Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
public Predicate buildPredicate(Condition condition, Root<?> root, CriteriaBuilder criteriaBuilder) {
|
||||||
switch (condition.comparison) {
|
switch (condition.getComparison()) {
|
||||||
case eq:
|
case GT:
|
||||||
return buildEqualsPredicateToCriteria(condition, root, criteriaQuery, criteriaBuilder);
|
case LT:
|
||||||
case gt:
|
case NE:
|
||||||
|
case IS_NULL:
|
||||||
|
case IN:
|
||||||
break;
|
break;
|
||||||
case lt:
|
case INN:
|
||||||
break;
|
return criteriaBuilder.isNotNull(root.get(condition.getField()));
|
||||||
case ne:
|
case LK:
|
||||||
break;
|
return criteriaBuilder.like(root.get(condition.getField()), "%"+condition.getValue()+"%");
|
||||||
case isnull:
|
|
||||||
break;
|
|
||||||
case in:
|
|
||||||
break;
|
|
||||||
case inn:
|
|
||||||
return criteriaBuilder.isNotNull(root.get(condition.field));
|
|
||||||
case lk:
|
|
||||||
return criteriaBuilder.like(root.get(condition.field), "%"+condition.value+"%");
|
|
||||||
default:
|
default:
|
||||||
return buildEqualsPredicateToCriteria(condition, root, criteriaQuery, criteriaBuilder);
|
return buildEqualsPredicateToCriteria(condition, root, criteriaBuilder);
|
||||||
}
|
}
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Predicate buildEqualsPredicateToCriteria(Condition condition, Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
private Predicate buildEqualsPredicateToCriteria(Condition condition, Root<?> root, CriteriaBuilder criteriaBuilder) {
|
||||||
return criteriaBuilder.equal(root.get(condition.field), condition.value);
|
return criteriaBuilder.equal(root.get(condition.getField()), condition.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package com.jasamedika.medifirst2000.paging;
|
package com.jasamedika.medifirst2000.paging;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
numeric,
|
NUMERIC,
|
||||||
string,
|
STRING,
|
||||||
date,
|
DATE,
|
||||||
bool,
|
BOOLEAN,
|
||||||
uuid,
|
UUID,
|
||||||
list,
|
LIST,
|
||||||
raw
|
RAW
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,5 @@
|
|||||||
package com.jasamedika.medifirst2000.service.impl;
|
package com.jasamedika.medifirst2000.service.impl;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.converter.KamusIndikatorConverter;
|
import com.jasamedika.medifirst2000.converter.KamusIndikatorConverter;
|
||||||
import com.jasamedika.medifirst2000.dao.KamusIndikatorDao;
|
import com.jasamedika.medifirst2000.dao.KamusIndikatorDao;
|
||||||
import com.jasamedika.medifirst2000.dao.TargetIndikatorDao;
|
import com.jasamedika.medifirst2000.dao.TargetIndikatorDao;
|
||||||
@ -28,6 +13,20 @@ import com.jasamedika.medifirst2000.paging.Filter;
|
|||||||
import com.jasamedika.medifirst2000.service.KamusIndikatorService;
|
import com.jasamedika.medifirst2000.service.KamusIndikatorService;
|
||||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||||
import com.jasamedika.medifirst2000.vo.KamusIndikatorVO;
|
import com.jasamedika.medifirst2000.vo.KamusIndikatorVO;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service("KamusIndikatorService")
|
@Service("KamusIndikatorService")
|
||||||
public class KamusIndikatorServiceImpl extends BaseVoServiceImpl implements KamusIndikatorService{
|
public class KamusIndikatorServiceImpl extends BaseVoServiceImpl implements KamusIndikatorService{
|
||||||
@ -114,37 +113,26 @@ public class KamusIndikatorServiceImpl extends BaseVoServiceImpl implements Kamu
|
|||||||
Specification<KamusIndikator> spec) {
|
Specification<KamusIndikator> spec) {
|
||||||
Direction direction=null;
|
Direction direction=null;
|
||||||
List<DetailKamusIndikatorDto> dtos = new LinkedList<DetailKamusIndikatorDto>();
|
List<DetailKamusIndikatorDto> dtos = new LinkedList<DetailKamusIndikatorDto>();
|
||||||
|
|
||||||
if(dir.equalsIgnoreCase("asc")){
|
if(dir.equalsIgnoreCase("asc")){
|
||||||
direction=Sort.Direction.ASC;
|
direction=Sort.Direction.ASC;
|
||||||
}else{
|
}else{
|
||||||
direction=Sort.Direction.DESC;
|
direction=Sort.Direction.DESC;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pageable pageable = new PageRequest(page, take, direction, sort);
|
Pageable pageable = new PageRequest(page, take, direction, sort);
|
||||||
Page<KamusIndikator> resultPage = kamusIndikatorDao.findAll(spec, pageable);
|
Page<KamusIndikator> resultPage = kamusIndikatorDao.findAll(spec, pageable);
|
||||||
List<KamusIndikator> resultData = resultPage.getContent();
|
List<KamusIndikator> resultData = resultPage.getContent();
|
||||||
|
|
||||||
for(KamusIndikator model : resultData){
|
for(KamusIndikator model : resultData){
|
||||||
|
|
||||||
Filter filter = new Filter();
|
Filter filter = new Filter();
|
||||||
if (CommonUtil.isNotNullOrEmpty(model.getId())) {
|
if (CommonUtil.isNotNullOrEmpty(model.getId()))
|
||||||
filter.addCondition(new Condition.Builder().setComparison(Comparison.eq).setField("kamusIndikatorId")
|
filter.addCondition(Condition.builder().comparison(Comparison.EQ).field("kamusIndikatorId").value(model.getId()).build());
|
||||||
.setValue(model.getId()).build());
|
filter.addCondition(Condition.builder().comparison(Comparison.INN).field("id").build());
|
||||||
}
|
|
||||||
filter.addCondition(new Condition.Builder().setComparison(Comparison.inn).setField("id").build());
|
|
||||||
|
|
||||||
Page<TargetIndikator> resultPageKontrak = targetDao.findAll(filter, pageable);
|
Page<TargetIndikator> resultPageKontrak = targetDao.findAll(filter, pageable);
|
||||||
List<TargetIndikator> resultDataKontrak = resultPageKontrak.getContent();
|
List<TargetIndikator> resultDataKontrak = resultPageKontrak.getContent();
|
||||||
|
|
||||||
DetailKamusIndikatorDto resultObj = new DetailKamusIndikatorDto();
|
DetailKamusIndikatorDto resultObj = new DetailKamusIndikatorDto();
|
||||||
|
|
||||||
resultObj.setKamus(model);
|
resultObj.setKamus(model);
|
||||||
resultObj.setListTarget(resultDataKontrak);
|
resultObj.setListTarget(resultDataKontrak);
|
||||||
|
|
||||||
dtos.add(resultObj);
|
dtos.add(resultObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return constructMapReturn(dtos, resultPage.getTotalElements(), resultPage.getTotalPages());
|
return constructMapReturn(dtos, resultPage.getTotalElements(), resultPage.getTotalPages());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,17 @@
|
|||||||
package com.jasamedika.medifirst2000.service.impl;
|
package com.jasamedika.medifirst2000.service.impl;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
||||||
import java.util.LinkedList;
|
import com.jasamedika.medifirst2000.dao.KamusIndikatorDao;
|
||||||
import java.util.List;
|
import com.jasamedika.medifirst2000.dao.KontrakKinerjaDao;
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.dao.TargetIndikatorDao;
|
||||||
|
import com.jasamedika.medifirst2000.dto.MatriksIndikatorDTO;
|
||||||
|
import com.jasamedika.medifirst2000.entities.KamusIndikator;
|
||||||
|
import com.jasamedika.medifirst2000.entities.TargetIndikator;
|
||||||
|
import com.jasamedika.medifirst2000.paging.Comparison;
|
||||||
|
import com.jasamedika.medifirst2000.paging.Condition;
|
||||||
|
import com.jasamedika.medifirst2000.paging.Filter;
|
||||||
|
import com.jasamedika.medifirst2000.service.MatriksIndikatorService;
|
||||||
|
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
@ -14,19 +21,10 @@ import org.springframework.data.domain.Sort.Direction;
|
|||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
import java.util.HashMap;
|
||||||
import com.jasamedika.medifirst2000.dao.KamusIndikatorDao;
|
import java.util.LinkedList;
|
||||||
import com.jasamedika.medifirst2000.dao.KontrakKinerjaDao;
|
import java.util.List;
|
||||||
import com.jasamedika.medifirst2000.dao.TargetIndikatorDao;
|
import java.util.Map;
|
||||||
import com.jasamedika.medifirst2000.dto.MatriksIndikatorDTO;
|
|
||||||
import com.jasamedika.medifirst2000.entities.KamusIndikator;
|
|
||||||
import com.jasamedika.medifirst2000.entities.KontrakKinerja;
|
|
||||||
import com.jasamedika.medifirst2000.entities.TargetIndikator;
|
|
||||||
import com.jasamedika.medifirst2000.paging.Comparison;
|
|
||||||
import com.jasamedika.medifirst2000.paging.Condition;
|
|
||||||
import com.jasamedika.medifirst2000.paging.Filter;
|
|
||||||
import com.jasamedika.medifirst2000.service.MatriksIndikatorService;
|
|
||||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
|
||||||
|
|
||||||
@Service("MatriksIndikatorService")
|
@Service("MatriksIndikatorService")
|
||||||
public class MatriksIndikatorServiceImpl implements MatriksIndikatorService{
|
public class MatriksIndikatorServiceImpl implements MatriksIndikatorService{
|
||||||
@ -60,12 +58,10 @@ public class MatriksIndikatorServiceImpl implements MatriksIndikatorService{
|
|||||||
for(KamusIndikator model : resultDataIKU){
|
for(KamusIndikator model : resultDataIKU){
|
||||||
|
|
||||||
Filter filter = new Filter();
|
Filter filter = new Filter();
|
||||||
if (CommonUtil.isNotNullOrEmpty(model.getId())) {
|
if (CommonUtil.isNotNullOrEmpty(model.getId()))
|
||||||
filter.addCondition(new Condition.Builder().setComparison(Comparison.eq).setField("kamusIndikatorId")
|
filter.addCondition(Condition.builder().comparison(Comparison.EQ).field("kamusIndikatorId").value(model.getId()).build());
|
||||||
.setValue(model.getId()).build());
|
filter.addCondition(Condition.builder().comparison(Comparison.INN).field("id").build());
|
||||||
}
|
|
||||||
filter.addCondition(new Condition.Builder().setComparison(Comparison.inn).setField("id").build());
|
|
||||||
|
|
||||||
Page<TargetIndikator> resultPageTarget = realisasiDao.findAll(filter, pageable);
|
Page<TargetIndikator> resultPageTarget = realisasiDao.findAll(filter, pageable);
|
||||||
List<TargetIndikator> resultDataTarget = resultPageTarget.getContent();
|
List<TargetIndikator> resultDataTarget = resultPageTarget.getContent();
|
||||||
|
|
||||||
|
|||||||
@ -235,15 +235,11 @@ public class PegawaiServiceImpl extends BaseVoServiceImpl implements PegawaiServ
|
|||||||
String namaLengkap) {
|
String namaLengkap) {
|
||||||
try {
|
try {
|
||||||
Filter filter = new Filter();
|
Filter filter = new Filter();
|
||||||
if (CommonUtil.isNotNullOrEmpty(id)) {
|
if (CommonUtil.isNotNullOrEmpty(id))
|
||||||
filter.addCondition(
|
filter.addCondition(Condition.builder().comparison(Comparison.EQ).field("id").value(id).build());
|
||||||
new Condition.Builder().setComparison(Comparison.eq).setField("id").setValue(id).build());
|
if (CommonUtil.isNotNullOrEmpty(namaLengkap))
|
||||||
}
|
filter.addCondition(Condition.builder().comparison(Comparison.EQ).field("namaLengkap").value(namaLengkap).build());
|
||||||
if (CommonUtil.isNotNullOrEmpty(namaLengkap)) {
|
filter.addCondition(Condition.builder().comparison(Comparison.INN).field("id").build());
|
||||||
filter.addCondition(new Condition.Builder().setComparison(Comparison.eq).setField("namaLengkap")
|
|
||||||
.setValue(namaLengkap).build());
|
|
||||||
}
|
|
||||||
filter.addCondition(new Condition.Builder().setComparison(Comparison.inn).setField("id").build());
|
|
||||||
Pageable pageable = new PageRequest(page, take, Sort.Direction.ASC, sort);
|
Pageable pageable = new PageRequest(page, take, Sort.Direction.ASC, sort);
|
||||||
Page<Pegawai> resultPage = pegawaiDao.findAll(filter, pageable);
|
Page<Pegawai> resultPage = pegawaiDao.findAll(filter, pageable);
|
||||||
List<Pegawai> pegawaiList = resultPage.getContent();
|
List<Pegawai> pegawaiList = resultPage.getContent();
|
||||||
|
|||||||
@ -1,22 +1,5 @@
|
|||||||
package com.jasamedika.medifirst2000.service.impl;
|
package com.jasamedika.medifirst2000.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.converter.RuanganConverter;
|
import com.jasamedika.medifirst2000.converter.RuanganConverter;
|
||||||
import com.jasamedika.medifirst2000.dao.KamarDao;
|
import com.jasamedika.medifirst2000.dao.KamarDao;
|
||||||
import com.jasamedika.medifirst2000.dao.RuanganDao;
|
import com.jasamedika.medifirst2000.dao.RuanganDao;
|
||||||
@ -31,6 +14,22 @@ import com.jasamedika.medifirst2000.service.RuanganService;
|
|||||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||||
import com.jasamedika.medifirst2000.util.JsonUtil;
|
import com.jasamedika.medifirst2000.util.JsonUtil;
|
||||||
import com.jasamedika.medifirst2000.vo.RuanganVO;
|
import com.jasamedika.medifirst2000.vo.RuanganVO;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement class for PasienService
|
* Implement class for PasienService
|
||||||
@ -74,16 +73,11 @@ public class RuanganServiceImpl extends BaseVoServiceImpl implements RuanganServ
|
|||||||
String kdRuangan) {
|
String kdRuangan) {
|
||||||
|
|
||||||
Filter filter = new Filter();
|
Filter filter = new Filter();
|
||||||
if (CommonUtil.isNotNullOrEmpty(nama)) {
|
if (CommonUtil.isNotNullOrEmpty(nama))
|
||||||
filter.addCondition(new Condition.Builder().setComparison(Comparison.lk).setField("namaRuangan")
|
filter.addCondition(Condition.builder().comparison(Comparison.LK).field("namaRuangan").value(nama).build());
|
||||||
.setValue(nama).build());
|
if (CommonUtil.isNotNullOrEmpty(kdRuangan))
|
||||||
}
|
filter.addCondition(Condition.builder().comparison(Comparison.LK).field("kdRuangan").value(kdRuangan).build());
|
||||||
|
filter.addCondition(Condition.builder().comparison(Comparison.INN).field("id").build());
|
||||||
if (CommonUtil.isNotNullOrEmpty(kdRuangan)) {
|
|
||||||
filter.addCondition(new Condition.Builder().setComparison(Comparison.lk).setField("kdRuangan")
|
|
||||||
.setValue(kdRuangan).build());
|
|
||||||
}
|
|
||||||
filter.addCondition(new Condition.Builder().setComparison(Comparison.inn).setField("id").build());
|
|
||||||
|
|
||||||
Pageable pageable = new PageRequest(page, limit, Sort.Direction.ASC, sort);
|
Pageable pageable = new PageRequest(page, limit, Sort.Direction.ASC, sort);
|
||||||
Page<Ruangan> resultPage = ruanganDao.findAll(filter, pageable);
|
Page<Ruangan> resultPage = ruanganDao.findAll(filter, pageable);
|
||||||
|
|||||||
@ -1,136 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.service.test;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.nio.channels.FileChannel;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
//import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
public class CopyFilesExample {
|
|
||||||
public static void main(String[] args) throws InterruptedException,
|
|
||||||
IOException {
|
|
||||||
// domain
|
|
||||||
String folderWorkspace="jasamedika-domain";
|
|
||||||
String folderChange="entities";
|
|
||||||
String fromFileName="Bedah";
|
|
||||||
String toFileName="Gizi";
|
|
||||||
String endFileName="";
|
|
||||||
//domain File
|
|
||||||
copyAndReplace(folderWorkspace, folderChange, fromFileName, toFileName, endFileName);
|
|
||||||
|
|
||||||
//vo
|
|
||||||
folderChange="vo";
|
|
||||||
endFileName="VO";
|
|
||||||
//vo File
|
|
||||||
copyAndReplace(folderWorkspace, folderChange, fromFileName, toFileName, endFileName);
|
|
||||||
|
|
||||||
// converter -dao -service -service impl
|
|
||||||
folderWorkspace="jasamedika-business";
|
|
||||||
folderChange="converter";
|
|
||||||
endFileName="Converter";
|
|
||||||
//Converter File
|
|
||||||
copyAndReplace(folderWorkspace, folderChange, fromFileName, toFileName, endFileName);
|
|
||||||
|
|
||||||
folderChange="dao";
|
|
||||||
endFileName="Dao";
|
|
||||||
//Dao File
|
|
||||||
copyAndReplace(folderWorkspace, folderChange, fromFileName, toFileName, endFileName);
|
|
||||||
|
|
||||||
folderChange="service";
|
|
||||||
endFileName="Service";
|
|
||||||
//Service File
|
|
||||||
copyAndReplace(folderWorkspace, folderChange, fromFileName, toFileName, endFileName);
|
|
||||||
|
|
||||||
folderChange="service\\impl";
|
|
||||||
endFileName="ServiceImpl";
|
|
||||||
//ServiceImpl File
|
|
||||||
copyAndReplace(folderWorkspace, folderChange, fromFileName, toFileName, endFileName);
|
|
||||||
|
|
||||||
// controller
|
|
||||||
folderWorkspace="jasamedika-web";
|
|
||||||
folderChange="controller";
|
|
||||||
endFileName="Controller";
|
|
||||||
//Controller File
|
|
||||||
copyAndReplace(folderWorkspace, folderChange, fromFileName, toFileName, endFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void copyAndReplace(String folderWorkspace, String folderChange, String fromFileName,
|
|
||||||
String toFileName, String endFileName) throws IOException, InterruptedException {
|
|
||||||
copyFile(fromFileName,toFileName,folderWorkspace,folderChange,endFileName);
|
|
||||||
Thread.sleep(3000);
|
|
||||||
replaceFile(fromFileName,toFileName,folderWorkspace,folderChange,endFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void replaceFile(String fromFileName,String toFileName,String folderWorkspace,String folderChange,String endFileName) {
|
|
||||||
System.out.println("REPLACE FILE " +folderChange+ " START");
|
|
||||||
File destFileConverter = new File("E:\\workspace-7\\"+folderWorkspace+"\\src\\main\\java\\com\\jasamedika\\medifirst2000\\"+folderChange+"\\Pap"+toFileName+endFileName+".java");
|
|
||||||
try{
|
|
||||||
FileInputStream fstream = new FileInputStream(destFileConverter);
|
|
||||||
DataInputStream in = new DataInputStream(fstream);
|
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
|
||||||
String strLine;
|
|
||||||
String result = null;
|
|
||||||
StringBuffer stringBuffer=new StringBuffer();
|
|
||||||
while((strLine=br.readLine())!=null)
|
|
||||||
{
|
|
||||||
System.out.println("LINE : "+strLine);
|
|
||||||
Pattern p = Pattern.compile(fromFileName, Pattern.CASE_INSENSITIVE);
|
|
||||||
Matcher m = p.matcher(strLine);
|
|
||||||
result = m.replaceAll(toFileName);
|
|
||||||
stringBuffer.append(result+"\n");
|
|
||||||
System.out.println("RESULT : "+result);
|
|
||||||
}
|
|
||||||
FileWriter fw = new FileWriter(destFileConverter);
|
|
||||||
fw.write(stringBuffer.toString());
|
|
||||||
fw.close();
|
|
||||||
in.close();
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
System.out.println("REPLACE FILE " +folderChange+ " END");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static void copyFile(String fromFileName,String toFileName,String folderWorkspace,String folderChange,String endFileName) throws IOException {
|
|
||||||
System.out.println("COPY FILE " +folderChange+ " START");
|
|
||||||
File source = new File("E:\\workspace-7\\"+folderWorkspace+"\\src\\main\\java\\com\\jasamedika\\medifirst2000\\"+folderChange+"\\Pap"+fromFileName+endFileName+".java");
|
|
||||||
File destFile = new File("E:\\workspace-7\\"+folderWorkspace+"\\src\\main\\java\\com\\jasamedika\\medifirst2000\\"+folderChange+"\\Pap"+toFileName+endFileName+".java");
|
|
||||||
|
|
||||||
// copy file using FileStreams
|
|
||||||
long start = System.nanoTime();
|
|
||||||
long end;
|
|
||||||
copyFileUsingFileStreams(source, destFile);
|
|
||||||
System.out.println("Time taken by FileStreams Copy = "
|
|
||||||
+ (System.nanoTime() - start));
|
|
||||||
System.out.println("COPY FILE " +folderChange+ " END");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void copyFileUsingFileStreams(File source, File dest)
|
|
||||||
throws IOException {
|
|
||||||
InputStream input = null;
|
|
||||||
OutputStream output = null;
|
|
||||||
try {
|
|
||||||
input = new FileInputStream(source);
|
|
||||||
output = new FileOutputStream(dest);
|
|
||||||
byte[] buf = new byte[1024];
|
|
||||||
int bytesRead;
|
|
||||||
while ((bytesRead = input.read(buf)) > 0) {
|
|
||||||
output.write(buf, 0, bytesRead);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
input.close();
|
|
||||||
output.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.service.test;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class FindRekursif {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String javaFileName="Produk";
|
|
||||||
try {
|
|
||||||
searchFile(javaFileName);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void searchFile(String javaFileName) throws IOException {
|
|
||||||
System.out.println("SEARCH FILE START");
|
|
||||||
File file = new File("E:\\workspace-7\\jasamedika-domain\\src\\main\\java\\com\\jasamedika\\medifirst2000\\entities\\"+javaFileName+".java");
|
|
||||||
FileInputStream fstream = new FileInputStream(file);
|
|
||||||
DataInputStream in = new DataInputStream(fstream);
|
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
|
||||||
String strLine;
|
|
||||||
StringBuffer stringBuffer=new StringBuffer();
|
|
||||||
int count=1;
|
|
||||||
while((strLine=br.readLine())!=null)
|
|
||||||
{
|
|
||||||
Pattern p = Pattern.compile(javaFileName, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
|
|
||||||
Matcher m = p.matcher(strLine);
|
|
||||||
if( m.find()){
|
|
||||||
System.out.println("COUNT "+count+" RESULT : "+strLine);
|
|
||||||
}
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
System.out.println("SEARCH FILE END");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package com.jasamedika.medifirst2000.util;
|
package com.jasamedika.medifirst2000.util;
|
||||||
|
|
||||||
public class DateHelper {
|
public class DateHelper {
|
||||||
|
|
||||||
public static String toMonthName(String monthNumber){
|
public static String toMonthName(String monthNumber){
|
||||||
String result="";
|
String result="";
|
||||||
switch (monthNumber) {
|
switch (monthNumber) {
|
||||||
|
|||||||
@ -1,28 +1,22 @@
|
|||||||
package com.jasamedika.medifirst2000.util;
|
package com.jasamedika.medifirst2000.util;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class HibernateInitialize {
|
public class HibernateInitialize {
|
||||||
public static <T> T initializeAndUnproxy(T entity) {
|
|
||||||
if (entity == null) {
|
|
||||||
throw new
|
|
||||||
NullPointerException("Entity passed for initialization is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
public static <T> T initializeAndUnproxy(T entity) {
|
||||||
{
|
if (entity == null)
|
||||||
Hibernate.initialize(entity);
|
throw new NullPointerException("Entity passed for initialization is null");
|
||||||
if (entity instanceof HibernateProxy) {
|
try {
|
||||||
entity = (T) ((HibernateProxy) entity).getHibernateLazyInitializer()
|
Hibernate.initialize(entity);
|
||||||
.getImplementation();
|
if (entity instanceof HibernateProxy)
|
||||||
}
|
entity = (T) ((HibernateProxy) entity).getHibernateLazyInitializer().getImplementation();
|
||||||
|
} catch(Exception ex) {
|
||||||
|
log.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,38 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.util;
|
|
||||||
|
|
||||||
import com.ulisesbocchio.jasyptspringboot.annotation.EncryptablePropertySource;
|
|
||||||
import com.ulisesbocchio.jasyptspringboot.annotation.EncryptablePropertySources;
|
|
||||||
import org.jasypt.encryption.StringEncryptor;
|
|
||||||
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
|
|
||||||
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author salmanoe
|
|
||||||
* @version 1.0.0
|
|
||||||
* @since 23/01/2024
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@EncryptablePropertySources({@EncryptablePropertySource("classpath:jdbc.bridging.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.cssd.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.development.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.ip3rs.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.it.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.k3kl.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.laundry.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.localhost.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.mirroring.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.pelayanan.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.sdm.properties"),
|
|
||||||
@EncryptablePropertySource("classpath:jdbc.web.properties")})
|
|
||||||
public class JasyptConfig {
|
|
||||||
@Bean
|
|
||||||
public StringEncryptor jasyptStringEncryptor() {
|
|
||||||
String password = System.getProperty("jasypt.encryptor.password");
|
|
||||||
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
|
|
||||||
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
|
|
||||||
config.setPassword(password);
|
|
||||||
return encryptor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,29 +1,28 @@
|
|||||||
package com.jasamedika.medifirst2000.util;
|
package com.jasamedika.medifirst2000.util;
|
||||||
|
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.UrlResource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.springframework.core.io.UrlResource;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author salmanoe
|
* @author salmanoe
|
||||||
* @since Jan 31, 2023
|
* @since Jan 31, 2023
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ResourceUtils {
|
public class ResourceUtils {
|
||||||
|
|
||||||
public static Resource loadFile(String fileName) throws Exception {
|
public static Resource loadFile(String fileName) throws Exception {
|
||||||
try {
|
try {
|
||||||
Path filePath = Paths.get(fileName).toAbsolutePath().normalize();
|
Path filePath = Paths.get(fileName).toAbsolutePath().normalize();
|
||||||
Resource resource = new UrlResource(filePath.toUri());
|
Resource resource = new UrlResource(filePath.toUri());
|
||||||
if (resource.exists()) {
|
if (!resource.exists())
|
||||||
return resource;
|
|
||||||
} else {
|
|
||||||
throw new FileNotFoundException("File not found " + fileName);
|
throw new FileNotFoundException("File not found " + fileName);
|
||||||
}
|
return resource;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new FileNotFoundException("File not found " + fileName);
|
throw new FileNotFoundException("File not found " + fileName);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
<!-- <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
|
|
||||||
monitoring="autodetect" dynamicConfig="true">
|
|
||||||
|
|
||||||
<diskStore path="java.io.tmpdir" />
|
|
||||||
<diskStore path="c:\\cacheTest" />
|
|
||||||
|
|
||||||
<cache name="testFindCache"
|
|
||||||
maxEntriesLocalHeap="10000"
|
|
||||||
maxEntriesLocalDisk="100000"
|
|
||||||
eternal="false"
|
|
||||||
diskSpoolBufferSizeMB="20"
|
|
||||||
timeToIdleSeconds="300" timeToLiveSeconds="600"
|
|
||||||
memoryStoreEvictionPolicy="LFU"
|
|
||||||
transactionalMode="off">
|
|
||||||
<persistence strategy="localTempSwap" />
|
|
||||||
</cache>
|
|
||||||
|
|
||||||
</ehcache> -->
|
|
||||||
Loading…
x
Reference in New Issue
Block a user