Project

General

Profile

Revision 4dee6d44

ID4dee6d448bd28c6b5d3f07fb3f2c7b0630abc967
Parent e29ed013
Child 7d19ee1c

Added by Andreas Kohlbecker about 1 month ago

ref #9222 ref #6581 adapting web services to single sourced classes

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/initializer/EntityInitStrategy.java
11 11
import java.util.ArrayList;
12 12
import java.util.Arrays;
13 13
import java.util.List;
14
import java.util.stream.Collectors;
14 15

  
15 16
import org.apache.commons.lang3.StringUtils;
16 17

  
......
43 44
    }
44 45

  
45 46
    /**
46
     * Extends the property base bath by all property definitions in the <code>extensions</code>.
47
     * Extends the property base bath by all property definitions in the
48
     * <code>extensions</code> and adds the resulting property path to the
49
     * EntityInitStrategy.
50
     * <p>
51
     * Potential duplicate property paths de-duplicated.
47 52
     *
48
     * @param basePath can be NUll or empty to just append the extensions to the init strategies.
53
     * @param basePath
54
     *            can be NUll or empty to just append the extensions to the init
55
     *            strategies.
49 56
     * @param extensions
50 57
     * @param basePathIsCollection
51 58
     */
52
    public EntityInitStrategy extend(String basePath, EntityInitStrategy extensions, boolean basePathIsCollection){
59
    public EntityInitStrategy extend(String basePath, EntityInitStrategy extensions, boolean basePathIsCollection) {
53 60
        return extend(basePath, extensions.getPropertyPaths(), basePathIsCollection);
54 61
    }
55 62

  
56 63
    /**
57
     * Extends the property base bath by all property definitions in the <code>extensions</code>.
64
     * Extends the property base bath by all property definitions in the
65
     * <code>extensions</code> and adds the resulting property path to the
66
     * EntityInitStrategy.
67
     * <p>
68
     * Potential duplicate property paths de-duplicated.
58 69
     *
59
     * @param basePath can be NUll or empty to just append the extensions to the init strategies.
70
     * @param basePath
71
     *            can be NUll or empty to just add the extensions to the init
72
     *            strategies.
60 73
     * @param extensions
61 74
     * @param basePathIsCollection
62 75
     */
......
73 86
                propertyPaths.add(appendix);
74 87
            }
75 88
        }
89
        propertyPaths = propertyPaths.stream().distinct().collect(Collectors.toList());
76 90
        return this;
77 91
    }
