import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
}
/**
- * Extends the property base bath by all property definitions in the <code>extensions</code>.
+ * Extends the property base bath by all property definitions in the
+ * <code>extensions</code> and adds the resulting property path to the
+ * EntityInitStrategy.
+ * <p>
+ * Potential duplicate property paths de-duplicated.
*
- * @param basePath can be NUll or empty to just append the extensions to the init strategies.
+ * @param basePath
+ * can be NUll or empty to just append the extensions to the init
+ * strategies.
* @param extensions
* @param basePathIsCollection
*/
- public EntityInitStrategy extend(String basePath, EntityInitStrategy extensions, boolean basePathIsCollection){
+ public EntityInitStrategy extend(String basePath, EntityInitStrategy extensions, boolean basePathIsCollection) {
return extend(basePath, extensions.getPropertyPaths(), basePathIsCollection);
}
/**
- * Extends the property base bath by all property definitions in the <code>extensions</code>.
+ * Extends the property base bath by all property definitions in the
+ * <code>extensions</code> and adds the resulting property path to the
+ * EntityInitStrategy.
+ * <p>
+ * Potential duplicate property paths de-duplicated.
*
- * @param basePath can be NUll or empty to just append the extensions to the init strategies.
+ * @param basePath
+ * can be NUll or empty to just add the extensions to the init
+ * strategies.
* @param extensions
* @param basePathIsCollection
*/
propertyPaths.add(appendix);
}
}
+ propertyPaths = propertyPaths.stream().distinct().collect(Collectors.toList());
return this;
}
\r
public static final EntityInitStrategy NAME_RELATIONS_INIT_STRATEGY = new EntityInitStrategy(Arrays.asList(new String []{\r
"$",\r
+ "source.citation",\r
"relationsFromThisName.$",\r
"relationsFromThisName.toName.registrations",\r
"relationsToThisName.$",\r
import java.util.List;
import java.util.Set;
import java.util.UUID;
+import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
private static final Logger logger = Logger.getLogger(NamePortalController.class);
+ private static final EntityInitStrategy DEFAULT_INIT_STRATEGY = new EntityInitStrategy("$", "nomenclaturalSource.citation");
+
private static final List<String> TYPEDESIGNATION_INIT_STRATEGY = TypeDesignationPortalController.DEFAULT_INIT_STRATEGY;
private static EntityInitStrategy nameRelationsInitStrategy = null;
- /**
- * @return the nameRelationsInitStrategy
- */
public static EntityInitStrategy getNameRelationsInitStrategy() {
if(nameRelationsInitStrategy == null){
nameRelationsInitStrategy = extendNameRelationsInitStrategies(NameController.NAME_RELATIONS_INIT_STRATEGY.getPropertyPaths(), true);
return nameRelationsInitStrategy;
}
+ public NamePortalController() {
+ setInitializationStrategy(DEFAULT_INIT_STRATEGY.getPropertyPaths());
+ }
@Override
protected <CDM_BASE extends CdmBase> List<String> complementInitStrategy(Class<CDM_BASE> clazz,
if(pathProperties == null){
return pathProperties;
}
-
EntityInitStrategy initStrategy = extendNameRelationsInitStrategies(pathProperties, false);
-
return initStrategy.getPropertyPaths();
}
- /**
- * @param pathProperties
- * @return
- */
static EntityInitStrategy extendNameRelationsInitStrategies(List<String> pathProperties, boolean addNomrefInitStrategy) {
EntityInitStrategy initStrategy = new EntityInitStrategy(pathProperties);
nameRelInitExtendet.extend("fromName", NOMREF_INIT_STRATEGY.getPropertyPaths(), false);
}
- if(pathProperties.contains("nameRelations")){
+ List<String> transtientNameRelationsInitstrategies = initStrategy.getPropertyPaths()
+ .stream()
+ .filter(s -> s.startsWith("nameRelations"))
+ .collect(Collectors.toList());
+ if(!transtientNameRelationsInitstrategies.isEmpty()){
// nameRelations is a transient property! replace it by relationsFromThisName and relationsToThisName
- initStrategy.getPropertyPaths().remove("nameRelations");
+ for(String remove : transtientNameRelationsInitstrategies) {
+ initStrategy.getPropertyPaths().remove(remove);
+ }
initStrategy.extend("relationsFromThisName", nameRelInitExtendet.getPropertyPaths(), true);
initStrategy.extend("relationsToThisName", nameRelInitExtendet.getPropertyPaths(), true);
} else {
- if(pathProperties.contains("relationsFromThisName")){
- initStrategy.getPropertyPaths().remove("relationsFromThisName");
+ if(pathProperties.stream().anyMatch(s -> s.startsWith("relationsFromThisName"))){
+ initStrategy.getPropertyPaths().remove("relationsFromThisName"); // remove the very simple one
initStrategy.extend("relationsFromThisName", nameRelInitExtendet.getPropertyPaths(), true);
}
- if(pathProperties.contains("relationsToThisName")){
- initStrategy.getPropertyPaths().remove("relationsToThisName");
+ if(pathProperties.stream().anyMatch(s -> s.startsWith("relationsToThisName"))){
+ initStrategy.getPropertyPaths().remove("relationsToThisName"); // remove the very simple one
initStrategy.extend("relationsToThisName", nameRelInitExtendet.getPropertyPaths(), true);
}
}
return initStrategy;
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
- */
@Autowired
@Override
public void setService(INameService service) {
logger.info("doGet() - " + requestPathAndQuery(request));
- NomenclaturalStatus nomstatus = service.loadNomenclaturalStatus(uuid, Arrays.asList("$", "citation.inReference"));
+ NomenclaturalStatus nomstatus = service.loadNomenclaturalStatus(uuid, Arrays.asList("$", "source.citation.inReference"));
if(nomstatus == null){
HttpStatusMessage.UUID_NOT_FOUND.send(response);
}
"name.nomenclaturalSource.citation.inReference",
"name.rank.representations",
"name.status.type.representations",
+ "name.status.source.citation",
"sec.authorship"
// "descriptions" // TODO remove
"name.$",
"name.rank.representations",
"name.status.type.representations",
+ "name.status.source.citation",
"name.nomenclaturalSource.citation.authorship",
"name.nomenclaturalSource.citation.inReference.authorship",
"taxonNodes.classification",
// initialize homotypical and heterotypical groups; needs synonyms
"synonyms.$",
"synonyms.name.status.type.representations",
+ "synonyms.name.status.source.citation",
"synonyms.name.nomenclaturalSource.citation.authorship",
"synonyms.name.nomenclaturalSource.citation.inReference",
// "synonyms.name.homotypicalGroup.typifiedNames.$",
public static final EntityInitStrategy NAMERELATIONSHIP_INIT_STRATEGY = new EntityInitStrategy(Arrays.asList(new String []{
"$",
"type.inverseRepresentations",
- "citation",
+ "source.citation",
"toName.$",
"toName.nomenclaturalSource.citation.authorship",
"toName.nomenclaturalSource.citation.inReference",
<value>TermNode.children</value>
<value>TermNode.feature</value>
- <value>NomenclaturalStatus.citation</value>
+ <value>NomenclaturalStatus.source</value>
+ <value>DescriptionElementSource.citation</value>
<value>TreeNode.data</value>
<value>TreeNode.data</value>