Skip to content

Commit 53f202c

Browse files
added full postcoordination configuration.
1 parent 620f8ff commit 53f202c

File tree

6 files changed

+108
-2
lines changed

6 files changed

+108
-2
lines changed

src/main/java/edu/stanford/protege/gateway/config/ApplicationBeans.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,9 @@ CommandExecutor<GetEntityHistorySummaryRequest, GetEntityHistorySummaryResponse>
178178
return new CommandExecutorImpl<>(GetEntityHistorySummaryResponse.class);
179179
}
180180

181+
@Bean
182+
CommandExecutor<GetFullPostCoordinationConfigurationRequest, GetFullPostCoordinationConfigurationResponse> getFullPostCoordinationConfigurationExecutor() {
183+
return new CommandExecutorImpl<>(GetFullPostCoordinationConfigurationResponse.class);
184+
}
185+
181186
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package edu.stanford.protege.gateway.controllers;
2+
3+
import edu.stanford.protege.gateway.postcoordination.EntityPostCoordinationService;
4+
import edu.stanford.protege.gateway.postcoordination.commands.CompletePostCoordinationAxisConfiguration;
5+
import edu.stanford.protege.webprotege.ipc.util.CorrelationMDCUtil;
6+
import io.swagger.v3.oas.annotations.Operation;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
8+
import org.springframework.http.ResponseEntity;
9+
import org.springframework.web.bind.annotation.GetMapping;
10+
import org.springframework.web.bind.annotation.RequestMapping;
11+
import org.springframework.web.bind.annotation.RestController;
12+
13+
import java.util.List;
14+
import java.util.UUID;
15+
import java.util.concurrent.ExecutionException;
16+
import java.util.concurrent.TimeoutException;
17+
18+
@RestController
19+
@RequestMapping("/postcoordination-definitions")
20+
@Tag(name = "4. iCAT-X PostCoordination Definitions", description = "APIs for querying iCAT-X postcoordination definitions")
21+
public class PostCoordinationDefinitionController {
22+
23+
24+
private final EntityPostCoordinationService entityPostCoordinationService;
25+
26+
public PostCoordinationDefinitionController(EntityPostCoordinationService entityPostCoordinationService) {
27+
this.entityPostCoordinationService = entityPostCoordinationService;
28+
}
29+
30+
31+
@GetMapping
32+
@Operation(summary = "Get complete postcoordination definitions", operationId = "10_getPostCoordinationDefinitions")
33+
public ResponseEntity<List<CompletePostCoordinationAxisConfiguration>> getLinearizationDefinitions() throws ExecutionException, InterruptedException, TimeoutException {
34+
CorrelationMDCUtil.setCorrelationId(UUID.randomUUID().toString());
35+
36+
return ResponseEntity.ok(entityPostCoordinationService.getAllPostCoordinationAxisConfigs());
37+
}
38+
39+
}

src/main/java/edu/stanford/protege/gateway/postcoordination/EntityPostCoordinationService.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
import java.util.*;
2323
import java.util.concurrent.CompletableFuture;
24+
import java.util.concurrent.ExecutionException;
25+
import java.util.concurrent.TimeUnit;
26+
import java.util.concurrent.TimeoutException;
2427

2528

