import eu.etaxonomy.cdm.common.SetMap;
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
import eu.etaxonomy.cdm.model.common.Annotation;
+import eu.etaxonomy.cdm.model.common.AnnotationType;
import eu.etaxonomy.cdm.model.common.Marker;
import eu.etaxonomy.cdm.persistence.dao.common.ICdmGenericDao;
Map<String,Object> params = new HashMap<>();
String hql = "SELECT new map(bc.id as id, a.id as annotationId) "
- + " FROM "+baseClass.getSimpleName()+" bc JOIN bc.annotations a "
+ + " FROM "+baseClass.getSimpleName()+" bc JOIN bc.annotations a"
+ + " LEFT JOIN a.annotationType at"
+ " WHERE bc.id IN :baseIds";
params.put("baseIds", baseIds);
- if (config.getAnnotationTypes() != null) {
- hql += " AND a.annotationType.uuid IN :annotationTypes ";
+ if (config.getAnnotationTypes() != null ) {
+ hql += " AND (at.uuid IN :annotationTypes ";
+ if (config.getAnnotationTypes().contains(AnnotationType.uuidUntyped)) {
+ hql += " OR a.id IS NOT NULL AND at IS NULL ";
+ }
+ hql += ")";
params.put("annotationTypes", config.getAnnotationTypes());
}
//annotation
for (Annotation annotation : annotatable.getAnnotations()) {
if ((annotation.getAnnotationType() != null
- //config == null currently needs to be allowed as it is also used by DistributionInfoBuilder an
+ //config == null currently needs to be allowed as it is also used by DistributionInfoBuilder and
//also for now empty annotation types needs to be interpreted as "no filter" as we do not distinguish
//null and empty yet, this may change in future
&& (config == null || config.getAnnotationTypes().isEmpty()
UUID uuidAnnotationType = annotation.getAnnotationType() == null ? null :annotation.getAnnotationType().getUuid();
annotationDto.setTypeUuid(uuidAnnotationType);
//language etc. currently not yet used
- }else if (config != null && !config.getAnnotationTypes().isEmpty() && config.getAnnotationTypes().contains(AnnotationType.uuidUntyped) && (annotation.getAnnotationType() == null)){
+ }else if (config != null && config.getAnnotationTypes().contains(AnnotationType.uuidUntyped) && (annotation.getAnnotationType() == null)){
AnnotationDto annotationDto = new AnnotationDto();
annotatableDto.addAnnotation(annotationDto);
//TODO id needed? but need to adapt dto and container then
import eu.etaxonomy.cdm.model.common.AnnotationType;
import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.MarkerType;
import eu.etaxonomy.cdm.model.common.TimePeriod;
import eu.etaxonomy.cdm.model.description.CategoricalData;
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
cc.showAreaOfScopeLabel = true;
config.setWithSpecimens(false);
config.setTaxonUuid(taxonUuid);
+ config.addAnnotationType(AnnotationType.uuidUntyped);
config.setUseDtoLoading(false);
testAllFactsDo(config); //with model instance loading
TreeNode<Set<DistributionDto>, NamedAreaDto> germanyNode = tree.getRootElement().getChildren().get(1);
Assert.assertEquals("Germany", germanyNode.getNodeId().getLabel());
DistributionDto germanyDistribution = germanyNode.getData().iterator().next();
- Assert.assertEquals(1, germanyDistribution.getAnnotations().getCount());
+ Assert.assertEquals(2, germanyDistribution.getAnnotations().getCount());
+ Assert.assertEquals("Missing type annotation should exist",
+ + 1, germanyDistribution.getAnnotations().getItems().stream()
+ .filter(a->"Missing Type Annotation".equals(a.getText())).count());
Assert.assertEquals("There should be 1 source (even if it has no name used in source)", 1, germanyDistribution.getSources().getCount());
//france
Country.GERMANY().setSymbol("De");
PresenceAbsenceTerm.PRESENT().setSymbol("");
Distribution germany = Distribution.NewInstance(Country.GERMANY(), PresenceAbsenceTerm.PRESENT());
- germany.addAnnotation(Annotation.NewEditorialDefaultLanguageInstance("Abc Annotation"));
+ germany.addAnnotation(Annotation.NewEditorialDefaultLanguageInstance("Editorial Annotation"));
germany.addAnnotation(Annotation.NewInstance("Technical Annotation", AnnotationType.TECHNICAL(), Language.DEFAULT()));
+ germany.addAnnotation(Annotation.NewInstance("Missing Type Annotation", null, Language.DEFAULT()));
//.... germany source
Reference germanRef = ReferenceFactory.newArticle();
germanRef.setInJournal(ReferenceFactory.newJournal());
//empty text
TextData emptyTd = TextData.NewInstance(Feature.DISCUSSION(), "", Language.DEFAULT(), null);
taxDesc.addElements(emptyTd);
+ //annotation
+ taxDesc.addAnnotation(Annotation.NewInstance("Missing Type Annotation for empty", null, Language.DEFAULT()));
+ taxDesc.addMarker(MarkerType.IS_DOUBTFUL(), true);
//common names
CommonTaxonName cn1 = CommonTaxonName.NewInstance("My flower", Language.ENGLISH(), Country.UNITEDKINGDOMOFGREATBRITAINANDNORTHERNIRELAND());