78 92

  
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/NameController.java
77 77

  
78 78
    public static final EntityInitStrategy NAME_RELATIONS_INIT_STRATEGY = new EntityInitStrategy(Arrays.asList(new String []{
79 79
            "$",
80
            "source.citation",
80 81
            "relationsFromThisName.$",
81 82
            "relationsFromThisName.toName.registrations",
82 83
            "relationsToThisName.$",
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/NamePortalController.java
15 15
import java.util.List;
16 16
import java.util.Set;
17 17
import java.util.UUID;
18
import java.util.stream.Collectors;
18 19

  
19 20
import javax.servlet.http.HttpServletRequest;
20 21
import javax.servlet.http.HttpServletResponse;
......
70 71

  
71 72
    private static final Logger logger = Logger.getLogger(NamePortalController.class);
72 73

  
74
    private static final EntityInitStrategy DEFAULT_INIT_STRATEGY =  new EntityInitStrategy("$", "nomenclaturalSource.citation");
75

  
73 76
    private static final List<String> TYPEDESIGNATION_INIT_STRATEGY = TypeDesignationPortalController.DEFAULT_INIT_STRATEGY;
74 77

  
75 78

  
......
88 91

  
89 92
    private static EntityInitStrategy nameRelationsInitStrategy = null;
90 93

  
91
    /**
92
     * @return the nameRelationsInitStrategy
93
     */
94 94
    public static EntityInitStrategy getNameRelationsInitStrategy() {
95 95
        if(nameRelationsInitStrategy == null){
96 96
            nameRelationsInitStrategy = extendNameRelationsInitStrategies(NameController.NAME_RELATIONS_INIT_STRATEGY.getPropertyPaths(), true);
......
98 98
        return nameRelationsInitStrategy;
99 99
    }
100 100

  
101
    public NamePortalController() {
102
        setInitializationStrategy(DEFAULT_INIT_STRATEGY.getPropertyPaths());
103
    }
101 104

  
102 105
    @Override
103 106
    protected <CDM_BASE extends CdmBase> List<String> complementInitStrategy(Class<CDM_BASE> clazz,
......
106 109
        if(pathProperties == null){
107 110
            return pathProperties;
108 111
        }
109

  
110 112
        EntityInitStrategy initStrategy = extendNameRelationsInitStrategies(pathProperties, false);
111

  
112 113
        return initStrategy.getPropertyPaths();
113 114
    }
114 115

  
115
    /**
116
     * @param pathProperties
117
     * @return
118
     */
119 116
    static EntityInitStrategy extendNameRelationsInitStrategies(List<String> pathProperties, boolean addNomrefInitStrategy) {
120 117

  
121 118
        EntityInitStrategy initStrategy = new EntityInitStrategy(pathProperties);
......
127 124
            nameRelInitExtendet.extend("fromName", NOMREF_INIT_STRATEGY.getPropertyPaths(), false);
128 125
        }
129 126

  
130
        if(pathProperties.contains("nameRelations")){
127
        List<String> transtientNameRelationsInitstrategies = initStrategy.getPropertyPaths()
128
                .stream()
129
                .filter(s -> s.startsWith("nameRelations"))
130
                .collect(Collectors.toList());
131
        if(!transtientNameRelationsInitstrategies.isEmpty()){
131 132
            // nameRelations is a transient property! replace it by relationsFromThisName and relationsToThisName
132
            initStrategy.getPropertyPaths().remove("nameRelations");
133
            for(String remove : transtientNameRelationsInitstrategies) {
134
                initStrategy.getPropertyPaths().remove(remove);
135
            }
133 136
            initStrategy.extend("relationsFromThisName", nameRelInitExtendet.getPropertyPaths(), true);
134 137
            initStrategy.extend("relationsToThisName", nameRelInitExtendet.getPropertyPaths(), true);
135 138
        } else {
136
            if(pathProperties.contains("relationsFromThisName")){
137
                initStrategy.getPropertyPaths().remove("relationsFromThisName");
139
            if(pathProperties.stream().anyMatch(s -> s.startsWith("relationsFromThisName"))){
140
                initStrategy.getPropertyPaths().remove("relationsFromThisName"); // remove the very simple one
138 141
                initStrategy.extend("relationsFromThisName", nameRelInitExtendet.getPropertyPaths(), true);
139 142
            }
140
            if(pathProperties.contains("relationsToThisName")){
141
                initStrategy.getPropertyPaths().remove("relationsToThisName");
143
            if(pathProperties.stream().anyMatch(s -> s.startsWith("relationsToThisName"))){
144
                initStrategy.getPropertyPaths().remove("relationsToThisName"); // remove the very simple one
142 145
                initStrategy.extend("relationsToThisName", nameRelInitExtendet.getPropertyPaths(), true);
143 146
            }
144 147
        }
145 148
        return initStrategy;
146 149
    }
147 150

  
148
    /* (non-Javadoc)
149
     * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
150
     */
151 151
    @Autowired
152 152
    @Override
153 153
    public void setService(INameService service) {
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/NomenclaturalStatusController.java
61 61

  
62 62
        logger.info("doGet() - " + requestPathAndQuery(request));
63 63

  
64
        NomenclaturalStatus nomstatus = service.loadNomenclaturalStatus(uuid, Arrays.asList("$", "citation.inReference"));
64
        NomenclaturalStatus nomstatus = service.loadNomenclaturalStatus(uuid, Arrays.asList("$", "source.citation.inReference"));
65 65
        if(nomstatus == null){
66 66
            HttpStatusMessage.UUID_NOT_FOUND.send(response);
67 67
        }
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonPortalController.java
121 121
            "name.nomenclaturalSource.citation.inReference",
122 122
            "name.rank.representations",
123 123
            "name.status.type.representations",
124
            "name.status.source.citation",
124 125
            "sec.authorship"
125 126
//            "descriptions" // TODO remove
126 127

  
......
138 139
            "name.$",
139 140
            "name.rank.representations",
140 141
            "name.status.type.representations",
142
            "name.status.source.citation",
141 143
            "name.nomenclaturalSource.citation.authorship",
142 144
            "name.nomenclaturalSource.citation.inReference.authorship",
143 145
            "taxonNodes.classification",
......
148 150
            // initialize homotypical and heterotypical groups; needs synonyms
149 151
            "synonyms.$",
150 152
            "synonyms.name.status.type.representations",
153
            "synonyms.name.status.source.citation",
151 154
            "synonyms.name.nomenclaturalSource.citation.authorship",
152 155
            "synonyms.name.nomenclaturalSource.citation.inReference",
153 156
//            "synonyms.name.homotypicalGroup.typifiedNames.$",
......
176 179
    public static final EntityInitStrategy NAMERELATIONSHIP_INIT_STRATEGY = new EntityInitStrategy(Arrays.asList(new String []{
177 180
            "$",
178 181
            "type.inverseRepresentations",
179
            "citation",
182
            "source.citation",
180 183
            "toName.$",
181 184
            "toName.nomenclaturalSource.citation.authorship",
182 185
            "toName.nomenclaturalSource.citation.inReference",
cdmlib-remote/src/main/resources/eu/etaxonomy/cdm/remote/json/jsonConfigurations.xml
25 25
             <value>TermNode.children</value>
26 26
             <value>TermNode.feature</value>
27 27

  
28
            <value>NomenclaturalStatus.citation</value>
28
             <value>NomenclaturalStatus.source</value>
29
             <value>DescriptionElementSource.citation</value>
29 30

  
30 31
             <value>TreeNode.data</value>
31 32
             <value>TreeNode.data</value>

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)