import org.springframework.web.bind.annotation.RequestParam;\r
import org.springframework.web.servlet.ModelAndView;\r
\r
+\r
import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;\r
+import eu.etaxonomy.cdm.api.service.IMarkerService;\r
import eu.etaxonomy.cdm.api.service.INameService;\r
import eu.etaxonomy.cdm.api.service.IOccurrenceService;\r
+import eu.etaxonomy.cdm.api.service.IService;\r
import eu.etaxonomy.cdm.api.service.ITaxonService;\r
import eu.etaxonomy.cdm.api.service.IClassificationService;\r
+import eu.etaxonomy.cdm.api.service.ITermService;\r
import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator;\r
import eu.etaxonomy.cdm.api.service.config.TaxonServiceConfiguratorImpl;\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
import eu.etaxonomy.cdm.database.UpdatableRoutingDataSource;\r
+import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
+import eu.etaxonomy.cdm.model.common.Marker;\r
+import eu.etaxonomy.cdm.model.common.MarkerType;\r
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;\r
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
import eu.etaxonomy.cdm.model.location.NamedArea;\r
+import eu.etaxonomy.cdm.model.location.NamedAreaLevel;\r
import eu.etaxonomy.cdm.model.media.Media;\r
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;\r
import eu.etaxonomy.cdm.model.media.MediaUtils;\r
import eu.etaxonomy.cdm.remote.editor.CdmTypePropertyEditor;\r
import eu.etaxonomy.cdm.remote.editor.MatchModePropertyEditor;\r
import eu.etaxonomy.cdm.remote.editor.NamedAreaPropertyEditor;\r
+import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor;\r
+import eu.etaxonomy.cdm.remote.editor.UuidList;\r
\r
/**\r
* The TaxonPortalController class is a Spring MVC Controller.\r
@Autowired\r
private ITaxonService taxonService;\r
\r
+ @Autowired\r
+ private ITermService markerTypeService;\r
+\r
+ @Autowired\r
+ private IMarkerService markerService;\r
+ //private IService<MarkerType> markerTypeService;\r
+\r
@Autowired\r
private IFeatureTreeService featureTreeService;\r
\r
"elements.media.title",\r
});\r
\r
+ protected static final List<String> TAXONUSEDESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "$",\r
+ "sources.$",\r
+ "elements.$",\r
+ "elements.states.$",\r
+ "elements.sources.citation.authorTeam",\r
+ "elements.sources.nameUsedInSource.originalNameString",\r
+ /*//"elements.multilanguageText",\r
+ "elements.media.representations.parts",\r
+ "elements.media.title",*/\r
+ });\r
+\r
protected static final List<String> DESCRIPTION_ELEMENT_INIT_STRATEGY = Arrays.asList(new String []{\r
"$",\r
"sources.citation.authorTeam",\r
binder.registerCustomEditor(NamedArea.class, new NamedAreaPropertyEditor());\r
binder.registerCustomEditor(MatchMode.class, new MatchModePropertyEditor());\r
binder.registerCustomEditor(Class.class, new CdmTypePropertyEditor());\r
+ binder.registerCustomEditor(UuidList.class, new UUIDListPropertyEditor());\r
+\r
}\r
\r
\r
method = RequestMethod.GET)\r
public List<TaxonDescription> doGetDescriptions(\r
@PathVariable("uuid") UUID uuid,\r
+ @RequestParam(value = "markerTypes", required = false) UuidList markerTypeUUIDs,\r
HttpServletRequest request,\r
HttpServletResponse response)throws IOException {\r
- if(request != null){\r
+ if(request != null){\r
logger.info("doGetDescriptions()" + request.getServletPath());\r
}\r
+ List<DefinedTermBase> markerTypeTerms = null;\r
+ Set<UUID> sMarkerTypeUUIDs = null;\r
+\r
+ if(markerTypeUUIDs != null && !markerTypeUUIDs.isEmpty()){\r
+ sMarkerTypeUUIDs = new HashSet<UUID>(markerTypeUUIDs);\r
+ markerTypeTerms = markerTypeService.find(sMarkerTypeUUIDs);\r
+ } else if(markerTypeUUIDs != null && markerTypeUUIDs.isEmpty()){\r
+ markerTypeTerms = new ArrayList<DefinedTermBase>();\r
+ }\r
+ Set<MarkerType> markerTypes = new HashSet<MarkerType>();\r
+ List<TaxonDescription> descriptions = new ArrayList<TaxonDescription>();\r
+ if (markerTypeTerms != null) {\r
+ for (DefinedTermBase markerTypeTerm : markerTypeTerms) {\r
+ markerTypes.add((MarkerType)markerTypeTerm);\r
+ }\r
+ }\r
Taxon t = getCdmBaseInstance(Taxon.class, uuid, response, (List<String>)null);\r
- Pager<TaxonDescription> p = descriptionService.getTaxonDescriptions(t, null, null, null, null, TAXONDESCRIPTION_INIT_STRATEGY);\r
- return p.getRecords();\r
+ if (markerTypeTerms == null) {\r
+\r
+ Pager<TaxonDescription> p = descriptionService.getTaxonDescriptions(t, null, null, null, null, TAXONDESCRIPTION_INIT_STRATEGY);\r
+ descriptions = p.getRecords();\r
+ }\r
+\r
+ else if (markerTypeTerms != null && markerTypeTerms.isEmpty()) {\r
+ descriptions = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);\r
+\r
+ }\r
+ else {\r
+ descriptions = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);\r
+ }\r
+ return descriptions;\r
+ }\r
+\r
+ @RequestMapping(value = "useDescriptions", method = RequestMethod.GET)\r
+ public List<TaxonDescription> doGetUseDescriptions(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response) throws IOException {\r
+ logger.info("doGetDescriptionElements() - " + request.getServletPath());\r
+\r
+ //ModelAndView mv = new ModelAndView();\r
+ Taxon t = getCdmBaseInstance(Taxon.class, uuid, response, (List<String>)null);\r
+\r
+ //MarkerType useMarkerType = (MarkerType) markerTypeService.find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f059"));\r
+ MarkerType useMarkerType = (MarkerType) markerTypeService.find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039"));\r
+\r
+ //find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f059"));\r
+ Set<MarkerType> markerTypes = new HashSet<MarkerType>();\r
+ markerTypes.add(useMarkerType);\r
+ List<TaxonDescription> descriptionElements = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);\r
+ //getDescriptionElements(description, features, type, pageSize, pageNumber, propertyPaths) load(uuid);\r
+\r
+ /*if(!(description instanceof TaxonDescription)){\r
+ HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);\r
+ // will terminate thread\r
+ }*/\r
+\r
+ //boolean hasStructuredData = service. hasStructuredData(description);\r
+\r
+ //mv.addObject(hasStructuredData);\r
+\r
+ return descriptionElements;\r
}\r
\r
@RequestMapping(value = "descriptions/elementsByType/{classSimpleName}", method = RequestMethod.GET)\r
public ModelAndView doGetDescriptionElementsByType(\r
@PathVariable("uuid") UUID uuid,\r
@PathVariable("classSimpleName") String classSimpleName,\r
+ //@RequestParam(value = "markerTypes", required = false, defaultValue = "false") Set<UUID> markerTypes,\r
+// @PathVariable(value = "markerTypes") String markerTypes,\r
+ @RequestParam(value = "markerTypes", required = false) UuidList markerTypeUUIDs,\r
@RequestParam(value = "count", required = false, defaultValue = "false") Boolean doCount,\r
HttpServletRequest request,\r
HttpServletResponse response) throws IOException {\r
\r
List<String> initStrategy = doCount ? null : DESCRIPTION_ELEMENT_INIT_STRATEGY;\r
\r
- List<TaxonDescription> taxonDescriptions = doGetDescriptions(uuid, request, response);\r
+ List<TaxonDescription> taxonDescriptions = doGetDescriptions(uuid, markerTypeUUIDs, request, response);\r
try {\r
Class type;\r
type = Class.forName("eu.etaxonomy.cdm.model.description."\r