Project

General

Profile

Revision 1fab5922

ID1fab59220d372c0175457f38fdf98ca37b75b4d4
Parent c6a7335e
Child 973082b3

Added by Andreas Müller over 3 years ago

ref #6682 some changes to test taxon relationship service

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/TaxonRelationshipFormatterTest.java
131 131
        str = TaggedCacheHelper.createString(tags);
132 132
        System.out.println(str);
133 133
        Assert.assertEquals(symbol + " Pinus pinova Mill. sec. ToSecAuthor 1928, rel. sec. Cheek 1919: 123", str);
134
        //FIXME symbol
135

  
136 134

  
137 135
        //auctores
138 136
        fromTaxon.setAppendedPhrase("auctores");
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/BaseController.java
404 404
     * @return
405 405
     * @throws IOException
406 406
     */
407
    protected <T extends IPublishable> T checkExistsAndAccess(T publishable, boolean includeUnpublished,
407
    protected <S extends IPublishable> S checkExistsAndAccess(S publishable, boolean includeUnpublished,
408 408
            HttpServletResponse response) throws IOException {
409 409
        if (publishable == null){
410 410
            HttpStatusMessage.UUID_NOT_FOUND.send(response);
......
415 415
        return publishable;
416 416
    }
417 417

  
418
    protected <S extends IPublishable> S checkExistsAccessType(IPublishable publishable, boolean includeUnpublished,
419
            Class<S> clazz, HttpServletResponse response) throws IOException {
420
        IPublishable result = this.checkExistsAndAccess(publishable, includeUnpublished, response);
421
        if (clazz != null && !clazz.isAssignableFrom(result.getClass())){
422
            HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);
423
            result = null;
424
        }
425
        return (S)result;
426
    }
418 427

  
419 428
      /* TODO implement
420 429

  
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonController.java
44 44
import eu.etaxonomy.cdm.api.service.dto.TaxonRelationshipsDTO;
45 45
import eu.etaxonomy.cdm.api.service.pager.Pager;
46 46
import eu.etaxonomy.cdm.exception.UnpublishedException;
47
import eu.etaxonomy.cdm.model.common.CdmBase;
48
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
47 49
import eu.etaxonomy.cdm.model.common.MarkerType;
48 50
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
49 51
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
......
465 467
    @RequestMapping(value = "taxonRelationshipsDTO", method = RequestMethod.GET)
466 468
    public TaxonRelationshipsDTO doGetTaxonRelationshipsDTO(
467 469
            @PathVariable("uuid") UUID taxonUuid,
468
            @RequestParam(value = "type", required = false) Set<UUID> typeUuids,
470
            //TODO should be set
471
            @RequestParam(value = "type", required = false) UUID typeUuid,
469 472
            @RequestParam(value = "direction", required = false) Direction direction,
470 473
            HttpServletRequest request,
471 474
            HttpServletResponse response) throws IOException {
......
474 477

  
475 478
        logger.info("doGetTaxonRelationshipDTOs(): " + request.getRequestURI());
476 479
        TaxonBase<?> taxonBase = service.load(taxonUuid);
477
        taxonBase = checkExistsAndAccess(taxonBase, includeUnpublished, response);
480
        Taxon taxon = checkExistsAccessType(taxonBase, includeUnpublished, Taxon.class, response);
478 481

  
479
        direction = null;
480
        //TODO typeUuids;
481 482
        Set<TaxonRelationshipType> types = null;
483
        if (typeUuid != null){
484
            types = new HashSet<>();
485
            DefinedTermBase<?> type = termService.find(typeUuid);
486
            if (type.isInstanceOf(TaxonRelationshipType.class)){
487
                types.add(CdmBase.deproxy(type, TaxonRelationshipType.class));
488
            }else{
489
                HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);
490
            }
491
        }
482 492
        boolean deduplicateMisapplications = true;
483 493
        Integer pageSize = null;
484 494
        Integer pageNumber = null;
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
3232 3232
                }
3233 3233
            }
3234 3234
            if (deduplicateMisapplications){
3235
                dto.createMisapplicationString();
3235
//                dto.createMisapplicationString();
3236 3236
            }
3237 3237
            return dto;
3238 3238
        }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTO.java
64 64
                //TODO there must be a better DTO which also includes
65 65
                Set<Representation> representations = direction.isDirect() ? relType.getRepresentations() : relType.getInverseRepresentations();
66 66
                this.setType(new TermDto(relType.getUuid(), representations, relType.getOrderIndex()));
67
                this.misapplication = relation.getType().isAnyMisappliedName();
67 68
            }
68 69
            List<TaggedText> tags = new TaxonRelationshipFormatter().getTaggedText(
69 70
                    relation, direction == Direction.relatedFrom, languages);
70 71
            this.taggedText = tags;
71 72
            this.setCache(TaggedCacheHelper.createString(tags));
72
            this.setMisapplication(relation.getType().isAnyMisappliedName());
73 73
        }
74 74

  
75 75

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)