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
.log4j
.Logger
;
17 import org
.springframework
.aop
.framework
.Advised
;
18 import org
.springframework
.aop
.support
.AopUtils
;
20 import eu
.etaxonomy
.cdm
.api
.service
.dto
.DistributionInfoDTO
.InfoPart
;
21 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
22 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
23 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
24 import eu
.etaxonomy
.cdm
.ext
.geo
.EditGeoService
;
25 import eu
.etaxonomy
.cdm
.io
.api
.application
.CdmIoApplicationController
;
32 public class TestSalvadorAreaMapping
{
33 @SuppressWarnings("unused")
34 private static final Logger logger
= Logger
.getLogger(TestSalvadorAreaMapping
.class);
36 //database validation status (create, update, validate ...)
37 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.VALIDATE
;
39 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
40 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_salvador_preview();
41 static final ICdmDataSource cdmDestination
= CdmDestinations
.cdm_production_salvador();
44 protected void doTest(ICdmDataSource cdmDestination
){
46 CdmIoApplicationController app
= CdmIoApplicationController
.NewInstance(cdmDestination
, hbm2dll
);
49 } catch (Exception e
) {
59 private void doTest2(CdmIoApplicationController app
) {
60 UUID taxonUuid
= UUID
.fromString("eae896f0-3194-4b7b-a502-ad1d54ec36e6");
61 // Taxon taxon = (Taxon)app.getTaxonService().find(taxonUuid);
62 Object geoServiceObj
= app
.getBean("editGeoService");
63 EditGeoService geoService
;
65 geoService
= getTargetObject(geoServiceObj
);
68 Set
<InfoPart
> partSet
= new HashSet
<>();
69 partSet
.add(InfoPart
.mapUriParams
);
71 EnumSet
<InfoPart
> parts
= EnumSet
.copyOf(partSet
);
72 geoService
.composeDistributionInfoFor(parts
, taxonUuid
, false, false, null, null, null, null, null, null, null);
73 } catch (Exception e
) {
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
89 public static void main(String
[] args
) {
90 TestSalvadorAreaMapping me
= new TestSalvadorAreaMapping();
91 me
.doTest(cdmDestination
);