dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43744
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22179: Moved TranslationService dependency out of SchemaService
------------------------------------------------------------
revno: 22179
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-03-08 10:00:24 +0100
message:
Moved TranslationService dependency out of SchemaService
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryParser.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/DefaultTranslationService.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java 2016-03-08 01:51:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java 2016-03-08 09:00:24 +0000
@@ -93,6 +93,4 @@
* @return List of all available metadata schemas
*/
List<Schema> getMetadataSchemas();
-
- boolean isTranslated( Class<?> klass );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java 2016-03-07 16:43:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java 2016-03-08 09:00:24 +0000
@@ -152,4 +152,12 @@
* @return true if translations exist.
*/
boolean hasTranslations( String className );
+
+ /**
+ * Indicates whether translations exist for the given class.
+ *
+ * @param klass the class.
+ * @return true if translations exist.
+ */
+ boolean isTranslated( Class<?> klass );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryParser.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryParser.java 2016-03-08 01:51:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryParser.java 2016-03-08 09:00:24 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.schema.Property;
import org.hisp.dhis.schema.Schema;
import org.hisp.dhis.schema.SchemaService;
+import org.hisp.dhis.translation.TranslationService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Collection;
@@ -44,6 +45,9 @@
{
@Autowired
private SchemaService schemaService;
+
+ @Autowired
+ private TranslationService translationService;
@Override
public Query parse( Class<?> klass, List<String> filters ) throws QueryParserException
@@ -77,7 +81,7 @@
private Restriction getRestriction( Schema schema, String path, String operator, Object arg ) throws QueryParserException
{
// optimize if not translated
- if ( !schemaService.isTranslated( schema.getKlass() ) )
+ if ( !translationService.isTranslated( schema.getKlass() ) )
{
if ( path.startsWith( "displayName:" ) && schema.havePersistedProperty( "name" ) )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java 2016-03-08 01:51:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java 2016-03-08 09:00:24 +0000
@@ -30,14 +30,11 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import com.google.common.base.CaseFormat;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.hibernate.SessionFactory;
import org.hisp.dhis.system.util.AnnotationUtils;
import org.hisp.dhis.system.util.ReflectionUtils;
-import org.hisp.dhis.translation.TranslationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
@@ -49,8 +46,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -66,12 +61,6 @@
private Map<Class<?>, Schema> dynamicClassSchemaMap = new HashMap<>();
- private static Cache<Class<?>, Boolean> IS_TRANSLATED_CACHE = CacheBuilder.newBuilder()
- .expireAfterAccess( 15, TimeUnit.MINUTES )
- .initialCapacity( 100 )
- .maximumSize( 200 )
- .build();
-
@Autowired
private PropertyIntrospectorService propertyIntrospectorService;
@@ -81,9 +70,6 @@
@Autowired
private SessionFactory sessionFactory;
- @Autowired
- private TranslationService translationService;
-
@Override
public void onApplicationEvent( ContextRefreshedEvent contextRefreshedEvent )
{
@@ -229,20 +215,6 @@
return schemas;
}
- @Override
- public boolean isTranslated( final Class<?> klass )
- {
- try
- {
- return IS_TRANSLATED_CACHE.get( klass, () -> translationService.hasTranslations( klass.getSimpleName() ) );
- }
- catch ( ExecutionException ignored )
- {
- }
-
- return true;
- }
-
private void updateSelf( Schema schema )
{
if ( schema.haveProperty( "__self__" ) )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/DefaultTranslationService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/DefaultTranslationService.java 2016-03-07 16:43:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/DefaultTranslationService.java 2016-03-08 09:00:24 +0000
@@ -31,9 +31,14 @@
import org.hisp.dhis.system.util.LocaleUtils;
import org.springframework.transaction.annotation.Transactional;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
import java.util.Collection;
import java.util.List;
import java.util.Locale;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
/**
* @author Lars Helge Overland
@@ -43,6 +48,12 @@
public class DefaultTranslationService
implements TranslationService
{
+ private static Cache<Class<?>, Boolean> IS_TRANSLATED_CACHE = CacheBuilder.newBuilder()
+ .expireAfterAccess( 15, TimeUnit.MINUTES )
+ .initialCapacity( 100 )
+ .maximumSize( 200 )
+ .build();
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -161,4 +172,18 @@
{
return translationStore.hasTranslations( className );
}
+
+ @Override
+ public boolean isTranslated( final Class<?> klass )
+ {
+ try
+ {
+ return IS_TRANSLATED_CACHE.get( klass, () -> hasTranslations( klass.getSimpleName() ) );
+ }
+ catch ( ExecutionException ignored )
+ {
+ }
+
+ return true;
+ }
}