Skip to content

Commit 31fda45

Browse files
authored
Merge pull request #66 from who-icatx/api-validation
Api validation
2 parents 16312cc + 7f230b1 commit 31fda45

File tree

11 files changed

+723
-10
lines changed

11 files changed

+723
-10
lines changed

src/main/java/edu/stanford/protege/gateway/OwlEntityService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private void validateEntityUpdate(OWLEntityDto owlEntityDto, String existingProj
201201
callerVersionMatchesLatestVersion(owlEntityDto, existingProjectId, callerHash);
202202
entityIsNotItsOwnParent(owlEntityDto);
203203
linearizationParentsAreOnlyDirectParents(owlEntityDto, existingProjectId);
204-
validatorService.validateOWLEntityDto(owlEntityDto);
204+
validatorService.validateOWLEntityDto(owlEntityDto, existingProjectId);
205205
}
206206

207207
private void callerVersionMatchesLatestVersion(OWLEntityDto owlEntityDto, String existingProjectId, String callerHash) {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,19 @@ CommandExecutor<GetFullPostCoordinationConfigurationRequest, GetFullPostCoordina
183183
return new CommandExecutorImpl<>(GetFullPostCoordinationConfigurationResponse.class);
184184
}
185185

186+
@Bean
187+
CommandExecutor<ValidateEntityUpdateRequest, ValidateEntityUpdateResponse> executorForValidateEntityUpdate() {
188+
return new CommandExecutorImpl<>(ValidateEntityUpdateResponse.class);
189+
}
190+
191+
@Bean
192+
CommandExecutor<CheckNonExistentIrisRequest, CheckNonExistentIrisResponse> executorForCheckNonExistentIris() {
193+
return new CommandExecutorImpl<>(CheckNonExistentIrisResponse.class);
194+
}
195+
196+
@Bean
197+
CommandExecutor<ValidateLogicalDefinitionFromApiRequest, ValidateLogicalDefinitionFromApiResponse> validateLogicalDefinitionsExecutor() {
198+
return new CommandExecutorImpl<>(ValidateLogicalDefinitionFromApiResponse.class);
199+
}
200+
186201
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package edu.stanford.protege.gateway.ontology.commands;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.annotation.JsonTypeName;
5+
import edu.stanford.protege.webprotege.common.ProjectId;
6+
import edu.stanford.protege.webprotege.common.Request;
7+
import org.semanticweb.owlapi.model.IRI;
8+
9+
import java.util.Set;
10+
11+
@JsonTypeName(CheckNonExistentIrisRequest.CHANNEL)
12+
public record CheckNonExistentIrisRequest(
13+
@JsonProperty("projectId") ProjectId projectId,
14+
@JsonProperty("iris") Set<IRI> iris
15+
) implements Request<CheckNonExistentIrisResponse> {
16+
17+
public static final String CHANNEL = "webprotege.entities.CheckNonExistentIris";
18+
19+
@Override
20+
public String getChannel() {
21+
return CHANNEL;
22+
}
23+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package edu.stanford.protege.gateway.ontology.commands;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.annotation.JsonTypeName;
5+
import edu.stanford.protege.webprotege.common.Response;
6+
import org.semanticweb.owlapi.model.IRI;
7+
8+
import java.util.Set;
9+
10+
import static edu.stanford.protege.gateway.ontology.commands.CheckNonExistentIrisRequest.CHANNEL;
11+
12+
@JsonTypeName(CHANNEL)
13+
public record CheckNonExistentIrisResponse(
14+
@JsonProperty("nonExistentIris") Set<IRI> nonExistentIris
15+
) implements Response {
16+
17+
public static CheckNonExistentIrisResponse create(Set<IRI> nonExistentIris) {
18+
return new CheckNonExistentIrisResponse(nonExistentIris);
19+
}
20+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package edu.stanford.protege.gateway.ontology.commands;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.annotation.JsonTypeName;
5+
import edu.stanford.protege.webprotege.common.ProjectId;
6+
import edu.stanford.protege.webprotege.common.Request;
7+
8+
import javax.annotation.Nonnull;
9+
import java.util.List;
10+
11+
@JsonTypeName(ValidateLogicalDefinitionFromApiRequest.CHANNEL)
12+
public record ValidateLogicalDefinitionFromApiRequest(
13+
@JsonProperty("projectId") @Nonnull ProjectId projectId,
14+
@JsonProperty("entityIri") @Nonnull String entityIri,
15+
@JsonProperty("logicalDefinitions") @Nonnull List<LogicalDefinition> logicalDefinitions,
16+
@JsonProperty("necessaryConditions") @Nonnull List<Relationship> necessaryConditions
17+
) implements Request<ValidateLogicalDefinitionFromApiResponse> {
18+
19+
public static final String CHANNEL = "webprotege.icd.ValidateLogicalDefinitionsFromApi";
20+
21+
@Override
22+
public String getChannel() {
23+
return CHANNEL;
24+
}
25+
26+
public record LogicalDefinition(
27+
@JsonProperty("logicalDefinitionSuperclass") @Nonnull String logicalDefinitionSuperclass,
28+
@JsonProperty("relationships") @Nonnull List<Relationship> relationships
29+
) {}
30+
31+
public record Relationship(
32+
@JsonProperty("axis") @Nonnull String axis,
33+
@JsonProperty("filler") @Nonnull String filler
34+
) {}
35+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package edu.stanford.protege.gateway.ontology.commands;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.annotation.JsonTypeName;
5+
import edu.stanford.protege.webprotege.common.Response;
6+
7+
import javax.annotation.Nonnull;
8+
import java.util.List;
9+
10+
import static edu.stanford.protege.gateway.ontology.commands.ValidateLogicalDefinitionFromApiRequest.CHANNEL;
11+
12+
@JsonTypeName(CHANNEL)
13+
public record ValidateLogicalDefinitionFromApiResponse(
14+
@JsonProperty("messages") @Nonnull List<String> messages
15+
) implements Response {
16+
17+
public static ValidateLogicalDefinitionFromApiResponse create(@Nonnull List<String> messages) {
18+
return new ValidateLogicalDefinitionFromApiResponse(messages);
19+
}
20+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ public CompletableFuture<List<EntityPostCoordinationCustomScalesDto>> getEntityC
120120
}
121121

122122
public List<CompletePostCoordinationAxisConfiguration> getAllPostCoordinationAxisConfigs() throws ExecutionException, InterruptedException, TimeoutException {
123-
return entityConfigurationExecutor.execute(new GetFullPostCoordinationConfigurationRequest(), SecurityContextHelper.getExecutionContext()).get(5, TimeUnit.SECONDS).configuration();
123+
return entityConfigurationExecutor.execute(new GetFullPostCoordinationConfigurationRequest(), SecurityContextHelper.getExecutionContext()).get(15, TimeUnit.SECONDS).configuration();
124124
}
125125
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package edu.stanford.protege.gateway.postcoordination.commands;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.annotation.JsonTypeName;
5+
import edu.stanford.protege.webprotege.common.ProjectId;
6+
import edu.stanford.protege.webprotege.common.Request;
7+
8+
@JsonTypeName(ValidateEntityUpdateRequest.CHANNEL)
9+
public record ValidateEntityUpdateRequest(@JsonProperty("projectId")
10+
ProjectId projectId,
11+
@JsonProperty("entityCustomScaleValues")
12+
WhoficCustomScalesValues entityCustomScaleValues,
13+
@JsonProperty("entitySpecification")
14+
WhoficEntityPostCoordinationSpecification entitySpecification) implements Request<ValidateEntityUpdateResponse> {
15+
16+
public final static String CHANNEL = "webprotege.postcoordination.ValidateEntityUpdate";
17+
18+
@Override
19+
public String getChannel() {
20+
return CHANNEL;
21+
}
22+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package edu.stanford.protege.gateway.postcoordination.commands;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.annotation.JsonTypeName;
5+
import edu.stanford.protege.webprotege.common.Response;
6+
7+
import java.util.List;
8+
9+
import static edu.stanford.protege.gateway.postcoordination.commands.ValidateEntityUpdateRequest.CHANNEL;
10+
11+
@JsonTypeName(CHANNEL)
12+
public class ValidateEntityUpdateResponse implements Response {
13+
14+
@JsonProperty("errorMessages")
15+
private final List<String> errorMessages;
16+
17+
public ValidateEntityUpdateResponse() {
18+
this.errorMessages = List.of();
19+
}
20+
21+
public ValidateEntityUpdateResponse(List<String> errorMessages) {
22+
this.errorMessages = errorMessages;
23+
}
24+
25+
public List<String> getErrorMessages() {
26+
return errorMessages;
27+
}
28+
}

0 commit comments

Comments
 (0)