2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.app
.salvador
;
11 import java
.util
.EnumSet
;
12 import java
.util
.HashSet
;
14 import java
.util
.UUID
;
16 import org
.apache
.logging
.log4j
.LogManager
;
17 import org
.apache
.logging
.log4j
.Logger
;
18 import org
.springframework
.aop
.framework
.Advised
;
19 import org
.springframework
.aop
.support
.AopUtils
;
21 import eu
.etaxonomy
.cdm
.api
.dto
.portal
.DistributionInfoDto
.InfoPart
;
22 import eu
.etaxonomy
.cdm
.api
.dto
.portal
.config
.DistributionInfoConfiguration
;
23 import eu
.etaxonomy
.cdm
.api
.service
.geo
.DistributionServiceImpl
;
24 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
25 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
26 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
27 import eu
.etaxonomy
.cdm
.io
.api
.application
.CdmIoApplicationController
;
33 public class TestSalvadorAreaMapping
{
35 @SuppressWarnings("unused")
36 private static final Logger logger
= LogManager
.getLogger();
38 //database validation status (create, update, validate ...)
39 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.VALIDATE
;
41 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
42 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_salvador_preview();
43 static final ICdmDataSource cdmDestination
= CdmDestinations
.cdm_production_salvador();
45 protected void doTest(ICdmDataSource cdmDestination
){
47 CdmIoApplicationController app
= CdmIoApplicationController
.NewInstance(cdmDestination
, hbm2dll
);
50 } catch (Exception e
) {
55 private void doTest2(CdmIoApplicationController app
) {
56 UUID taxonUuid
= UUID
.fromString("eae896f0-3194-4b7b-a502-ad1d54ec36e6");
57 // Taxon taxon = (Taxon)app.getTaxonService().find(taxonUuid);
58 Object distributionServiceObj
= app
.getBean("distributionServiceImpl");
59 DistributionServiceImpl distributionService
;
61 distributionService
= getTargetObject(distributionServiceObj
);
64 Set
<InfoPart
> partSet
= new HashSet
<>();
65 partSet
.add(InfoPart
.mapUriParams
);
67 EnumSet
<InfoPart
> parts
= EnumSet
.copyOf(partSet
);
68 DistributionInfoConfiguration distConfig
= new DistributionInfoConfiguration();
69 distConfig
.setInfoParts(parts
);
70 distributionService
.composeDistributionInfoFor(distConfig
, taxonUuid
, false, null,
72 } catch (Exception e
) {
77 @SuppressWarnings("unchecked")
78 protected <T
> T
getTargetObject(Object proxy
) throws Exception
{
79 while( (AopUtils
.isJdkDynamicProxy(proxy
))) {
80 return (T
) getTargetObject(((Advised
)proxy
).getTargetSource().getTarget());
82 return (T
) proxy
; // expected to be cglib proxy then, which is simply a specialized class
85 public static void main(String
[] args
) {
86 TestSalvadorAreaMapping me
= new TestSalvadorAreaMapping();
87 me
.doTest(cdmDestination
);