use of org.karnak.backend.model.action.ActionItem 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);
}
}
}
}
}
use of org.karnak.backend.model.action.ActionItem in project karnak by OsiriX-Foundation.
the class ExprAction method Replace.
public ActionItem Replace(String dummyValue) {
ActionItem replace = new Replace("D");
replace.setDummyValue(dummyValue);
return replace;
}
use of org.karnak.backend.model.action.ActionItem in project karnak by OsiriX-Foundation.
the class TagActionMap method get.
public ActionItem get(Integer tag) {
ActionItem action = tagAction.get(tag);
if (action == null) {
for (Map.Entry<String, ActionItem> entry : tagPatternAction.entrySet()) {
String currentTagPattern = entry.getKey();
int patternTag = TagUtils.intFromHexString(currentTagPattern.replace("X", "0"));
int patternMask = TagUtils.intFromHexString(getMask(currentTagPattern));
if ((tag & patternMask) == patternTag) {
return entry.getValue();
}
}
}
return action;
}
use of org.karnak.backend.model.action.ActionItem in project karnak by OsiriX-Foundation.
the class Expression method getAction.
@Override
public ActionItem getAction(Attributes dcm, Attributes dcmCopy, int tag, HMAC hmac) {
if (exceptedTagsAction.get(tag) == null && tagsAction.get(tag) != null) {
final String expr = argumentEntities.get(0).getValue();
final ExprAction exprAction = new ExprAction(tag, dcm.getVR(tag), dcm, dcmCopy);
return (ActionItem) ExpressionResult.get(expr, exprAction, ActionItem.class);
}
return null;
}
Aggregations