diff --git a/jasamedika-business/pom.xml b/jasamedika-business/pom.xml
index f35e83dc..ce994b2f 100644
--- a/jasamedika-business/pom.xml
+++ b/jasamedika-business/pom.xml
@@ -283,6 +283,15 @@
${commons-io.version}
+
+
+
+ org.projectlombok
+ lombok
+ ${project.lombok.version}
+ provided
+
+
Jasa Medika
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/chace/ChaceConfig.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/chace/ChaceConfig.java
deleted file mode 100644
index 9beae8a5..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/chace/ChaceConfig.java
+++ /dev/null
@@ -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");
- }
-
-}*/
\ No newline at end of file
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/converter/base/BaseVoConverter.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/converter/base/BaseVoConverter.java
index 77312a5d..dc422b4d 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/converter/base/BaseVoConverter.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/converter/base/BaseVoConverter.java
@@ -1,9 +1,9 @@
package com.jasamedika.medifirst2000.converter.base;
-import java.util.List;
-
import com.jasamedika.medifirst2000.base.BaseModel;
+import java.util.List;
+
/**
* Base Converter Class between V and VO
*
@@ -14,28 +14,19 @@ public interface BaseVoConverter {
/**
* transfer value from vo object to domain object for enum value, please do
* manually using Enum.values()[ordinal]
- *
- * @param vo
- * @param model
- * @return
- */
- public T transferVOToModel(V vo, T model);
+ *
+ */
+ T transferVOToModel(V vo, T model);
/**
* transfer value from list of domain object to list of vo object
- *
- * @param models
- * @param vos
- * @return
- */
- public List transferListOfModelToListOfVO(List models, List vos);
+ *
+ */
+ List transferListOfModelToListOfVO(List models, List vos);
/**
* transfer value from domain object to vo object
- *
- * @param model
- * @param vo
- * @return
- */
- public V transferModelToVO(T model, V vo);
+ *
+ */
+ V transferModelToVO(T model, V vo);
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/CoreDao.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/CoreDao.java
index a75565fd..f0ec1b79 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/CoreDao.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/CoreDao.java
@@ -1,17 +1,17 @@
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.dao.custom.base.util.PaginationResult;
import com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue;
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
* 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
* methods provides additional information for how to configure it for the
* desired type of transaction control.
@@ -67,9 +67,9 @@ public interface CoreDao extends FindLayerDao {
* null if not using.
* @param rowStartIdxAndCount
* Optional int varargs.
- * 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.
- * rowStartIdxAndCount[1] specifies the the maximum number of
+ * rowStartIdxAndCount[1] specifies the maximum number of
* results to return.
* @return A pagination result
*/
@@ -92,15 +92,15 @@ public interface CoreDao extends FindLayerDao {
* The list of property name and sorting direction pairs. Set to
* null, if not using.
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return PagintationResult
*
*/
PaginationResult paginateByMapOfProperties(
- Map propertiesMap,
+ Map propertiesMap,
List leftJoinFetchColumns, List orders,
final int... rowStartIdxAndCount);
@@ -119,21 +119,21 @@ public interface CoreDao extends FindLayerDao {
* Sorting orders. Set to null if not using.
* @param rowStartIdxAndCount
* Optional int varargs.
- * 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.
- * rowStartIdxAndCount[1] specifies the the maximum number of
+ * rowStartIdxAndCount[1] specifies the maximum number of
* results to return.
* @return List
*/
PaginationResult paginateLikeMapOfProperties(
- Map propertiesMap,
+ Map propertiesMap,
List leftJoinFetchColumns, List orders,
final int... rowStartIdxAndCount);
/**
* Filters finding and counting instances by several criteria
* 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 AND relationship. Note that this is not an OR
* filter.
*
@@ -145,7 +145,7 @@ public interface CoreDao extends FindLayerDao {
* PropCriteriaAndValue elements, which is a set of
* three elements typically composed of the name of the property,
* 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
* a collection of values.
* Follows a list of the supported queryComparators for criteria
@@ -164,7 +164,7 @@ public interface CoreDao extends FindLayerDao {
* Property is compared with value which is a List or
* Collection:
*
- * - BEETWEEN List is advisable as it it ordered, although
+ *
- BEETWEEN List is advisable as it is ordered, although
* collection is supported
*
- IN
*
@@ -186,9 +186,9 @@ public interface CoreDao extends FindLayerDao {
* Sorting orders. Set to null if not using.
* @param rowStartIdxAndCount
* Optional int varargs.
- * 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.
- * rowStartIdxAndCount[1] specifies the the maximum number of
+ * rowStartIdxAndCount[1] specifies the maximum number of
* results to return.
* @return PaginationResult
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
@@ -201,13 +201,13 @@ public interface CoreDao extends FindLayerDao {
* Finds and counts all elements of the table in order.
*
* @param leftJoinFetchColumns
- * List of left join fetch property name..
+ * List of left join fetch property name.
* @param orders
* the orders
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return PaginationResult
*/
@@ -228,9 +228,9 @@ public interface CoreDao extends FindLayerDao {
* @param orders
* the orders
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return PaginationResult
*/
@@ -256,7 +256,7 @@ public interface CoreDao extends FindLayerDao {
* do "OR" Expression (Disjunction). The method will ignore the third and
* successive parameters in case we have them, such as
* 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
* the list of PropCriteriaAndValue filter.
@@ -264,7 +264,7 @@ public interface CoreDao extends FindLayerDao {
* Comparison expression either is conjunction ("AND") or
* disjunction ("OR"). Put null will make the
* 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.
*
* @return true, if successful {@inheritDoc}
@@ -274,9 +274,8 @@ public interface CoreDao extends FindLayerDao {
/**
* Remove object from session cache.
- *
- * @param coreDomain
- */
+ *
+ */
void evict(BaseModel coreDomain);
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/CountLayerDao.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/CountLayerDao.java
index 715a4c30..b8a75b43 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/CountLayerDao.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/CountLayerDao.java
@@ -1,11 +1,11 @@
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.dao.custom.base.util.PropCriteriaAndValue;
+import java.util.List;
+import java.util.Map;
+
/**
* @author Roberto
*
@@ -30,7 +30,7 @@ public interface CountLayerDao extends KernelDao {
* searched values, supports null
* @return List
*/
- Integer countByMapOfProperties(Map propertiesMap);
+ Integer countByMapOfProperties(Map propertiesMap);
/**
* Performs the count operation equivalent to the
@@ -55,7 +55,7 @@ public interface CountLayerDao extends KernelDao {
* searched values, supports null
* @return Integer
*/
- Integer countLikeMapOfProperties(Map propertiesMap);
+ Integer countLikeMapOfProperties(Map propertiesMap);
/**
* Performs the count operation equivalent to the
@@ -72,7 +72,7 @@ public interface CountLayerDao extends KernelDao {
/**
* Counts filtered instances by several criteria
* 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 AND relationship. Note that this is not an OR
* filter.
*
@@ -81,7 +81,7 @@ public interface CountLayerDao extends KernelDao {
* PropCriteriaAndValue elements, which is a set of
* three elements typically composed of the name of the property,
* 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
* a collection of values.
* Follows a list of the supported queryComparators for criteria
@@ -100,7 +100,7 @@ public interface CountLayerDao extends KernelDao {
* Property is compared with value which is a List or
* Collection:
*
- * - BEETWEEN List is mandatory as it it ordered
+ *
- BEETWEEN List is mandatory as it is ordered
*
- IN
*
* Property is checked against criteria regardless value
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/FindLayerDao.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/FindLayerDao.java
index 672cb508..ed344b37 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/FindLayerDao.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/FindLayerDao.java
@@ -1,13 +1,12 @@
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.dao.custom.base.util.PropCriteriaAndValue;
import com.jasamedika.medifirst2000.dao.custom.base.util.QueryOrder;
+import org.hibernate.NonUniqueResultException;
+
+import java.util.List;
+import java.util.Map;
/**
* @author Roberto
@@ -16,7 +15,7 @@ import com.jasamedika.medifirst2000.dao.custom.base.util.QueryOrder;
public interface FindLayerDao extends CountLayerDao {
/**
- * Finds an instance by its Id.
+ * Finds an instance by its ID.
*
* @param id
* the id
@@ -26,7 +25,7 @@ public interface FindLayerDao extends CountLayerDao {
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
* The id to look up for
@@ -41,9 +40,9 @@ public interface FindLayerDao extends CountLayerDao {
* Finds all elements of the table.
*
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
@@ -53,13 +52,13 @@ public interface FindLayerDao extends CountLayerDao {
* Finds all elements of the table in order.
*
* @param leftJoinFetchColumns
- * List of left join fetch property name..
+ * List of left join fetch property name.
* @param orders
* the orders
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
@@ -75,9 +74,9 @@ public interface FindLayerDao extends CountLayerDao {
* @param value
* The value of the property.
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
@@ -111,9 +110,9 @@ public interface FindLayerDao extends CountLayerDao {
* @param orders
* The list of property name and sorting direction pairs.
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
@@ -134,9 +133,9 @@ public interface FindLayerDao extends CountLayerDao {
* The list of property name and sorting direction pairs.
*
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
@@ -154,9 +153,9 @@ public interface FindLayerDao extends CountLayerDao {
* @param value
* the value
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
@@ -175,9 +174,9 @@ public interface FindLayerDao extends CountLayerDao {
* @param orders
* The order clause.
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
@@ -198,9 +197,9 @@ public interface FindLayerDao extends CountLayerDao {
* @param orders
* the orders
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
@@ -211,7 +210,7 @@ public interface FindLayerDao extends CountLayerDao {
/**
* Filters instances by several criteria
* 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 AND relationship. Note that this is not an OR
* filter.
*
@@ -220,7 +219,7 @@ public interface FindLayerDao extends CountLayerDao {
* PropCriteriaAndValue elements, which is a set of
* three elements typically composed of the name of the property,
* 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
* a collection of values.
* Follows a list of the supported queryComparators for criteria
@@ -239,7 +238,7 @@ public interface FindLayerDao extends CountLayerDao {
* Property is compared with value which is a List or
* Collection:
*
- * - BEETWEEN List is advisable as it it ordered, although
+ *
- BEETWEEN List is advisable as it is ordered, although
* collection is supported
*
- IN
*
@@ -258,9 +257,9 @@ public interface FindLayerDao extends CountLayerDao {
*
* See PropCriteriaAndValue for more details.
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
@@ -271,7 +270,7 @@ public interface FindLayerDao extends CountLayerDao {
/**
* Filters instances by several criteria
* 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 AND relationship. Note that this is not an OR
* filter.
*
@@ -280,7 +279,7 @@ public interface FindLayerDao extends CountLayerDao {
* PropCriteriaAndValue elements, which is a set of
* three elements typically composed of the name of the property,
* 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
* a collection of values.
* Follows a list of the supported queryComparators for criteria
@@ -299,7 +298,7 @@ public interface FindLayerDao extends CountLayerDao {
* Property is compared with value which is a List or
* Collection:
*
- * - BEETWEEN List is advisable as it it ordered, although
+ *
- BEETWEEN List is advisable as it is ordered, although
* collection is supported
*
- IN
*
@@ -321,9 +320,9 @@ public interface FindLayerDao extends CountLayerDao {
* Sorting orders
* @param rowStartIdxAndCount
* Optional int varargs.
- * 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.
- * rowStartIdxAndCount[1] specifies the the maximum number of
+ * rowStartIdxAndCount[1] specifies the maximum number of
* results to return.
* @return List
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
@@ -334,7 +333,7 @@ public interface FindLayerDao extends CountLayerDao {
/**
* Filters instances by several criteria
* 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 AND relationship. Note that this is not an OR
* filter.
*
@@ -345,7 +344,7 @@ public interface FindLayerDao extends CountLayerDao {
* PropCriteriaAndValue elements, which is a set of
* three elements typically composed of the name of the property,
* 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
* a collection of values.
* Follows a list of the supported queryComparators for criteria
@@ -364,7 +363,7 @@ public interface FindLayerDao extends CountLayerDao {
* Property is compared with value which is a List or
* Collection:
*
- * - BEETWEEN List is advisable as it it ordered, although
+ *
- BEETWEEN List is advisable as it is ordered, although
* collection is supported
*
- IN
*
@@ -386,9 +385,9 @@ public interface FindLayerDao extends CountLayerDao {
* Sorting orders
* @param rowStartIdxAndCount
* Optional int varargs.
- * 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.
- * rowStartIdxAndCount[1] specifies the the maximum number of
+ * rowStartIdxAndCount[1] specifies the maximum number of
* results to return.
* @return List
* @see com.jasamedika.medifirst2000.dao.custom.base.util.PropCriteriaAndValue
@@ -398,7 +397,7 @@ public interface FindLayerDao extends CountLayerDao {
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
* own custom query. In case that one of the properties value is null it
* performs the IS NULL operation for that parameter.
@@ -409,13 +408,13 @@ public interface FindLayerDao extends CountLayerDao {
* @param orders
* The list of property name and sorting direction pairs.
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
- List findByMapOfProperties(Map propertiesMap,
+ List findByMapOfProperties(Map propertiesMap,
List orders, final int... rowStartIdxAndCount);
/**
@@ -433,13 +432,13 @@ public interface FindLayerDao extends CountLayerDao {
* The list of property name and sorting direction pairs.
*
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
- List findByMapOfProperties(Map propertiesMap,
+ List findByMapOfProperties(Map propertiesMap,
List leftJoinFetchColumns, List orders,
final int... rowStartIdxAndCount);
@@ -453,14 +452,14 @@ public interface FindLayerDao extends CountLayerDao {
* A map containing the properties we're looking up for and their
* searched values, supports null
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
List findLikeMapOfProperties(
- Map propertiesMap,
+ Map propertiesMap,
final int... rowStartIdxAndCount);
/**
@@ -475,14 +474,14 @@ public interface FindLayerDao extends CountLayerDao {
* @param orders
* the orders
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
List findLikeMapOfProperties(
- Map propertiesMap,
+ Map propertiesMap,
List orders, final int... rowStartIdxAndCount);
/**
@@ -499,14 +498,14 @@ public interface FindLayerDao extends CountLayerDao {
* @param orders
* the orders
* @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
- * results. rowStartIdxAndCount[1] specifies the the maximum
+ * results. rowStartIdxAndCount[1] specifies the maximum
* number of results to return.
* @return List
*/
List findLikeMapOfProperties(
- Map propertiesMap,
+ Map propertiesMap,
List leftJoinFetchColumns, List orders,
final int... rowStartIdxAndCount);
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/KernelDao.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/KernelDao.java
index 2f8ed2a2..8b0cee02 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/KernelDao.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/custom/base/KernelDao.java
@@ -1,10 +1,9 @@
package com.jasamedika.medifirst2000.dao.custom.base;
-import java.util.List;
+import com.jasamedika.medifirst2000.base.BaseModel;
import javax.persistence.Query;
-
-import com.jasamedika.medifirst2000.base.BaseModel;
+import java.util.List;
/**
* The Interface KernelDao
@@ -13,72 +12,53 @@ import com.jasamedika.medifirst2000.base.BaseModel;
*/
public interface KernelDao {
- /** The Constant UNCHECKED. */
String UNCHECKED = "unchecked";
- /** The Constant I18N_INSTANCE. */
String I18N_INSTANCE = " instance";
- /** The Constant I18N_INSERT. */
String I18N_INSERT = "insert ";
- /** The Constant I18N_UPDATE. */
String I18N_UPDATE = "update ";
- /** The Constant I18N_REMOVE. */
String I18N_REMOVE = "remove ";
- /** The Constant I18N_FIND. */
String I18N_FIND = "find ";
- /** The Constant I18N_COUNT. */
String I18N_COUNT = "count ";
- /** The Constant I18N_FAILED. */
String I18N_FAILED = " failed";
- /** The Constant I18N_SUCCEED. */
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: ";
- /** The Constant AS_MODEL */
String AS_MODEL = " AS model ";
- /** The Constant WHERE */
String WHERE = " WHERE ";
- /** The Constant AND */
String AND = " AND ";
- /** The Constant AND */
String OR = " OR ";
- /** The Constant I18N_REMOVE_BULK. */
String I18N_REMOVE_BULK = "remove bulk on ";
- /** The Constant JOIN_TEXT_ESTIMATED_LENGTH */
int JOIN_TEXT_ESTIMATED_LENGTH = 32;
- /** The Constant JOIN_FETCH_TEXT_ESTIMATED_LENGTH */
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.
*
* @param query
- * Already well formed query with all parameters passed
+ * Already well-formed query with all parameters passed
* @param rowStartIdxAndCount
* rowStartIdxAndCount Optional int varargs.
- * 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.
- * rowStartIdxAndCount[1] specifies the the maximum number of
+ * rowStartIdxAndCount[1] specifies the maximum number of
* results to return.
* @return The resulting list of the query
* @author Roberto
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/exception/ServiceVOException.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/exception/ServiceVOException.java
index 813d86b0..7490ca0b 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/exception/ServiceVOException.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/exception/ServiceVOException.java
@@ -1,18 +1,14 @@
package com.jasamedika.medifirst2000.exception;
+import lombok.NoArgsConstructor;
+
/**
* ServiceVOException is class for containing exception that throw in service layer
*
* @author Roberto
*/
+@NoArgsConstructor
public class ServiceVOException extends RuntimeException {
- /**
- * serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- public ServiceVOException() {
- }
public ServiceVOException(String s) {
super(s);
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/LoggingAdvise.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/LoggingAdvise.java
deleted file mode 100644
index 7177b0b0..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/LoggingAdvise.java
+++ /dev/null
@@ -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);
- }
-
-
-}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/MainLoggingApp.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/MainLoggingApp.java
deleted file mode 100644
index 51ab88f1..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/MainLoggingApp.java
+++ /dev/null
@@ -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 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());
-
- }
-}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/ObjectUtil.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/ObjectUtil.java
deleted file mode 100644
index b3677b25..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/ObjectUtil.java
+++ /dev/null
@@ -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 getColumnNamesAndValues(final Object object)
- throws IllegalArgumentException, IllegalAccessException {
- Class extends Object> c = object.getClass();
-
- Map 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;
- }
-
-}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/entities/Logging.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/entities/Logging.java
index d34e9475..5797370b 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/entities/Logging.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/entities/Logging.java
@@ -1,37 +1,18 @@
package com.jasamedika.medifirst2000.logging.entities;
+import lombok.Getter;
+import lombok.Setter;
+
/**
- * Entiti class for Logging, contoh saja
+ * Entity class for Logging
*
* @author Roberto
*/
+@Getter
+@Setter
public class Logging {
+
private String deskripsi;
private String nama;
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;
- }
-
}
\ No newline at end of file
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/entities/wrapper/LoggingMapper.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/entities/wrapper/LoggingMapper.java
index cb613f7c..4208cb1f 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/entities/wrapper/LoggingMapper.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/entities/wrapper/LoggingMapper.java
@@ -1,18 +1,18 @@
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.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
*/
public class LoggingMapper implements RowMapper {
+
public Logging mapRow(ResultSet rs, int rowNum) throws SQLException {
Logging student = new Logging();
student.setId(rs.getInt("id"));
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/async/Constants.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/async/Constants.java
index d97999eb..4306404c 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/async/Constants.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/async/Constants.java
@@ -1,16 +1,17 @@
package com.jasamedika.medifirst2000.logging.hibernate.async;
+/**
+ * @author Syamsu
+ */
public class Constants {
+
public static final class HttpHeader {
public static final String SUPERVISING = "Supervising";
public static final String MODULE = "Module";
public static final String FORM = "Form";
public static final String ACTION = "Action";
-
- public static final String URL_FORM = "AlamatUrlForm"; // syamsu
- public static final String KD_RUANGAN = "KdRuangan"; // syamsu
- public static final String KD_USER = "KdUser"; // syamsu
-
-
+ public static final String URL_FORM = "AlamatUrlForm";
+ public static final String KD_RUANGAN = "KdRuangan";
+ public static final String KD_USER = "KdUser";
}
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/async/LoggingSystemAsynchronous.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/async/LoggingSystemAsynchronous.java
index e331da5d..5358166d 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/async/LoggingSystemAsynchronous.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/async/LoggingSystemAsynchronous.java
@@ -1,23 +1,9 @@
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.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
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.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
public class LoggingSystemAsynchronous {
- private static final Logger LOGGER = LoggerFactory.getLogger(LoggingSystemAsynchronous.class);
+ private static final Logger LOGGER = getLogger(LoggingSystemAsynchronous.class);
@Autowired
DataSource dataSource;
@@ -43,25 +40,21 @@ public class LoggingSystemAsynchronous {
@Autowired
HttpServletRequest request;
- Map commit = new HashMap();
+ Map commit = new HashMap<>();
Object entity;
private static class Holder {
String userName;
String superVisor;
-
String host;
-
String noRecP;
String detilCrud;
String jSonObject;
String method;
String object;
int kdHistoryLogin;
-
Date crudIn = new Date();
-
Object entity;
Serializable id;
Object[] currentState;
@@ -74,14 +67,10 @@ public class LoggingSystemAsynchronous {
final Object o = new Object();
public void saveSignOutLog(String userName, int IdPegawai) {
-
JdbcTemplate jdbcTemplateObject = new JdbcTemplate(dataSource);
-
asynchMethodtoLogSign(0, 0, userName, IdPegawai, jdbcTemplateObject, false);
}
- /// SignIn Log
-
public void saveSignInLog(int modulaplikasiId, int ruanganId, String userName, int idPegawai) {
String currentPrincipalName = "";
if (userName == null) {
@@ -117,26 +106,21 @@ public class LoggingSystemAsynchronous {
+ "nextval('historyloginmodulaplikasi_m_id_seq'), ?, ?, "
+ "?, ?, ?, "
+ "?, ?)";
-
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
-
String host = request.getRemoteHost();
-// String KdRuangan = request.getHeader(Constants.HttpHeader.KD_RUANGAN) == null ? "0"
-// : request.getHeader(Constants.HttpHeader.KD_RUANGAN);
-
try {
jdbcTemplateObject
.update("INSERT INTO modulaplikasi_s (id, kdprofile, statusenabled, norec, kdmodulaplikasi, modulaplikasi) "
+ "VALUES (0, 0, true, '0000', '0', 'Belum Pilih Modul')");
-
jdbcTemplateObject.update("UPDATE modulaplikasi_s SET kdprofile = 0 WHERE id = 0");
} catch (Throwable t) {
+ LOGGER.error(t.getMessage());
}
try{
jdbcTemplateObject.update("UPDATE modulaplikasi_s SET kdprofile = 0 WHERE id = 0");
}catch(Throwable t){
-
+ LOGGER.error(t.getMessage());
}
try {
@@ -144,12 +128,13 @@ public class LoggingSystemAsynchronous {
.update("INSERT INTO modulaplikasi_m (id, kdprofile, statusenabled, norec, kdmodulaplikasi, modulaplikasi) "
+ "VALUES (0, 0, true, '0000', '0', 'Belum Pilih Modul')");
} catch (Throwable t) {
+ LOGGER.error(t.getMessage());
}
try{
jdbcTemplateObject.update("UPDATE modulaplikasi_m SET kdprofile = 0 WHERE id = 0");
}catch(Throwable t){
-
+ LOGGER.error(t.getMessage());
}
try {
@@ -158,75 +143,56 @@ public class LoggingSystemAsynchronous {
.update("INSERT INTO ruangan_m (id, kdprofile, statusenabled, norec, kdruangan, namaruangan, qruangan) "
+ "VALUES (0, 0, true, '0000', '0', 'Belum Pilih Ruangan', 0)");
} catch (Throwable t) {
+ LOGGER.error(t.getMessage());
}
try{
jdbcTemplateObject.update("UPDATE ruangan_m SET kdprofile = 0 WHERE id = 0");
}catch(Throwable t){
-
+ LOGGER.error(t.getMessage());
}
try {
jdbcTemplateObject.update(SQL, 0, "0", "", uuid, "", UserName, idPegawai, modulaplikasiId, host,
ruanganId, (signin)?new Date():null, (signin)?null:new Date());
} 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,
String[] propertyNames, Type[] types) {
-
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
+ if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
return;
- }
-
String currentPrincipalName = authentication.getName();
- if ("anonymousUser".equals(currentPrincipalName)) {
+ if ("anonymousUser".equals(currentPrincipalName))
return;
- }
-
synchronized (o) {
this.entity = entity;
-
Holder h = new Holder();
h.userName = currentPrincipalName;
-
h.entity = entity;
h.id = id;
h.currentState = currentState;
h.previousState = previousState;
h.propertyNames = propertyNames;
h.types = types;
-
commit.put(h.entity.getClass().getName() + "." + currentPrincipalName, h);
}
}
public void insertData(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
-
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
+ if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
return;
- }
-
String currentPrincipalName = authentication.getName();
- if ("anonymousUser".equals(currentPrincipalName)) {
+ if ("anonymousUser".equals(currentPrincipalName))
return;
- }
-
synchronized (o) {
this.entity = entity;
-
Holder h = new Holder();
h.userName = currentPrincipalName;
-
h.entity = entity;
h.id = id;
h.state = state;
@@ -234,30 +200,22 @@ public class LoggingSystemAsynchronous {
h.types = types;
h.previousState = new Object[state.length];
h.currentState = state;
-
commit.put(h.entity.getClass().getName() + "." + currentPrincipalName, h);
-
}
}
public void deleteData(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
+ if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
return;
- }
-
String currentPrincipalName = authentication.getName();
- if ("anonymousUser".equals(currentPrincipalName)) {
+ if ("anonymousUser".equals(currentPrincipalName))
return;
- }
-
synchronized (o) {
this.entity = entity;
-
Holder h = new Holder();
h.userName = currentPrincipalName;
-
h.entity = entity;
h.id = id;
h.state = state;
@@ -265,26 +223,18 @@ public class LoggingSystemAsynchronous {
h.types = types;
h.previousState = state;
h.currentState = new Object[state.length];
-
commit.put(h.entity.getClass().getName() + "." + currentPrincipalName, h);
-
}
-
}
public void saveOperationLog(String sql) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
+ if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
return;
- }
-
String currentPrincipalName = authentication.getName();
- if ("anonymousUser".equals(currentPrincipalName)) {
+ if ("anonymousUser".equals(currentPrincipalName))
return;
- }
-
JdbcTemplate jdbcTemplateObject = new JdbcTemplate(dataSource);
-
asynchMethodtoCreatedLog(sql, currentPrincipalName, jdbcTemplateObject, request);
}
@@ -292,7 +242,7 @@ public class LoggingSystemAsynchronous {
try{
jObject.put(key, value);
}catch(Exception e){
-
+ LOGGER.error(e.getMessage());
}
}
@@ -300,7 +250,7 @@ public class LoggingSystemAsynchronous {
try{
jObject.put(key, value);
}catch(Exception e){
-
+ LOGGER.error(e.getMessage());
}
}
@@ -308,7 +258,7 @@ public class LoggingSystemAsynchronous {
try{
jObject.put(key, value);
}catch(Exception e){
-
+ LOGGER.error(e.getMessage());
}
}
@@ -316,34 +266,25 @@ public class LoggingSystemAsynchronous {
try{
jArray.put(value);
}catch(Exception e){
-
+ LOGGER.error(e.getMessage());
}
}
@Async
public void asynchMethodtoCreatedLog(String sql, String UserName, JdbcTemplate jdbcTemplateObject,
HttpServletRequest request) {
-
if (entity != null) {
Holder h = commit.get(entity.getClass().getName() + "." + UserName);
destroy();
if (h != null) {
String method = "X";
String object = "";
-
StringBuilder infoBuilder = new StringBuilder();
StringBuilder jSonObject = new StringBuilder();
-
JSONObject jObject = new JSONObject();
-
-
jSonObject.append("{\n");
-
String host = request.getRemoteHost();
-
-
String infoOperasi = "Pengambilan";
-
if (sql.toUpperCase().contains("INSERT ")) {
method = "I";
infoBuilder.append("INSERT METOD").append("\n");
@@ -363,88 +304,58 @@ public class LoggingSystemAsynchronous {
putStringToJSONObject(jObject, "m", "D");
infoOperasi = "Penghapusan data";
}
-
- // String AlamatUrlForm =
- // 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;
-
+ boolean isSupervising = (request.getHeader(SUPERVISING) != null)
+ && ("true".equals(request.getHeader(SUPERVISING)));
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;
-
if (isSupervising) {
try {
String Username = request.getHeader(Constants.HttpHeader.KD_USER) == null ? ""
: request.getHeader(Constants.HttpHeader.KD_USER);
kdHistoryLogin = jdbcTemplateObject.queryForObject(SQL, new Object[] { Username },
Integer.class);
-
-
- infoBuilder.append(infoOperasi + " oleh '" + Username + "'").append("\n");
- infoBuilder.append("Supervisor " + UserName).append("\n");
-
- jSonObject.append("'user':'" + Username + "',\n");
- jSonObject.append("'supervisor':'" + UserName + "',\n");
-
+ infoBuilder.append(infoOperasi).append(" oleh '").append(Username).append("'").append("\n");
+ infoBuilder.append("Supervisor ").append(UserName).append("\n");
+ jSonObject.append("'user':'").append(Username).append("',\n");
+ jSonObject.append("'supervisor':'").append(UserName).append("',\n");
putStringToJSONObject(jObject, "user", Username);
putStringToJSONObject(jObject, "supervisor", UserName);
-
} catch (Throwable t) {
-
+ LOGGER.error(t.getMessage());
}
} else {
try {
-
kdHistoryLogin = jdbcTemplateObject.queryForObject(SQL, new Object[] { UserName },
Integer.class);
- infoBuilder.append(infoOperasi + " oleh '" + UserName + "'").append("\n");
- jSonObject.append("'user':'" + UserName + "',\n");
+ infoBuilder.append(infoOperasi).append(" oleh '").append(UserName).append("'").append("\n");
+ jSonObject.append("'user':'").append(UserName).append("',\n");
jSonObject.append("'supervisor':'-',\n");
-
putStringToJSONObject(jObject, "user", UserName);
-
} catch (Throwable t) {
-
+ LOGGER.error(t.getMessage());
}
}
-
Table table = h.entity.getClass().getAnnotation(Table.class);
-
- if ("ActivityPegawai".equals(h.entity.getClass().getSimpleName())) {
+ if ("ActivityPegawai".equals(h.entity.getClass().getSimpleName()))
return;
- }
-
String className = h.entity.getClass().getName();
object = className;
-
- infoBuilder.append("Di class '" + className);
- infoBuilder.append("' atau entity '" + h.entity.getClass().getSimpleName());
- infoBuilder.append("' pada table '" + table.name() + "'.").append("\n");
+ infoBuilder.append("Di class '").append(className);
+ infoBuilder.append("' atau entity '").append(h.entity.getClass().getSimpleName());
+ infoBuilder.append("' pada table '").append(table.name()).append("'.").append("\n");
infoBuilder.append("Yang berubah : ").append("\n");
-
- jSonObject.append("'class':'" + className + "', \n");
- jSonObject.append("'entity':'" + h.entity.getClass().getSimpleName() + "', \n");
- jSonObject.append("'table':'" + table.name() + "', \n");
-
+ jSonObject.append("'class':'").append(className).append("', \n");
+ jSonObject.append("'entity':'").append(h.entity.getClass().getSimpleName()).append("', \n");
+ jSonObject.append("'table':'").append(table.name()).append("', \n");
putStringToJSONObject(jObject, "class", className);
putStringToJSONObject(jObject, "entity", h.entity.getClass().getSimpleName());
putStringToJSONObject(jObject, "table", table.name());
-
String noRecP = "";
int idP = 0;
JSONArray jArray = new JSONArray();
-
jSonObject.append("'property' : [");
-
putJSONArrayToJSONObject(jObject,"property", jArray);
-
for (int i = 0; i < h.propertyNames.length; i++) {
-
if ("norec".equalsIgnoreCase(h.propertyNames[i].trim())) {
if (h.previousState[i] != null) {
noRecP = String.valueOf(h.previousState[i]);
@@ -454,7 +365,6 @@ public class LoggingSystemAsynchronous {
noRecP = "null";
}
}
-
if ("id".equalsIgnoreCase(h.propertyNames[i].trim())) {
if (h.previousState[i] != null) {
idP = (Integer) h.previousState[i];
@@ -464,10 +374,9 @@ public class LoggingSystemAsynchronous {
idP = 0;
}
}
-
if (h.previousState.length > i && h.currentState.length > i) {
String columName = "";
- Class extends Object> cl = h.entity.getClass();
+ Class> cl = h.entity.getClass();
for (;;) {
try {
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]);
break;
}
-
- if (addObject){
+ if (addObject)
putJSONObjectToJSONArray(jArray, pObject);
- }
}
}
jSonObject.append("{}],\n");
jSonObject.append("'id' : '").append(idP).append("',\n");
-
putIntToJSONObject(jObject, "id", idP);
-
jSonObject.append("'noRecP' : '").append(noRecP).append("'");
putStringToJSONObject(jObject, "noRecP", noRecP);
-
- infoBuilder.append("Dengan id : " + idP + " dan noRecP : " + noRecP);
- infoBuilder.append(" dari host : " + host + ".").append("\n");
-
+ infoBuilder.append("Dengan id : ").append(idP).append(" dan noRecP : ").append(noRecP);
+ infoBuilder.append(" dari host : ").append(host).append(".").append("\n");
jSonObject.append("\n}\n");
-
-
h.host = host;
h.detilCrud = infoBuilder.toString();
h.noRecP = noRecP;
@@ -521,42 +422,31 @@ public class LoggingSystemAsynchronous {
h.method = method;
h.object = object;
h.kdHistoryLogin = kdHistoryLogin;
-
commit.put(className, h);
}
}
}
- public void save(Iterator entities) {
+ public void save(Iterator> entities) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- if (authentication == null || (authentication instanceof AnonymousAuthenticationToken)) {
+ if (authentication == null || (authentication instanceof AnonymousAuthenticationToken))
return;
- }
-
String currentPrincipalName = authentication.getName();
- if ("anonymousUser".equals(currentPrincipalName)) {
+ if ("anonymousUser".equals(currentPrincipalName))
return;
- }
-
JdbcTemplate jdbcTemplateObject = new JdbcTemplate(dataSource);
AsynchMethodSave(entities, jdbcTemplateObject, currentPrincipalName);
}
@Async
- public void AsynchMethodSave(Iterator entities, JdbcTemplate jdbcTemplateObject, String currentPrincipalName) {
+ public void AsynchMethodSave(Iterator> entities, JdbcTemplate jdbcTemplateObject, String currentPrincipalName) {
while (entities.hasNext()) {
String keyName = entities.next().getClass().getName() + "." + currentPrincipalName;
Holder h = commit.get(keyName);
-
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);
commit.put(keyName, null);
}
-
}
}
@@ -567,24 +457,16 @@ public class LoggingSystemAsynchronous {
+ "NoRecord, TglCrudIn, TglCrudOut) " + "VALUES "
+ "( nextval('historyloginuser_m_id_seq'), ?, true, ?, ?," + "?, ?, " + "?, " + "?, ?, ?, "
+ "?, ?, ?)";
-
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
-
try {
jdbcTemplateObject.update(SQL, 0, "0", "", uuid, "",
jSonObject.replaceAll("\n", "").replaceAll("\t", ""), kdHistoryLogin, method,
object, NoRecP, crudIn, new Date());
} catch (Throwable t) {
-// try{
-// LOGGER.warn("operasi 'LogData' gagal di log karena " + t.getMessage());
-// }catch(Exception e){
-//
-// }
+ LOGGER.error(t.getMessage());
}
}
- ////// private method
-
private void destroy() {
synchronized (o) {
this.entity = null;
@@ -593,50 +475,40 @@ public class LoggingSystemAsynchronous {
private boolean showObj(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
Object prev, Object curr) {
-
jSonObject.append("{\n");
- jSonObject.append("\t'name' : '" + property + "', \n");
- jSonObject.append("\t'column' : '" + columName + "', \n");
- jSonObject.append("\t'oldData' : '" + prev + "', \n");
- jSonObject.append("\t'newData' : '" + curr + "', \n");
+ jSonObject.append("\t'name' : '").append(property).append("', \n");
+ jSonObject.append("\t'column' : '").append(columName).append("', \n");
+ jSonObject.append("\t'oldData' : '").append(prev).append("', \n");
+ jSonObject.append("\t'newData' : '").append(curr).append("', \n");
jSonObject.append("},\n");
-
putStringToJSONObject(pObject, "name", property);
putStringToJSONObject(pObject, "column", columName);
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
-
- infoBuilder.append(property + " : Sebelumnya " + prev + " menjadi " + curr).append("\n");
-
+ infoBuilder.append(property).append(" : Sebelumnya ").append(prev).append(" menjadi ").append(curr).append("\n");
return true;
}
private boolean showDate(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
Date prev, Date curr) {
-
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("\t'name' : '" + property + "', \n");
- jSonObject.append("\t'column' : '" + columName + "', \n");
- jSonObject.append("\t'oldData' : '" + prev + "', \n");
- jSonObject.append("\t'newData' : '" + curr + "', \n");
+ jSonObject.append("\t'name' : '").append(property).append("', \n");
+ jSonObject.append("\t'column' : '").append(columName).append("', \n");
+ jSonObject.append("\t'oldData' : '").append(prev).append("', \n");
+ jSonObject.append("\t'newData' : '").append(curr).append("', \n");
jSonObject.append("},\n");
-
putStringToJSONObject(pObject, "name", property);
putStringToJSONObject(pObject, "column", columName);
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
-
return true;
}
-
return false;
}
private int whoIsNull(Object o1, Object o2) {
-
if (o1 == null && o2 == null) {
return 3;
} else if (o1 == null) {
@@ -646,106 +518,84 @@ public class LoggingSystemAsynchronous {
} else {
return 0;
}
-
}
private boolean showPrevNotNull(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
Object prev) {
if (!property.endsWith("Id")) {
jSonObject.append("{\n");
- jSonObject.append("\t'name' : '" + property + "', \n");
- jSonObject.append("\t'column' : '" + columName + "', \n");
- jSonObject.append("\t'oldData' : '" + prev + "', \n");
+ jSonObject.append("\t'name' : '").append(property).append("', \n");
+ jSonObject.append("\t'column' : '").append(columName).append("', \n");
+ jSonObject.append("\t'oldData' : '").append(prev).append("', \n");
jSonObject.append("\t'newData' : 'null', \n");
jSonObject.append("},\n");
-
putStringToJSONObject(pObject, "name", property);
putStringToJSONObject(pObject, "column", columName);
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
putStringToJSONObject(pObject, "newData", "null");
-
- infoBuilder.append("Property : " + property + ", column name : " + columName + ", Sebelumnya " + prev
- + " menjadi null ").append("\n");
-
+ infoBuilder.append("Property : ").append(property).append(", column name : ").append(columName).append(", Sebelumnya ").append(prev).append(" menjadi null ").append("\n");
return true;
}
-
return false;
}
private boolean showCurNotNull(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
Object curr) {
jSonObject.append("{\n");
- jSonObject.append("\t'name' : '" + property + "', \n");
- jSonObject.append("\t'column' : '" + columName + "', \n");
+ jSonObject.append("\t'name' : '").append(property).append("', \n");
+ jSonObject.append("\t'column' : '").append(columName).append("', \n");
jSonObject.append("\t'oldData' : 'null', \n");
- jSonObject.append("\t'newData' : '" + curr + "', \n");
+ jSonObject.append("\t'newData' : '").append(curr).append("', \n");
jSonObject.append("},\n");
-
putStringToJSONObject(pObject, "name", property);
putStringToJSONObject(pObject, "column", columName);
putStringToJSONObject(pObject, "oldData", "null");
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
-
- infoBuilder.append("Property : " + property + ", column name " + columName + ", Sebelumnya null menjadi " + curr)
+ infoBuilder.append("Property : ").append(property).append(", column name ").append(columName).append(", Sebelumnya null menjadi ").append(curr)
.append("\n");
-
return true;
}
private boolean showNotAllNull(JSONObject pObject, StringBuilder infoBuilder, StringBuilder jSonObject, String columName, String property,
Object prev, Object curr) {
-
if (prev instanceof String || curr instanceof Character) {
if (!(String.valueOf(prev)).equals(String.valueOf(curr))) {
jSonObject.append("{\n");
- jSonObject.append("\t'name' : '" + property + "', \n");
- jSonObject.append("\t'column' : '" + columName + "', \n");
- jSonObject.append("\t'oldData' : '" + prev + "', \n");
- jSonObject.append("\t'newData' : '" + curr + "', \n");
+ jSonObject.append("\t'name' : '").append(property).append("', \n");
+ jSonObject.append("\t'column' : '").append(columName).append("', \n");
+ jSonObject.append("\t'oldData' : '").append(prev).append("', \n");
+ jSonObject.append("\t'newData' : '").append(curr).append("', \n");
jSonObject.append("},\n");
-
putStringToJSONObject(pObject, "name", property);
putStringToJSONObject(pObject, "column", columName);
putStringToJSONObject(pObject, "oldData", String.valueOf(prev));
putStringToJSONObject(pObject, "newData", String.valueOf(curr));
-
- infoBuilder.append("Property : " + property + ", column name " + columName + ", Sebelumnya " + prev
- + " menjadi " + curr).append("\n");
-
+ infoBuilder.append("Property : ").append(property).append(", column name ").append(columName).append(", Sebelumnya ").append(prev).append(" menjadi ").append(curr).append("\n");
return true;
}
} else {
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);
- }
} 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);
- }
} 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);
- }
} 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);
- }
} 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);
- }
} 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);
- }
- } else if (prev instanceof Date || curr instanceof Date) {
- return showDate(pObject, infoBuilder, jSonObject, columName, property, (Date) prev, (Date) curr);
+ } else if (prev instanceof Date && curr instanceof Date) {
+ return showDate(pObject, infoBuilder, jSonObject, columName, property, (Date) prev, (Date) curr);
}
-
}
-
return false;
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/holder/HibernateInterceptorBeansHolder.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/holder/HibernateInterceptorBeansHolder.java
index bd203438..118c8548 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/holder/HibernateInterceptorBeansHolder.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/holder/HibernateInterceptorBeansHolder.java
@@ -9,7 +9,6 @@ import com.jasamedika.medifirst2000.logging.hibernate.async.LoggingSystemAsynchr
*
* @author Syamsu
*/
-
@Component
public class HibernateInterceptorBeansHolder {
@@ -18,6 +17,5 @@ public class HibernateInterceptorBeansHolder {
@Autowired
public void setLoggingSystemAsynchronous(LoggingSystemAsynchronous logging) {
HibernateInterceptorBeansHolder.loggingSystemAsynchronous = logging;
- }
-
+ }
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/interceptor/HibernateInterceptor.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/interceptor/HibernateInterceptor.java
index af96d92e..f52fa3ee 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/interceptor/HibernateInterceptor.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/logging/hibernate/interceptor/HibernateInterceptor.java
@@ -12,6 +12,7 @@ import java.io.Serializable;
* @author Syamsu
*/
public class HibernateInterceptor extends EmptyInterceptor {
+
private static final long serialVersionUID = 5478574918838397131L;
@Override
@@ -42,14 +43,4 @@ public class HibernateInterceptor extends EmptyInterceptor {
HibernateInterceptorBeansHolder.loggingSystemAsynchronous.saveOperationLog(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);
- // }
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/MessagePublisher.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/MessagePublisher.java
index 0e83a495..8b3e1bc1 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/MessagePublisher.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/MessagePublisher.java
@@ -1,27 +1,27 @@
package com.jasamedika.medifirst2000.notification;
-import java.util.List;
-import java.util.Map;
-
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
+import java.util.List;
+import java.util.Map;
-public interface MessagePublisher {
- public String GetSettingDataFixed(String prefix);
- public void sendDirectNotification(final Map data);
-
- public RabbitHole getRabbitHole();
-
- public static interface RabbitHole {
- public void connect(String host, String userName, String password, String routingKeyAndQueueName) throws Exception;
- public void sendRabbitMQNotification(String pesan) throws Exception;
- public void close() throws Exception;
- public void sendNotif(MessagePublisher.RabbitHole rabbitHole, Ruangan dariRuangan, Pegawai pegawai,
- NotifikasiMessageObjekModulService notifikasiMessageObjekModulService,
- Integer notifMessagingId, List ruanganTujuansId) throws Exception;
+public interface MessagePublisher {
+
+ interface RabbitHole {
+ void connect(String host, String userName, String password, String routingKeyAndQueueName) throws Exception;
+ void sendRabbitMQNotification(String pesan) throws Exception;
+ void close() throws Exception;
+ void sendNotif(MessagePublisher.RabbitHole rabbitHole, Ruangan dariRuangan, Pegawai pegawai,
+ NotifikasiMessageObjekModulService notifikasiMessageObjekModulService,
+ Integer notifMessagingId, List ruanganTujuansId) throws Exception;
}
-
+
+ RabbitHole getRabbitHole();
+
+ String getSettingDataFixed(String prefix);
+
+ void sendDirectNotification(final Map data);
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/MessageSubscriber.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/MessageSubscriber.java
index e2191a46..fe06d706 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/MessageSubscriber.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/MessageSubscriber.java
@@ -3,8 +3,9 @@ package com.jasamedika.medifirst2000.notification;
import com.rabbitmq.client.Consumer;
public interface MessageSubscriber {
- public void startRabbitMQNotification(String host, String routingKeyAndQueueName) throws Exception;
- public void listenRabbitMQNotification(String routingKeyAndQueueName, Consumer consumer, boolean autoAck) throws Exception;
- public void stopRabbitMQNotification() throws Exception;
- public Consumer getDefaultConsumer();
+
+ void startRabbitMQNotification(String host, String routingKeyAndQueueName) throws Exception;
+ void listenRabbitMQNotification(String routingKeyAndQueueName, Consumer consumer, boolean autoAck) throws Exception;
+ void stopRabbitMQNotification() throws Exception;
+ Consumer getDefaultConsumer();
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/RabbitMQConfiguration.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/RabbitMQConfiguration.java
deleted file mode 100644
index a64f5506..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/RabbitMQConfiguration.java
+++ /dev/null
@@ -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);
-// }
-}
-
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/antrian/BackEndAntrian.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/antrian/BackEndAntrian.java
deleted file mode 100644
index b4a45870..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/antrian/BackEndAntrian.java
+++ /dev/null
@@ -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 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) {
-// }
-// }
-}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/antrian/InfoTambahanAntrian.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/antrian/InfoTambahanAntrian.java
deleted file mode 100644
index ed78955b..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/antrian/InfoTambahanAntrian.java
+++ /dev/null
@@ -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);
- }
- }
-}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/impl/MessagePublisherImpl.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/impl/MessagePublisherImpl.java
index 00b1fad3..a933f003 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/impl/MessagePublisherImpl.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/impl/MessagePublisherImpl.java
@@ -4,6 +4,7 @@ import com.google.gson.Gson;
import com.jasamedika.medifirst2000.base.vo.BaseMasterVO;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Ruangan;
+import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.notification.MessagePublisher;
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
import com.jasamedika.medifirst2000.util.CommonUtil;
@@ -11,48 +12,39 @@ import com.jasamedika.medifirst2000.vo.*;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
-import com.rabbitmq.client.MessageProperties;
import io.socket.client.IO;
+import io.socket.client.Socket;
import org.json.JSONException;
import org.json.JSONObject;
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.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
-import javax.sql.DataSource;
import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
+
+import static com.rabbitmq.client.MessageProperties.PERSISTENT_TEXT_PLAIN;
+import static org.slf4j.LoggerFactory.getLogger;
+import static org.springframework.beans.BeanUtils.copyProperties;
@Component("messagePublisher")
public class MessagePublisherImpl implements MessagePublisher {
- 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
protected EntityManager em;
- @Autowired
- DataSource dataSource;
-
@Override
- @Transactional(readOnly = false)
- public String GetSettingDataFixed(String prefix) {
+ @Transactional
+ public String getSettingDataFixed(String prefix) {
try{
- StringBuffer buffer = new StringBuffer();
- buffer.append("select model.nilaiField from SettingDataFixed ")
- .append(" model where model.namaField ='" + prefix + "' ");
- Query query = em.createQuery(buffer.toString());
-
+ Query query = em.createQuery("select model.nilaiField from SettingDataFixed " + " model where model.namaField ='" + prefix + "' ");
return (String) query.getSingleResult();
}catch(Exception e){
return "127.0.0.1";
@@ -61,43 +53,37 @@ public class MessagePublisherImpl implements MessagePublisher {
@Override
public void sendDirectNotification(final Map data) {
-
try {
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
- public void call(Object... args) {
-
- 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.emit("subscribe", item);
+ } catch (JSONException e) {
+ LOGGER.error(e.getMessage());
+ }
+ });
socket.connect();
} else {
try {
Gson gson = new Gson();
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.disconnect();
} catch (JSONException e) {
+ LOGGER.error(e.getMessage());
}
-
}
-
} catch (URISyntaxException e) {
- e.printStackTrace();
+ throw new ServiceVOException(e.getMessage());
}
}
@@ -106,14 +92,11 @@ public class MessagePublisherImpl implements MessagePublisher {
Channel channel;
String routingKeyAndQueueName;
Gson gson;
- //String urlSocket;
String host;
public DefaultRabbitHole(String host){
this.gson = new Gson();
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 {
@@ -128,7 +111,7 @@ public class MessagePublisherImpl implements MessagePublisher {
}
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 {
@@ -139,19 +122,14 @@ public class MessagePublisherImpl implements MessagePublisher {
public void sendNotif(MessagePublisher.RabbitHole rabbitHole, Ruangan dariRuangan, Pegawai pegawai,
NotifikasiMessageObjekModulService notifikasiMessageObjekModulService,
Integer notifMessagingId, List ruanganTujuansId) throws Exception {
-
List notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService
.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
-
- if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
+ if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs))
return;
- }
-
Integer ruanganTujuanIdtemp = 0;
boolean connect = false;
RuanganVO dariRuanganVO = convertToVO(new RuanganVO(),dariRuangan);
PegawaiVO pegawaiVO = convertToVO(new PegawaiVO(),pegawai);
-
for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs) {
RuanganVO ruanganTujuan = vo.getRuangan();
ModulAplikasiVO modulAplikasi = vo.getModulAplikasi();
@@ -160,23 +138,17 @@ public class MessagePublisherImpl implements MessagePublisher {
String titleNotifikasi = vo.getTitleNotifikasi();
String pesanNotifikasi = vo.getPesanNotifikasi();
String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
-
- if (ruanganTujuan.getId() == dariRuanganVO.getId()) {
+ if (Objects.equals(ruanganTujuan.getId(), dariRuanganVO.getId()))
continue;
- }
-
- if (ruanganTujuanIdtemp != ruanganTujuan.getId()) {
- if (connect) {
+ if (!Objects.equals(ruanganTujuanIdtemp, ruanganTujuan.getId())) {
+ if (connect)
rabbitHole.close();
- }
rabbitHole.connect(host, "rsab", "rsab", String.valueOf(ruanganTujuan.getId()));
connect = true;
ruanganTujuanIdtemp = ruanganTujuan.getId();
}
-
ModulAplikasiVO modulAplikasiVO = convertToVO(new ModulAplikasiVO(), modulAplikasi);
ObjekModulAplikasiVO objekModulAplikasiVO = convertToVO(new ObjekModulAplikasiVO(), objekModulAplikasi);
-
Map map = new HashMap<>();
map.put("rec", UUID.randomUUID());
map.put("title", titleNotifikasi);
@@ -190,39 +162,20 @@ public class MessagePublisherImpl implements MessagePublisher {
map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
map.put("fromPegawai", pegawaiVO);
map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
-
rabbitHole.sendRabbitMQNotification(gson.toJson(map));
}
- if (connect) {
+ if (connect)
rabbitHole.close();
- }
-
}
T convertToVO(T target, Object source){
- BeanUtils.copyProperties(source, target);
+ copyProperties(source, target);
return target;
}
-
}
@Override
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();
- // }
-
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/impl/MessageSubscriberImpl.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/impl/MessageSubscriberImpl.java
index 800ea181..f037ae31 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/impl/MessageSubscriberImpl.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/notification/impl/MessageSubscriberImpl.java
@@ -1,35 +1,24 @@
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 javax.sql.DataSource;
-
-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;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.slf4j.LoggerFactory.getLogger;
@Component("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;
Connection connection;
AMQP.Queue.DeclareOk Queue;
- @Autowired
- DataSource dataSource;
-
public void startRabbitMQNotification(String host, String routingKeyAndQueueName) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost(host);
@@ -40,10 +29,8 @@ public class MessageSubscriberImpl implements MessageSubscriber {
public void listenRabbitMQNotification(String routingKeyAndQueueName, Consumer consumer, boolean autoAck)
throws Exception {
- for (int i = 0; i < Queue.getMessageCount(); i++) {
+ for (int i = 0; i < Queue.getMessageCount(); i++)
channel.basicConsume(routingKeyAndQueueName, autoAck, consumer);
- }
-
}
public void stopRabbitMQNotification() throws Exception {
@@ -57,7 +44,7 @@ public class MessageSubscriberImpl implements MessageSubscriber {
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
byte[] body) throws IOException {
- LOGGER.info(new String(body, "UTF-8"));
+ LOGGER.info(new String(body, UTF_8));
getChannel().basicAck(envelope.getDeliveryTag(), false);
}
};
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Comparison.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Comparison.java
index 3efe2668..c58fc054 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Comparison.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Comparison.java
@@ -1,20 +1,12 @@
package com.jasamedika.medifirst2000.paging;
public enum Comparison {
- // equal
- eq,
- // greaterThan
- gt,
- // lowerThan
- lt,
- // not equal
- ne,
- // is null
- isnull,
-
- in,
-
- inn,
-
- lk
+ EQ, // equal
+ GT, // greaterThan
+ LT, // lowerThan
+ NE, // not equal
+ IS_NULL, // is null
+ IN,
+ INN,
+ LK
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Condition.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Condition.java
index 8c8cbf1f..2766e1eb 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Condition.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Condition.java
@@ -1,53 +1,21 @@
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 Type type;
- public Comparison comparison;
+ private Type type;
- public Object value;
+ private Comparison comparison;
- public String field;
+ private Object value;
- public Condition() {
- }
-
- 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);
- }
- }
+ private String field;
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Filter.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Filter.java
index 81ecd4aa..f197f1fa 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Filter.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Filter.java
@@ -9,30 +9,12 @@ import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
-
-/**
- * [{
- * "type": "string",
- * "value": "***",
- * "field": "model"
- * },{
- * "type": "numeric",
- * "value": "***",
- * "field": "year",
- * "comparison": "gt"
- * }]
- */
public class Filter implements Specification {
- List conditions;
-
- public Filter(String json) {
-// ObjectMapper mapper = new ObjectMapper();
-// this.conditions = mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, Condition.class));
- }
+ private final List conditions;
public Filter() {
- conditions = new ArrayList<>();
+ this.conditions = new ArrayList<>();
}
public void addCondition(Condition condition) {
@@ -41,47 +23,39 @@ public class Filter implements Specification {
@Override
public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
- List predicates = buildPredicates(root, criteriaQuery, criteriaBuilder);
+ List predicates = buildPredicates(root, criteriaBuilder);
return predicates.size() > 1
- ? criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]))
+ ? criteriaBuilder.and(predicates.toArray(new Predicate[0]))
: predicates.get(0);
}
- private List buildPredicates(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
-// return conditions.stream().map(this::buildPredicate).collect(toList());
+ private List buildPredicates(Root> root, CriteriaBuilder criteriaBuilder) {
List predicates = new ArrayList<>();
for(Condition c:conditions){
- predicates.add(buildPredicate(c, root, criteriaQuery, criteriaBuilder));
+ predicates.add(buildPredicate(c, root, criteriaBuilder));
}
-
return predicates;
}
- public Predicate buildPredicate(Condition condition, Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
- switch (condition.comparison) {
- case eq:
- return buildEqualsPredicateToCriteria(condition, root, criteriaQuery, criteriaBuilder);
- case gt:
+ public Predicate buildPredicate(Condition condition, Root> root, CriteriaBuilder criteriaBuilder) {
+ switch (condition.getComparison()) {
+ case GT:
+ case LT:
+ case NE:
+ case IS_NULL:
+ case IN:
break;
- case lt:
- break;
- case ne:
- break;
- 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+"%");
+ case INN:
+ return criteriaBuilder.isNotNull(root.get(condition.getField()));
+ case LK:
+ return criteriaBuilder.like(root.get(condition.getField()), "%"+condition.getValue()+"%");
default:
- return buildEqualsPredicateToCriteria(condition, root, criteriaQuery, criteriaBuilder);
+ return buildEqualsPredicateToCriteria(condition, root, criteriaBuilder);
}
throw new RuntimeException();
}
- private Predicate buildEqualsPredicateToCriteria(Condition condition, Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
- return criteriaBuilder.equal(root.get(condition.field), condition.value);
+ private Predicate buildEqualsPredicateToCriteria(Condition condition, Root> root, CriteriaBuilder criteriaBuilder) {
+ return criteriaBuilder.equal(root.get(condition.getField()), condition.getValue());
}
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Type.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Type.java
index 261e96c2..aee8f4f5 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Type.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/paging/Type.java
@@ -1,11 +1,11 @@
package com.jasamedika.medifirst2000.paging;
public enum Type {
- numeric,
- string,
- date,
- bool,
- uuid,
- list,
- raw
+ NUMERIC,
+ STRING,
+ DATE,
+ BOOLEAN,
+ UUID,
+ LIST,
+ RAW
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/KamusIndikatorServiceImpl.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/KamusIndikatorServiceImpl.java
index 9eff4536..92a8345d 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/KamusIndikatorServiceImpl.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/KamusIndikatorServiceImpl.java
@@ -1,20 +1,5 @@
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.dao.KamusIndikatorDao;
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.util.CommonUtil;
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")
public class KamusIndikatorServiceImpl extends BaseVoServiceImpl implements KamusIndikatorService{
@@ -114,37 +113,26 @@ public class KamusIndikatorServiceImpl extends BaseVoServiceImpl implements Kamu
Specification spec) {
Direction direction=null;
List dtos = new LinkedList();
-
if(dir.equalsIgnoreCase("asc")){
direction=Sort.Direction.ASC;
}else{
direction=Sort.Direction.DESC;
}
-
Pageable pageable = new PageRequest(page, take, direction, sort);
Page resultPage = kamusIndikatorDao.findAll(spec, pageable);
List resultData = resultPage.getContent();
-
for(KamusIndikator model : resultData){
-
Filter filter = new Filter();
- if (CommonUtil.isNotNullOrEmpty(model.getId())) {
- filter.addCondition(new Condition.Builder().setComparison(Comparison.eq).setField("kamusIndikatorId")
- .setValue(model.getId()).build());
- }
- filter.addCondition(new Condition.Builder().setComparison(Comparison.inn).setField("id").build());
-
+ if (CommonUtil.isNotNullOrEmpty(model.getId()))
+ filter.addCondition(Condition.builder().comparison(Comparison.EQ).field("kamusIndikatorId").value(model.getId()).build());
+ filter.addCondition(Condition.builder().comparison(Comparison.INN).field("id").build());
Page resultPageKontrak = targetDao.findAll(filter, pageable);
List resultDataKontrak = resultPageKontrak.getContent();
-
DetailKamusIndikatorDto resultObj = new DetailKamusIndikatorDto();
-
resultObj.setKamus(model);
resultObj.setListTarget(resultDataKontrak);
-
dtos.add(resultObj);
- }
-
+ }
return constructMapReturn(dtos, resultPage.getTotalElements(), resultPage.getTotalPages());
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/MatriksIndikatorServiceImpl.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/MatriksIndikatorServiceImpl.java
index abdf8180..e22607da 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/MatriksIndikatorServiceImpl.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/MatriksIndikatorServiceImpl.java
@@ -1,10 +1,17 @@
package com.jasamedika.medifirst2000.service.impl;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
+import com.jasamedika.medifirst2000.core.web.WebConstants;
+import com.jasamedika.medifirst2000.dao.KamusIndikatorDao;
+import com.jasamedika.medifirst2000.dao.KontrakKinerjaDao;
+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.data.domain.Page;
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.stereotype.Service;
-import com.jasamedika.medifirst2000.core.web.WebConstants;
-import com.jasamedika.medifirst2000.dao.KamusIndikatorDao;
-import com.jasamedika.medifirst2000.dao.KontrakKinerjaDao;
-import com.jasamedika.medifirst2000.dao.TargetIndikatorDao;
-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;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
@Service("MatriksIndikatorService")
public class MatriksIndikatorServiceImpl implements MatriksIndikatorService{
@@ -60,12 +58,10 @@ public class MatriksIndikatorServiceImpl implements MatriksIndikatorService{
for(KamusIndikator model : resultDataIKU){
Filter filter = new Filter();
- if (CommonUtil.isNotNullOrEmpty(model.getId())) {
- filter.addCondition(new Condition.Builder().setComparison(Comparison.eq).setField("kamusIndikatorId")
- .setValue(model.getId()).build());
- }
- filter.addCondition(new Condition.Builder().setComparison(Comparison.inn).setField("id").build());
-
+ if (CommonUtil.isNotNullOrEmpty(model.getId()))
+ filter.addCondition(Condition.builder().comparison(Comparison.EQ).field("kamusIndikatorId").value(model.getId()).build());
+ filter.addCondition(Condition.builder().comparison(Comparison.INN).field("id").build());
+
Page resultPageTarget = realisasiDao.findAll(filter, pageable);
List resultDataTarget = resultPageTarget.getContent();
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/PegawaiServiceImpl.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/PegawaiServiceImpl.java
index f296c885..eb273633 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/PegawaiServiceImpl.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/PegawaiServiceImpl.java
@@ -235,15 +235,11 @@ public class PegawaiServiceImpl extends BaseVoServiceImpl implements PegawaiServ
String namaLengkap) {
try {
Filter filter = new Filter();
- if (CommonUtil.isNotNullOrEmpty(id)) {
- filter.addCondition(
- new Condition.Builder().setComparison(Comparison.eq).setField("id").setValue(id).build());
- }
- if (CommonUtil.isNotNullOrEmpty(namaLengkap)) {
- filter.addCondition(new Condition.Builder().setComparison(Comparison.eq).setField("namaLengkap")
- .setValue(namaLengkap).build());
- }
- filter.addCondition(new Condition.Builder().setComparison(Comparison.inn).setField("id").build());
+ if (CommonUtil.isNotNullOrEmpty(id))
+ filter.addCondition(Condition.builder().comparison(Comparison.EQ).field("id").value(id).build());
+ if (CommonUtil.isNotNullOrEmpty(namaLengkap))
+ filter.addCondition(Condition.builder().comparison(Comparison.EQ).field("namaLengkap").value(namaLengkap).build());
+ filter.addCondition(Condition.builder().comparison(Comparison.INN).field("id").build());
Pageable pageable = new PageRequest(page, take, Sort.Direction.ASC, sort);
Page resultPage = pegawaiDao.findAll(filter, pageable);
List pegawaiList = resultPage.getContent();
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/RuanganServiceImpl.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/RuanganServiceImpl.java
index d67ffc39..1701d941 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/RuanganServiceImpl.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/RuanganServiceImpl.java
@@ -1,22 +1,5 @@
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.dao.KamarDao;
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.JsonUtil;
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
@@ -74,16 +73,11 @@ public class RuanganServiceImpl extends BaseVoServiceImpl implements RuanganServ
String kdRuangan) {
Filter filter = new Filter();
- if (CommonUtil.isNotNullOrEmpty(nama)) {
- filter.addCondition(new Condition.Builder().setComparison(Comparison.lk).setField("namaRuangan")
- .setValue(nama).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());
+ if (CommonUtil.isNotNullOrEmpty(nama))
+ filter.addCondition(Condition.builder().comparison(Comparison.LK).field("namaRuangan").value(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());
Pageable pageable = new PageRequest(page, limit, Sort.Direction.ASC, sort);
Page resultPage = ruanganDao.findAll(filter, pageable);
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/test/CopyFilesExample.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/test/CopyFilesExample.java
deleted file mode 100644
index 5d055ef9..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/test/CopyFilesExample.java
+++ /dev/null
@@ -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();
- }
- }
-
-}
\ No newline at end of file
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/test/FindRekursif.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/test/FindRekursif.java
deleted file mode 100644
index e9c7d99f..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/test/FindRekursif.java
+++ /dev/null
@@ -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");
-
-}
-}
\ No newline at end of file
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/DateHelper.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/DateHelper.java
index 42d63445..09c82340 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/DateHelper.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/DateHelper.java
@@ -1,6 +1,7 @@
package com.jasamedika.medifirst2000.util;
public class DateHelper {
+
public static String toMonthName(String monthNumber){
String result="";
switch (monthNumber) {
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/HibernateInitialize.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/HibernateInitialize.java
index 809fc929..8a7eb4e9 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/HibernateInitialize.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/HibernateInitialize.java
@@ -1,28 +1,22 @@
package com.jasamedika.medifirst2000.util;
+import lombok.extern.slf4j.Slf4j;
import org.hibernate.Hibernate;
import org.hibernate.proxy.HibernateProxy;
+@Slf4j
public class HibernateInitialize {
- public static T initializeAndUnproxy(T entity) {
- if (entity == null) {
- throw new
- NullPointerException("Entity passed for initialization is null");
- }
- try
- {
- Hibernate.initialize(entity);
- if (entity instanceof HibernateProxy) {
- entity = (T) ((HibernateProxy) entity).getHibernateLazyInitializer()
- .getImplementation();
- }
+ public static T initializeAndUnproxy(T entity) {
+ if (entity == null)
+ throw new NullPointerException("Entity passed for initialization is null");
+ try {
+ Hibernate.initialize(entity);
+ if (entity instanceof HibernateProxy)
+ entity = (T) ((HibernateProxy) entity).getHibernateLazyInitializer().getImplementation();
+ } catch(Exception ex) {
+ log.error(ex.getMessage());
}
- catch(Exception ex)
- {
-
- }
-
return entity;
}
}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/JasyptConfig.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/JasyptConfig.java
deleted file mode 100644
index 92eb3b78..00000000
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/JasyptConfig.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/ResourceUtils.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/ResourceUtils.java
index 068d6e2b..b5d2fb21 100644
--- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/ResourceUtils.java
+++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/util/ResourceUtils.java
@@ -1,29 +1,28 @@
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.net.MalformedURLException;
import java.nio.file.Path;
import java.nio.file.Paths;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.UrlResource;
-import org.springframework.stereotype.Component;
-
/**
* @author salmanoe
* @since Jan 31, 2023
*/
@Component
public class ResourceUtils {
+
public static Resource loadFile(String fileName) throws Exception {
try {
Path filePath = Paths.get(fileName).toAbsolutePath().normalize();
Resource resource = new UrlResource(filePath.toUri());
- if (resource.exists()) {
- return resource;
- } else {
+ if (!resource.exists())
throw new FileNotFoundException("File not found " + fileName);
- }
+ return resource;
} catch (MalformedURLException e) {
throw new FileNotFoundException("File not found " + fileName);
}
diff --git a/jasamedika-business/src/main/resources/ehcache.xml b/jasamedika-business/src/main/resources/ehcache.xml
deleted file mode 100644
index a9719739..00000000
--- a/jasamedika-business/src/main/resources/ehcache.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
\ No newline at end of file