From ca358187f7decf53a0f31f565ad75c0e43bc9127 Mon Sep 17 00:00:00 2001 From: Andreas Kohlbecker Date: Wed, 25 May 2011 12:10:43 +0000 Subject: [PATCH] bringing the titleCache of TeamOrPersonBase back to the REST services --- .gitattributes | 1 + .../cdm/model/agent/TeamOrPersonBase.java | 27 ++++++---- .../remote/controller/AgentController.java | 49 ++++++++++++++++--- .../bean/TaxonNodeDaoBeanProcessor.java | 12 ++--- .../bean/TeamOrPersonBaseBeanProcessor.java | 44 +++++++++++++++++ .../matcher/CdmProxyBeanProcessorMatcher.java | 24 +++++---- .../cdm/remote/json/jsonConfigurations.xml | 38 +++++++------- 7 files changed, 143 insertions(+), 52 deletions(-) create mode 100644 cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TeamOrPersonBaseBeanProcessor.java diff --git a/.gitattributes b/.gitattributes index b86ebc7b6d..cf73a5dc4a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1576,6 +1576,7 @@ cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TaxonNam cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TaxonNodeBeanProcessor.java -text cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TaxonNodeDaoBeanProcessor.java -text cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TaxonRelationshipBeanProcessor.java -text +cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TeamOrPersonBaseBeanProcessor.java -text cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TermBaseBeanProcessor.java -text cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TextDataBeanProcessor.java -text cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TypeDesignationBaseBeanProcessor.java -text diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/TeamOrPersonBase.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/TeamOrPersonBase.java index baa1f5e6a4..4bdf121e5b 100644 --- a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/TeamOrPersonBase.java +++ b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/TeamOrPersonBase.java @@ -1,8 +1,8 @@ /** * 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. */ @@ -31,7 +31,7 @@ import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty; /** * The abstract class for such {@link AgentBase agents} ({@link Person persons} or {@link Team teams}) who might also be used * for authorship of {@link eu.etaxonomy.cdm.model.reference.Reference references} or of {@link eu.etaxonomy.cdm.model.name.TaxonNameBase taxon names}. - * + * * @author a.mueller * @version 1.0 * @created 17-APR-2008 @@ -56,11 +56,11 @@ public abstract class TeamOrPersonBase> extends Ag @Transient @XmlTransient protected boolean isGeneratingTitleCache = false; - + /** * Returns the identification string (nomenclatural abbreviation) used in * nomenclature for this {@link Person person} or this {@link Team team}. - * + * * @see INomenclaturalAuthor#getNomenclaturalTitle() */ @Transient @@ -72,7 +72,7 @@ public abstract class TeamOrPersonBase> extends Ag return result; } - /** + /** * @see #getNomenclaturalTitle() */ public void setNomenclaturalTitle(String nomenclaturalTitle) { @@ -83,7 +83,16 @@ public abstract class TeamOrPersonBase> extends Ag * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() */ @Override - @Transient //TODO a.kohlbecker remove?? + @Transient /* + TODO is this still needed, can't we remove this ?? + @Transient is an absolutely special case and thus leads to several + special implementations in order to harmonize this exception again + in other parts of the library: + - eu.etaxonomy.cdm.remote.controller.AgentController.doGetTitleCache() + - eu.etaxonomy.cdm.remote.json.processor.bean.TeamOrPersonBaseBeanProcessor + + [a.kohlbecker May 2011] + */ public String getTitleCache() { isGeneratingTitleCache = true; String result = super.getTitleCache(); @@ -105,6 +114,6 @@ public abstract class TeamOrPersonBase> extends Ag } return result; } - - + + } diff --git a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/AgentController.java b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/AgentController.java index 567b484721..0ce84283a1 100644 --- a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/AgentController.java +++ b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/AgentController.java @@ -1,18 +1,27 @@ // $Id$ /** * 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.controller; +import java.io.IOException; +import java.util.Map; +import java.util.UUID; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; import eu.etaxonomy.cdm.api.service.IAgentService; import eu.etaxonomy.cdm.api.service.pager.Pager; @@ -31,29 +40,29 @@ import eu.etaxonomy.cdm.model.common.Annotation; * Methods mapped at type level, inherited from super classes ({@link BaseController}): *
* URI: /{datasource-name}/agent/name/{agent-uuid} - * + * * Get the {@link AgentBase} instance identified by the {agent-uuid}. * The returned AgentBase is initialized by * the default initialization strategy: {@link #DEFAULT_INIT_STRATEGY} *
*
* URI: /{datasource-name}/agent/name/{agent-uuid}/annotation - * + * * Returns a {@link Pager} on the {@link Annotation}s for the {@link AgentBase} instance identified by the * {agent-uuid}. * The returned AgentBase instances are initialized by * the following strategy: {@link #ANNOTATION_INIT_STRATEGY} *
- * + * * @author a.kohlbecker * @date 24.03.2009 */ @Controller @RequestMapping(value = {"/agent/{uuid}"}) -public class AgentController extends AnnotatableController +public class AgentController extends BaseController { - + /* (non-Javadoc) * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService) */ @@ -63,4 +72,30 @@ public class AgentController extends AnnotatableController { + + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.remote.json.processor.bean.AbstractBeanProcessor#getIgnorePropNames() + */ + @Override + public List getIgnorePropNames() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.remote.json.processor.bean.AbstractBeanProcessor#processBeanSecondStep(java.lang.Object, net.sf.json.JSONObject, net.sf.json.JsonConfig) + */ + @Override + public JSONObject processBeanSecondStep(TeamOrPersonBase bean, JSONObject json, + JsonConfig jsonConfig) { + json.element("titleCache", bean.getTitleCache()); + return json; + } + +} diff --git a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/matcher/CdmProxyBeanProcessorMatcher.java b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/matcher/CdmProxyBeanProcessorMatcher.java index dbb45090be..b3b3e34b54 100644 --- a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/matcher/CdmProxyBeanProcessorMatcher.java +++ b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/matcher/CdmProxyBeanProcessorMatcher.java @@ -2,7 +2,7 @@ /** * 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. */ @@ -16,6 +16,7 @@ import net.sf.json.processors.JsonBeanProcessorMatcher; import org.apache.log4j.Logger; import org.hibernate.proxy.HibernateProxy; +import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; import eu.etaxonomy.cdm.model.common.TermBase; import eu.etaxonomy.cdm.model.media.Media; import eu.etaxonomy.cdm.model.name.TaxonNameBase; @@ -25,22 +26,22 @@ import eu.etaxonomy.cdm.model.taxon.Taxon; /** * can handle HibernateProxys - * + * * @author a.kohlbecker * */ public class CdmProxyBeanProcessorMatcher extends JsonBeanProcessorMatcher { public static final Logger logger = Logger.getLogger(CdmProxyBeanProcessorMatcher.class); - + /* (non-Javadoc) * @see net.sf.json.processors.JsonBeanProcessorMatcher#getMatch(java.lang.Class, java.util.Set) */ @SuppressWarnings("unchecked") @Override public Object getMatch(Class target, Set set) { - - + + if (HibernateProxy.class.isAssignableFrom(target)) { if(logger.isDebugEnabled()){ logger.debug("Found HibernateProxy object of class " + target.getClass() + " returning " + HibernateProxy.class); @@ -56,12 +57,9 @@ public class CdmProxyBeanProcessorMatcher extends JsonBeanProcessorMatcher { if (TermBase.class.isAssignableFrom(target)) { return DEFAULT.getMatch(TermBase.class, set); } -// if (NameRelationship.class.isAssignableFrom(target)) { -// return DEFAULT.getMatch(NameRelationship.class, set); -// } -// if (TaxonRelationship.class.isAssignableFrom(target)) { -// return DEFAULT.getMatch(TaxonRelationship.class, set); -// } + if (TeamOrPersonBase.class.isAssignableFrom(target)) { + return DEFAULT.getMatch(TeamOrPersonBase.class, set); + } if (Media.class.isAssignableFrom(target)) { return DEFAULT.getMatch(Media.class, set); } @@ -74,6 +72,6 @@ public class CdmProxyBeanProcessorMatcher extends JsonBeanProcessorMatcher { return DEFAULT.getMatch(target, set); } - - + + } diff --git a/cdmlib-remote/src/main/resources/eu/etaxonomy/cdm/remote/json/jsonConfigurations.xml b/cdmlib-remote/src/main/resources/eu/etaxonomy/cdm/remote/json/jsonConfigurations.xml index 4f2fc5affe..d31982625f 100644 --- a/cdmlib-remote/src/main/resources/eu/etaxonomy/cdm/remote/json/jsonConfigurations.xml +++ b/cdmlib-remote/src/main/resources/eu/etaxonomy/cdm/remote/json/jsonConfigurations.xml @@ -7,7 +7,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd "> - + @@ -19,19 +19,19 @@ TreeNode.data TreeNode.data - + PolytomousKey.root PolytomousKeyNode.children PolytomousKeyNode.question PolytomousKeyNode.statement - PolytomousKeyNode.modifyingText - + PolytomousKeyNode.modifyingText + Media.representations MediaRepresentation.parts - + - - + + TextData.feature CategoricalData.feature CommonTaxonName.feature @@ -45,9 +45,9 @@ - + + + + @@ -129,7 +133,7 @@ - + @@ -145,9 +149,9 @@ - - + @@ -224,9 +228,9 @@ - @@ -343,7 +347,7 @@ - + @@ -360,5 +364,5 @@ inDescription - + \ No newline at end of file -- 2.34.1