Skip to content

Commit

Permalink
Merge pull request #59 from protegeproject/28-if-user-creates-a-new-e…
Browse files Browse the repository at this point in the history
…ntity-with-the-same-name-as-an-existing-entity-all-the-linearizations-will-be-set-to-default

Fix for CreateClassesFromApiAction
  • Loading branch information
alexsilaghi authored Nov 26, 2024
2 parents 3eeebaa + a2d4aef commit 817f818
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package edu.stanford.protege.webprotege.icd.actions;

import com.fasterxml.jackson.annotation.*;
import com.google.common.collect.ImmutableSet;
import edu.stanford.protege.webprotege.common.*;
import edu.stanford.protege.webprotege.dispatch.ProjectAction;

Expand All @@ -14,7 +13,7 @@ public record CreateClassesFromApiAction(@JsonProperty("changeRequestId") Change
@JsonProperty("projectId") ProjectId projectId,
@JsonProperty("sourceText") String sourceText,
@JsonProperty("langTag") @Nullable String langTag,
@JsonProperty("parent") ImmutableSet<String> parent) implements ProjectAction<CreateClassesFromApiResult> {
@JsonProperty("parent") String parent) implements ProjectAction<CreateClassesFromApiResult> {
public static final String CHANNEL = "icatx.webprotege.entities.CreateClassesFromApi";

public String getChannel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import javax.inject.Inject;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
Expand Down Expand Up @@ -70,16 +69,14 @@ protected List<BuiltInAction> getRequiredExecutableBuiltInActions(CreateClassesF

@Override
protected ChangeListGenerator<Set<OWLClass>> getChangeListGenerator(CreateClassesFromApiAction action, ExecutionContext executionContext) {
var owlClassParents = action.parent().stream()
.map(DataFactory::getOWLClass)
.collect(ImmutableSet.toImmutableSet());
var owlClassParent = DataFactory.getOWLClass(action.parent());
var language = action.langTag();
if (language == null || language.isEmpty()) {
language = projectDetailsManager.getProjectSettings(action.projectId()).getDefaultLanguage().getLang();
}
return changeGeneratorFactory.create(action.sourceText(),
language,
owlClassParents,
ImmutableSet.of(owlClassParent),
action.changeRequestId());
}

Expand All @@ -92,19 +89,19 @@ protected CreateClassesFromApiResult createActionResult(ChangeApplicationResult<
classes.forEach(newClass ->
{
try {
linearizationManager.mergeLinearizationsFromParents(
linearizationManager.createLinearizationFromParent(
newClass.getIRI(),
action.parent().stream().map(IRI::create).collect(Collectors.toSet()),
IRI.create(action.parent()),
action.projectId(),
executionContext
).get();
} catch (InterruptedException | ExecutionException e) {
logger.error("MergeLinearizationsError: " + e);
logger.error("CreateLinearizationsError: " + e);
}
try {
postcoordinationManager.createPostcoordinationFromParent(
newClass.getIRI(),
IRI.create(action.parent().stream().findFirst().get()),
IRI.create(action.parent()),
action.projectId(),
executionContext
).get();
Expand Down

0 comments on commit 817f818

Please sign in to comment.