/**\r
* Copyright (C) 2007 EDIT\r
- * European Distributed Institute of Taxonomy \r
+ * European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
- * \r
+ *\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
\r
public final void setMappingFiles(final Resource[] mappingFiles) {\r
this.mappingFiles = mappingFiles;\r
- }\r
+ }\r
\r
- public final void setCustomConverters(final List<CustomConverter> customConverters) {\r
+ public final void setCustomConverters(final List<CustomConverter> customConverters) {\r
this.customConverters = customConverters;\r
- }\r
+ }\r
\r
- public final void setEventListeners(final List<DozerEventListener> eventListeners) {\r
+ public final void setEventListeners(final List<EventListener> eventListeners) {\r
this.eventListeners = eventListeners;\r
- }\r
+ }\r
\r
- public final void setFactories(final Map<String, BeanFactory> factories) {\r
+ public final void setFactories(final Map<String, BeanFactory> factories) {\r
this.factories = factories;\r
}\r
\r
// ==================================================================================================================================\r
public final Object getObject() throws Exception {\r
return this.beanMapper;\r
- }\r
- public final Class<Mapper> getObjectType() {\r
+ }\r
+\r
+ @Override\r
+ public final Class<Mapper> getObjectType() {\r
return Mapper.class;\r
- }\r
- public final boolean isSingleton() {\r
+ }\r
+\r
+ @Override\r
+ public final boolean isSingleton() {\r
return true;\r
- }\r
+ }\r
+\r
+ // ==================================================================================================================================\r
+ // interface 'InitializingBean'\r
+ // ==================================================================================================================================\r
+ @Override\r
+ public final void afterPropertiesSet() throws Exception {\r
+\r
+ DozerBeanMapperBuilder beanMapperBuilder = DozerBeanMapperBuilder.create();\r
+\r
+ final List<String> mappings = new ArrayList<>(this.mappingFiles.length);\r
+ if (this.mappingFiles != null) {\r
+ for (Resource mappingFile : this.mappingFiles) {\r
+ mappings.add(mappingFile.getURL().toString());\r
+ }\r
+ beanMapperBuilder.withMappingFiles(mappings);\r
+ }\r
\r
- // ==================================================================================================================================\r
- // interface 'InitializingBean'\r
- // ==================================================================================================================================\r
- public final void afterPropertiesSet() throws Exception {\r
- this.beanMapper = new DozerBeanMapper();\r
-\r
- if (this.mappingFiles != null) {\r
- final List<String> mappings = new ArrayList<String>(this.mappingFiles.length);\r
- for (Resource mappingFile : this.mappingFiles) {\r
- mappings.add(mappingFile.getURL().toString());\r
- }\r
- this.beanMapper.setMappingFiles(mappings);\r
- }\r
if (this.customConverters != null) {\r
- this.beanMapper.setCustomConverters(this.customConverters);\r
+ beanMapperBuilder.withCustomConverters(customConverters);\r
}\r
if (this.eventListeners != null) {\r
- this.beanMapper.setEventListeners(this.eventListeners);\r
+ beanMapperBuilder.withEventListeners(eventListeners);\r
}\r
if (this.factories != null) {\r
- this.beanMapper.setFactories(this.factories);\r
+ beanMapperBuilder.withBeanFactorys(factories);\r
}\r
- \r
+\r
if(this.customFieldMapper != null) {\r
- this.beanMapper.setCustomFieldMapper(customFieldMapper);\r
+ beanMapperBuilder.withCustomFieldMapper(customFieldMapper);\r
}\r
- \r
+\r
if(this.customConvertersWithId != null) {\r
- this.beanMapper.setCustomConvertersWithId(customConvertersWithId);\r
+ beanMapperBuilder.withCustomConvertersWithIds(customConvertersWithId);\r
}\r
- }\r
-\r
- }
+ }\r
+}
\ 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.dto.assembler.converter;
-
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
public class DateTimeConverter implements CustomConverter {
- public Object convert(Object destination, Object source, Class destClass, Class sourceClass) {
+ @Override
+ public Object convert(Object destination, Object source, Class<?> destClass, Class<?> sourceClass) {
if (source == null) {
return null;
}
Object result = null;
if (source instanceof DateTime) {
if(destClass.equals(DateTime.class)){
- result = new DateTime(((DateTime)source));
+ result = new DateTime((source));
} else if(destClass.equals(XMLGregorianCalendar.class)){
- result = dataTypeFactory().newXMLGregorianCalendar(((DateTime)source).toGregorianCalendar()); //naive approach, may mot result in correct representation of partial datetime
- }
+ result = dataTypeFactory().newXMLGregorianCalendar(((DateTime)source).toGregorianCalendar()); //naive approach, may mot result in correct representation of partial datetime
+ }
}
-
+
if(result == null){
throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
+ destination + " and " + source);
}
return result;
}
-
+
/**
* Cache the DatatypeFactory because newInstance is very expensive.
*/
private static DatatypeFactory dataTypeFactory;
-
+
/**
* Returns a new instance of DatatypeFactory, or the cached one if previously created.
*
}
return dataTypeFactory;
}
-
-}
+}
\ No newline at end of file
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
package eu.etaxonomy.cdm.remote.dto.assembler.converter;\r
\r
import java.net.URI;\r
}\r
\r
@Override\r
- public Object convert(Object existingDestinationFieldValue, Object sourceFieldValue, Class<?> destinationClass, Class<?> sourceClass) {\r
+ public Object convert(Object existingDestinationFieldValue, Object sourceFieldValue,\r
+ Class<?> destinationClass, Class<?> sourceClass) {\r
if(sourceFieldValue == null) {\r
return null;\r
}\r
}\r
return relation;\r
}\r
-\r
-}\r
+}
\ No newline at end of file
public class HibernateProxyFieldMapper implements CustomFieldMapper {
-
@Override
public boolean mapField(Object source, Object destination, Object sourceFieldValue, ClassMap classMap, FieldMap fieldMapping) {
if(sourceFieldValue instanceof CollectionProxy) {
try {
- ((CollectionProxy)sourceFieldValue).hashCode();
+ ((CollectionProxy<?,?>)sourceFieldValue).hashCode();
} catch(SessionException se) { // currently no way to tell if is initialized
return true;
}
}else {
return true;
}
-
}
-}
+}
\ No newline at end of file
}\r
}\r
\r
-\r
protected Mapper getMapper() {\r
if(mapper == null) {\r
this.setMapper(this.applicationContext.getBean("dozerMapper", Mapper.class));\r
} catch (Exception e) {\r
throw new MappingException("Converter HibernateProxyNullSafeDeepConverter used incorrectly. Arguments passed in were:"+ destination + " and " + source + " sourceClass " + sourceClass + " destClass " + destClass, e);\r
}\r
-\r
}\r
}\r
\r
throws BeansException {\r
this.applicationContext = applicationContext;\r
}\r
-}\r
+}
\ 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.
*/
public class LsidProxyConverter implements CustomConverter {
private String lsidProxyServiceUrl;
-
+
private String authorityPart;
-
+
public void setLsidProxyServiceUrl(String lsidProxyServiceUrl) {
this.lsidProxyServiceUrl = lsidProxyServiceUrl;
}
-
+
public void setAuthorityPart(String authorityPart) {
this.authorityPart = authorityPart;
}
- public Object convert(Object destination, Object source, Class destClass, Class sourceClass) {
+ @Override
+ public Object convert(Object destination, Object source, Class<?> destClass, Class<?> sourceClass) {
if (source == null || ((LSID)source).toString() == null || ((LSID)source).toString().equals("")) {
return null;
}
+ destination + " and " + source);
}
}
-
-}
+}
\ 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.
*/
public class StripTagsConverter implements CustomConverter {
- public Object convert(Object destination, Object source, Class<?> destClass, Class<?> sourceClass) {
+ @Override
+ public Object convert(Object destination, Object source, Class<?> destClass, Class<?> sourceClass) {
if (source == null) {
return null;
}
- if (source instanceof String) {
+ if (source instanceof String) {
Reader reader = new RemoveHTMLReader(new StringReader((String)source));
StringBuilder stringBuilder = new StringBuilder();
int charValue;
while ((charValue = reader.read()) != -1) {
stringBuilder.append((char)charValue);
}
+ reader.close();
} catch (IOException e) {return e.toString();}
return stringBuilder.toString();
} else {
+ destination + " and " + source);
}
}
-
-}
+}
\ No newline at end of file
//convert from DateTime -> TimePeriod
//FIXME implement
return null;
-
} else {
throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
+ existingDestinationFieldValue + " and " + source);
}
}
-
-}
+}
\ No newline at end of file
* @see com.ibm.lsid.MetadataResponse\r
*/\r
public abstract class OaiPmhResponseView extends AbstractView {\r
- \r
+\r
private Marshaller marshaller;\r
- \r
+\r
protected Mapper mapper;\r
- \r
+\r
@Autowired\r
@Qualifier("marshaller")\r
public void setMarshaller(Marshaller marshaller) {\r
this.marshaller = marshaller;\r
}\r
- \r
+\r
@Autowired\r
public void setMapper(Mapper mapper) {\r
this.mapper = mapper;\r
}\r
- \r
+\r
protected abstract void constructResponse(OAIPMH oaiPmh,Map<String,Object> model);\r
\r
@Override\r
\r
@Before\r
public void setUp() throws Exception {\r
- \r
+\r
model = new HashMap<String,Object>();\r
identifyView = new IdentifyView();\r
identifyView.setMarshaller(marshaller);\r
- \r
+\r
metaDataRecord = new CsvDemoMetaDataRecord(true, "/tmp", "");\r
config = CsvDemoExportConfigurator.NewInstance(null, null);\r
\r
demoRecord.setScientificName(taxon.getTitleCache());\r
demoRecord.setAuthorName("Author");\r
demoRecord.setDatasetName("Classification");\r
- \r
+\r
ArrayList<CsvDemoRecord> recordList = new ArrayList<CsvDemoRecord>();\r
logger.info(recordList.size());\r
recordList.add(demoRecord);\r