2629
@Service
@@ -38,21 +41,24 @@ public class EntityPostCoordinationService {
3841
private final CommandExecutor<GetTablePostCoordinationAxisRequest, GetTablePostCoordinationAxisResponse> tableConfigurationExecutor;
3942
private final CommandExecutor<GetIcatxEntityTypeRequest, GetIcatxEntityTypeResponse> entityTypesExecutor;
4043

44+
private final CommandExecutor<GetFullPostCoordinationConfigurationRequest, GetFullPostCoordinationConfigurationResponse> entityConfigurationExecutor;
45+
4146
private final EntityLinearizationService linearizationService;
4247

4348
public EntityPostCoordinationService(CommandExecutor<GetEntityCustomScaleValuesRequest, GetEntityCustomScaleValueResponse> customScaleExecutor,
4449
CommandExecutor<GetEntityPostCoordinationRequest, GetEntityPostCoordinationResponse> specificationExecutor,
4550
CommandExecutor<AddEntityCustomScalesRevisionRequest, AddEntityCustomScalesRevisionResponse> updateCustomScalesExecutor,
4651
CommandExecutor<AddEntitySpecificationRevisionRequest, AddEntitySpecificationRevisionResponse> updateSpecificationExecutor,
4752
CommandExecutor<GetTablePostCoordinationAxisRequest, GetTablePostCoordinationAxisResponse> tableConfigurationExecutor,
48-
CommandExecutor<GetIcatxEntityTypeRequest, GetIcatxEntityTypeResponse> entityTypesExecutor,
53+
CommandExecutor<GetIcatxEntityTypeRequest, GetIcatxEntityTypeResponse> entityTypesExecutor, CommandExecutor<GetFullPostCoordinationConfigurationRequest, GetFullPostCoordinationConfigurationResponse> entityConfigurationExecutor,
4954
EntityLinearizationService linearizationService) {
5055
this.customScaleExecutor = customScaleExecutor;
5156
this.specificationExecutor = specificationExecutor;
5257
this.updateCustomScalesExecutor = updateCustomScalesExecutor;
5358
this.updateSpecificationExecutor = updateSpecificationExecutor;
5459
this.tableConfigurationExecutor = tableConfigurationExecutor;
5560
this.entityTypesExecutor = entityTypesExecutor;
61+
this.entityConfigurationExecutor = entityConfigurationExecutor;
5662
this.linearizationService = linearizationService;
5763
}
5864

@@ -76,6 +82,7 @@ public CompletableFuture<List<EntityPostCoordinationSpecificationDto>> getPostCo
7682
}
7783

7884

85+
7986
public void updateEntityPostCoordination(EntityPostCoordinationWrapperDto postcoordination, ProjectId projectId, String entityIri, ChangeRequestId changeRequestId) {
8087
try {
8188
if(postcoordination != null) {
@@ -112,5 +119,7 @@ public CompletableFuture<List<EntityPostCoordinationCustomScalesDto>> getEntityC
112119
);
113120
}
114121

115-
122+
public List<CompletePostCoordinationAxisConfiguration> getAllPostCoordinationAxisConfigs() throws ExecutionException, InterruptedException, TimeoutException {
123+
return entityConfigurationExecutor.execute(new GetFullPostCoordinationConfigurationRequest(), SecurityContextHelper.getExecutionContext()).get(5, TimeUnit.SECONDS).configuration();
124+
}
116125
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package edu.stanford.protege.gateway.postcoordination.commands;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
import java.util.Map;
6+
import java.util.Set;
7+
8+
public class CompletePostCoordinationAxisConfiguration {
9+
@JsonProperty("axisIdentifier")
10+
public String axisIdentifier;
11+
@JsonProperty("availableForEntityTypes")
12+
public Set<String> availableForEntityTypes;
13+
@JsonProperty("tableLabel")
14+
public String tableLabel;
15+
@JsonProperty("scaleLabel")
16+
public String scaleLabel;
17+
@JsonProperty("postCoordinationAxisSortingCode")
18+
public String postCoordinationAxisSortingCode;
19+
@JsonProperty("postCoordinationSubAxes")
20+
public Map<String, Set<String>> postCoordinationSubAxes;
21+
@JsonProperty("availableScalesTopClass")
22+
public String availableScalesTopClass;
23+
@JsonProperty("allowMultiValue")
24+
public String allowMultivalue;
25+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package edu.stanford.protege.gateway.postcoordination.commands;
2+
3+
4+
import com.fasterxml.jackson.annotation.JsonTypeName;
5+
import edu.stanford.protege.webprotege.common.Request;
6+
7+
8+
@JsonTypeName(GetFullPostCoordinationConfigurationRequest.CHANNEL)
9+
public class GetFullPostCoordinationConfigurationRequest implements Request<GetFullPostCoordinationConfigurationResponse> {
10+
11+
public final static String CHANNEL = "webprotege.postcoordination.GetFullPostCoordinationConfiguration";
12+
13+
@Override
14+
public String getChannel() {
15+
return CHANNEL;
16+
}
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package edu.stanford.protege.gateway.postcoordination.commands;
2+
3+
import com.fasterxml.jackson.annotation.JsonTypeName;
4+
import edu.stanford.protege.webprotege.common.Response;
5+
6+
import java.util.List;
7+
8+
9+
@JsonTypeName(GetFullPostCoordinationConfigurationRequest.CHANNEL)
10+
public record GetFullPostCoordinationConfigurationResponse(List<CompletePostCoordinationAxisConfiguration> configuration) implements Response {
11+
}

0 commit comments

Comments
 (0)