use of org.karnak.backend.model.action.ReplaceNull in project karnak by OsiriX-Foundation.
the class Profile method applyAction.
public void applyAction(Attributes dcm, Attributes dcmCopy, HMAC hmac, ProfileItem profilePassedInSequence, ActionItem actionPassedInSequence, AttributeEditorContext context) {
for (int tag : dcm.tags()) {
VR vr = dcm.getVR(tag);
final ExprCondition exprCondition = new ExprCondition(dcmCopy);
ActionItem currentAction = null;
ProfileItem currentProfile = null;
for (ProfileItem profileEntity : profiles.stream().filter(p -> !(p instanceof CleanPixelData)).collect(Collectors.toList())) {
currentProfile = profileEntity;
if (profileEntity.getCondition() == null || profileEntity.getCodeName().equals(ProfileItemType.DEFACING.getClassAlias()) || profileEntity.getCodeName().equals(ProfileItemType.CLEAN_PIXEL_DATA.getClassAlias())) {
currentAction = profileEntity.getAction(dcm, dcmCopy, tag, hmac);
} else {
boolean conditionIsOk = (Boolean) ExpressionResult.get(profileEntity.getCondition(), exprCondition, Boolean.class);
if (conditionIsOk) {
currentAction = profileEntity.getAction(dcm, dcmCopy, tag, hmac);
}
}
if (currentAction != null) {
break;
}
if (profileEntity.equals(profilePassedInSequence)) {
currentAction = actionPassedInSequence;
break;
}
}
if (!(currentAction instanceof Remove) && !(currentAction instanceof ReplaceNull) && vr == VR.SQ) {
final ProfileItem finalCurrentProfile = currentProfile;
final ActionItem finalCurrentAction = currentAction;
Sequence seq = dcm.getSequence(tag);
if (seq != null) {
for (Attributes d : seq) {
applyAction(d, dcmCopy, hmac, finalCurrentProfile, finalCurrentAction, context);
}
}
} else {
if (currentAction != null) {
try {
currentAction.execute(dcm, tag, hmac);
} catch (final Exception e) {
LOGGER.error("Cannot execute the currentAction {} for tag: {}", currentAction, TagUtils.toString(tag), e);
}
}
}
}
}
Aggregations