import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.ListIndexBase;
import java.util.Set;
import java.util.UUID;
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
List<OrderHint> orderHints, List<String> propertyPaths) {
List<Restriction<?>> allRestrictions = new ArrayList<>();
- allRestrictions.add(new Restriction<String>(param, matchmode, queryString));
+ allRestrictions.add(new Restriction<>(param, matchmode, queryString));
if(restrictions != null){
allRestrictions.addAll(restrictions);
}
MatchMode matchmode, List<Restriction<?>> restrictions) {
List<Restriction<?>> allRestrictions = new ArrayList<>();
- allRestrictions.add(new Restriction<String>(param, matchmode, queryString));
+ allRestrictions.add(new Restriction<>(param, matchmode, queryString));
if(restrictions != null){
allRestrictions.addAll(restrictions);
}
import java.util.Set;
import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.hibernate.Hibernate;
import eu.etaxonomy.cdm.model.common.CdmBase;
}
try {
- // ------ reusing snippet from JSONOnbject._fromBean()
+ // ------ reusing snippet from JSONObject._fromBean()
Class<?> type = prop.getPropertyType();
Object value = PropertyUtils.getProperty( bean, key );
"blockedBy",
"blocked",
"submitterUserName"
- );
+ );
}
@Override
// nothing to do here
return json;
}
-
-}
+}
\ No newline at end of file
@Override
public Object processArrayValue(Object object, JsonConfig jsonConfig) {
DateTime dateTime = (DateTime) object;
- return formatDateTime(object);
+ return formatDateTime(dateTime);
}
@Override
public Object processObjectValue(String key, Object object,
JsonConfig jsonConfig) {
- return formatDateTime(object);
+ return formatDateTime((DateTime)object);
}
- public Object formatDateTime(Object object) {
+ Object formatDateTime(DateTime object) {
if(object != null){
- DateTime dateTime = (DateTime) object;
+ DateTime dateTime = object;
// WARNING! null means now!
return DateTimeJSONValueProcessor.iso8601Format.print(dateTime);
} else {
/**
* Copyright (C) 2009 EDIT European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 See LICENSE.TXT at the top of this package for the full license terms.
*/
package eu.etaxonomy.cdm.remote.json.processor.value;
-import net.sf.json.JSONArray;
-import net.sf.json.JsonConfig;
-import net.sf.json.processors.JsonValueProcessor;
-
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.remote.json.processor.matcher.HibernateJSONValueProcessorMatcher;
+import net.sf.json.JSONArray;
+import net.sf.json.JsonConfig;
+import net.sf.json.processors.JsonValueProcessor;
/**
* Used in conjunction with the {@link HibernateJSONValueProcessorMatcher} to unwrap
* beans from hibernate proxies. Using this Value processor is essential for
* properly detecting @Transient annotations which are not inherited by subclasses
* like the proxies
- *
+ *
* @author a.kohlbecker
*/
public class HibernateJSONValueProcessor implements JsonValueProcessor {
-
+
public static final Logger logger = LogManager.getLogger(HibernateJSONValueProcessor.class);
-
+
// public Object processArrayValue(Object object, JsonConfig jsonConfig) {
// if(Hibernate.isInitialized(object)) {
// log.debug("Processing array value " + object);
// return JSONNull.getInstance();
// }
// }
-
- public Object processArrayValue(Object object, JsonConfig jsonConfig) {
+
+ @Override
+ public Object processArrayValue(Object object, JsonConfig jsonConfig) {
// usage of the InitializedHibernatePropertyFiler is expected !!!
// retain default processing
return JSONArray.fromObject(object,jsonConfig);
}
-
- public Object processObjectValue(String propertyName, Object object, JsonConfig jsonConfig) {
+ @Override
+ public Object processObjectValue(String propertyName, Object object, JsonConfig jsonConfig) {
// deproxy
Object target = HibernateProxyHelper.deproxy(object, Object.class);
if(logger.isDebugEnabled()){
logger.debug("deproxying object " + target);
}
return target;
-
- }
-}
+ }
+}
\ No newline at end of file
/**
* @author a.kohlbecker
* @since 23.06.2010
- *
*/
public class MapJSONValueProcessor implements JsonValueProcessor {
return JSONObject.fromObject(value, jsonConfig);
}
- /* (non-Javadoc)
- * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
- */
@Override
public Object processObjectValue(String key, Object value,
JsonConfig jsonConfig) {
return processArrayValue(value, jsonConfig);
}
-
-}
+}
\ No newline at end of file
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-
package eu.etaxonomy.cdm.remote.json.processor.value;
-import net.sf.json.JsonConfig;
-import net.sf.json.processors.JsonValueProcessor;
-
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.joda.time.Partial;
import org.joda.time.format.ISODateTimeFormat;
import eu.etaxonomy.cdm.hibernate.PartialUserType;
+import net.sf.json.JsonConfig;
+import net.sf.json.processors.JsonValueProcessor;
/**
* Partial time as four digit year, two digit month of year, and two digit day of month (yyyy-MM-dd).
+ *
* @author a.kohlbecker
* @since 20.01.2008
- * @version 1.0
*/
public class PartialJSONValueProcessor implements JsonValueProcessor {
- private static Logger logger = LogManager.getLogger(PartialJSONValueProcessor.class);
-
- /* (non-Javadoc)
- * @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
- */
- public Object processArrayValue(Object object, JsonConfig jsonConfig) {
+ private static Logger logger = LogManager.getLogger(PartialJSONValueProcessor.class);
+
+ @Override
+ public Object processArrayValue(Object object, JsonConfig jsonConfig) {
if(object == null){
return "";
}
return partial.toString(ISODateTimeFormat.date());
}
- /* (non-Javadoc)
- * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
- */
- public Object processObjectValue(String key, Object object, JsonConfig jsonConfig) {
+ @Override
+ public Object processObjectValue(String key, Object object, JsonConfig jsonConfig) {
if(object == null){
return "";
}
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 See LICENSE.TXT at the top of this package for the full license terms.
*/
-
package eu.etaxonomy.cdm.remote.json.processor.value;
import java.util.UUID;
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonValueProcessor;
}
UUID uuid = (UUID) obj;
return uuid.toString();
- };
-
-}
+ }
+}
\ No newline at end of file
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.SuppressPropertiesBeanIntrospector;
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.springframework.web.servlet.View;
import eu.etaxonomy.cdm.opt.config.DataSourceProperties;
String contextPath = null;
- if (request != null)
- {
+ if (request != null) {
contextPath = request.getContextPath();
- }
+ }
if(jsonConfig == null){
logger.error("The jsonConfig must not be null. It must be set in the applicationContext.");
boolean isCollectionType = false;
JSON jsonObj;
if (entity == null){
- jsonObj = JSONObject.fromObject("{}");
+ jsonObj = JSONObject.fromObject("{}");
} else if(Collection.class.isAssignableFrom(entity.getClass())){
isCollectionType = true;
jsonObj = JSONArray.fromObject(entity, jsonConfig);
XMLSerializer xmlSerializer = new XMLSerializer();
if(isCollectionType){
xmlSerializer.setArrayName(entity.getClass().getSimpleName());
- Class elementType = Object.class;
- Collection c = (Collection)entity;
+ Class<?> elementType = Object.class;
+ Collection<?> c = (Collection<?>)entity;
if(c.size() > 0){
elementType = c.iterator().next().getClass();
}
// render
render(entity, writer, jsonpCallback, request, response);
}
-
-
-}
+}
\ No newline at end of file
import java.util.Set;
import java.util.UUID;
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.hibernate.Hibernate;
import org.joda.time.DateTime;
import org.joda.time.Partial;
}
}
}
-
-
-
-
-
-
-}
+}
\ No newline at end of file