import org.apache.commons.lang.ObjectUtils;\r
import org.apache.http.HttpRequest;\r
import org.apache.log4j.Logger;\r
+import org.apache.lucene.queryParser.ParseException;\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.stereotype.Controller;\r
import org.springframework.web.bind.WebDataBinder;\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.config.IFindTaxaAndNamesConfigurator;\r
+import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
+import eu.etaxonomy.cdm.api.service.search.SearchResult;\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.IdentifiableSource;\r
+import eu.etaxonomy.cdm.model.common.Language;\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.Feature;\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.MediaRepresentation;\r
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;\r
import eu.etaxonomy.cdm.model.media.MediaUtils;\r
import eu.etaxonomy.cdm.model.name.NameRelationship;\r
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;\r
import eu.etaxonomy.cdm.model.taxon.Classification;\r
import eu.etaxonomy.cdm.persistence.query.MatchMode;\r
+import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters;\r
import eu.etaxonomy.cdm.remote.editor.CdmTypePropertyEditor;\r
import eu.etaxonomy.cdm.remote.editor.MatchModePropertyEditor;\r
private ITaxonService taxonService;\r
\r
@Autowired\r
- private ITermService markerTypeService;\r
-\r
- @Autowired\r
- private IMarkerService markerService;\r
- //private IService<MarkerType> markerTypeService;\r
+ private ITermService termService;\r
\r
@Autowired\r
private IFeatureTreeService featureTreeService;\r
});\r
\r
private static final List<String> TYPEDESIGNATION_INIT_STRATEGY = Arrays.asList(new String []{\r
- //"$",\r
"typeSpecimen.$",\r
"citation.authorTeam.$",\r
"typeName",\r
+ "typeStatus"\r
});\r
\r
protected static final List<String> TAXONNODE_WITHTAXON_INIT_STRATEGY = Arrays.asList(new String []{\r
PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber);\r
pagerParams.normalizeAndValidate(response);\r
\r
- ITaxonServiceConfigurator config = new TaxonServiceConfiguratorImpl();\r
+ IFindTaxaAndNamesConfigurator config = new FindTaxaAndNamesConfiguratorImpl();\r
config.setPageNumber(pagerParams.getPageIndex());\r
config.setPageSize(pagerParams.getPageSize());\r
config.setTitleSearchString(query);\r
return (Pager<IdentifiableEntity>) service.findTaxaAndNames(config);\r
}\r
\r
+ /**\r
+ * @param clazz\r
+ * @param queryString\r
+ * @param treeUuid\r
+ * @param languages\r
+ * @param features one or more feature uuids\r
+ * @param pageNumber\r
+ * @param pageSize\r
+ * @param request\r
+ * @param response\r
+ * @return\r
+ * @throws IOException\r
+ * @throws ParseException\r
+ */\r
+ @RequestMapping(method = RequestMethod.GET, value={"/portal/taxon/findByDescriptionElementFullText"})\r
+ public Pager<SearchResult<TaxonBase>> dofindByDescriptionElementFullText(\r
+ @RequestParam(value = "clazz", required = false) Class clazz,\r
+ @RequestParam(value = "query", required = true) String queryString,\r
+ @RequestParam(value = "tree", required = false) UUID treeUuid,\r
+ @RequestParam(value = "features", required = false) UuidList featureUuids,\r
+ @RequestParam(value = "languages", required = false) List<Language> languages,\r
+ @RequestParam(value = "hl", required = false) Boolean highlighting,\r
+ @RequestParam(value = "pageNumber", required = false) Integer pageNumber,\r
+ @RequestParam(value = "pageSize", required = false) Integer pageSize,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response\r
+ )\r
+ throws IOException, ParseException {\r
+\r
+ logger.info("findByDescriptionElementFullText : " + request.getRequestURI() + "?" + request.getQueryString() );\r
+\r
+ PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber);\r
+ pagerParams.normalizeAndValidate(response);\r
+\r
+ if(highlighting == null){\r
+ highlighting = false;\r
+ }\r
+\r
+ Classification classification = null;\r
+ if(treeUuid != null){\r
+ classification = classificationService.find(treeUuid);\r
+ }\r
+\r
+ List<Feature> features = null;\r
+ if(featureUuids != null){\r
+ features = new ArrayList<Feature>(featureUuids.size());\r
+ for(UUID uuid : featureUuids){\r
+ features.add((Feature) termService.find(uuid));\r
+ }\r
+ }\r
+\r
+ Pager<SearchResult<TaxonBase>> pager = service.findByDescriptionElementFullText(clazz, queryString, classification, features, languages, highlighting, pagerParams.getPageSize(), pagerParams.getPageIndex(), ((List<OrderHint>)null), SIMPLE_TAXON_INIT_STRATEGY);\r
+ return pager;\r
+ }\r
+\r
/**\r
* Get the synonymy for a taxon identified by the <code>{taxon-uuid}</code>.\r
* The synonymy consists\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
+ sMarkerTypeUUIDs = new HashSet<UUID>(markerTypeUUIDs);\r
+ markerTypeTerms = termService.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
+ for (DefinedTermBase markerTypeTerm : markerTypeTerms) {\r
+ markerTypes.add((MarkerType)markerTypeTerm);\r
+ }\r
}\r
Taxon t = getCdmBaseInstance(Taxon.class, uuid, response, (List<String>)null);\r
if (markerTypeTerms == null) {\r
else {\r
descriptions = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);\r
/*for (TaxonDescription description: descriptions) {\r
- for (IdentifiableSource source :description.getSources()) {\r
- if (source.getOriginalNameString() != null) {\r
- description.\r
- }\r
- \r
- }\r
- \r
- \r
+ for (IdentifiableSource source :description.getSources()) {\r
+ if (source.getOriginalNameString() != null) {\r
+ description.\r
+ }\r
+\r
+ }\r
+\r
+\r
}*/\r
}\r
return descriptions;\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
+ MarkerType useMarkerType = (MarkerType) termService.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
private List<Media> getMediaForTaxon(Taxon taxon, Class<? extends MediaRepresentationPart> type, String[] mimeTypes,\r
Integer widthOrDuration, Integer height, Integer size){\r
\r
- Pager<TaxonDescription> p =\r
- descriptionService.getTaxonDescriptions(taxon, null, null, null, null, TAXONDESCRIPTION_MEDIA_INIT_STRATEGY);\r
-\r
- // pars the media and quality parameters\r
+ List<Media> taxonGalleryMedia = service.listTaxonDescriptionMedia(taxon, false, TAXONDESCRIPTION_MEDIA_INIT_STRATEGY);\r
\r
+ Map<Media, MediaRepresentation> mediaRepresentationMap = MediaUtils.findPreferredMedia(taxonGalleryMedia, type,\r
+ mimeTypes, null, widthOrDuration, height, size);\r
\r
- // collect all media of the given taxon\r
- boolean limitToGalleries = false;\r
- List<Media> taxonMedia = new ArrayList<Media>();\r
- List<Media> taxonGalleryMedia = new ArrayList<Media>();\r
- for(TaxonDescription desc : p.getRecords()){\r
-\r
- if(desc.isImageGallery()){\r
- for(DescriptionElementBase element : desc.getElements()){\r
- for(Media media : element.getMedia()){\r
- taxonGalleryMedia.add(media);\r
- }\r
- }\r
- } else if(!limitToGalleries){\r
- for(DescriptionElementBase element : desc.getElements()){\r
- for(Media media : element.getMedia()){\r
- taxonMedia.add(media);\r
- }\r
- }\r
- }\r
-\r
+ List<Media> filteredMedia = new ArrayList<Media>(mediaRepresentationMap.size());\r
+ for(Media media : mediaRepresentationMap.keySet()){\r
+ media.getRepresentations().clear();\r
+ media.addRepresentation(mediaRepresentationMap.get(media));\r
+ filteredMedia.add(media);\r
}\r
\r
- taxonGalleryMedia.addAll(taxonMedia);\r
-\r
- List<Media> returnMedia = MediaUtils.findPreferredMedia(taxonGalleryMedia, type,\r
- mimeTypes, null, widthOrDuration, height, size);\r
-\r
- return returnMedia;\r
+ return filteredMedia;\r
}\r
\r
\r