Skip to content

Commit

Permalink
Fix problems caused by unmanaged references when updating fault event
Browse files Browse the repository at this point in the history
  • Loading branch information
kostobog committed Jun 19, 2024
1 parent c429910 commit 75e0b08
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/cz/cvut/kbss/analysis/model/FaultEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static FaultEvent create(){
private Double probability;

@OWLObjectProperty(iri = Vocabulary.s_p_has_selected_estimation, fetch = FetchType.EAGER)
private FailureRateEstimate selectedEstimate;
private URI selectedEstimate;

@OWLObjectProperty(iri = Vocabulary.s_p_has_child, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Set<FaultEvent> children = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import org.springframework.validation.Validator;

import java.net.URI;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
Expand Down Expand Up @@ -171,6 +168,26 @@ public void updateChildrenSequence(URI faultEventUri, List<URI> childrenSequence
log.info("< updateChildrenSequence");
}

@Transactional
@Override
public FaultEvent update(FaultEvent instance) {
Objects.requireNonNull(instance);
preUpdate(instance);
FaultEvent managedInstance = faultEventDao.find(instance.getUri()).orElse( null);
assert managedInstance != null;
managedInstance.setName(instance.getName());
managedInstance.setGateType(instance.getGateType());
managedInstance.setEventType(instance.getEventType());
managedInstance.setProbability(instance.getProbability());
managedInstance.setSupertypes(instance.getSupertypes());
managedInstance.setChildrenSequence(instance.getChildrenSequence());
managedInstance.setSelectedEstimate(instance.getSelectedEstimate());
faultEventDao.getContext(managedInstance);
faultEventDao.update(managedInstance);
postUpdate(managedInstance);
return managedInstance;
}

@Override
protected void preUpdate(FaultEvent instance) {
if(instance.getSupertypes() != null && !instance.getSupertypes().isEmpty())
Expand Down

0 comments on commit 75e0b08

Please sign in to comment.