wocommunity / wolips

wolips
53 stars 53 forks source link

InPlace RuleEditor stores assignment class in the wrong place #132

Closed NochEinKamel closed 2 years ago

NochEinKamel commented 7 years ago

We had a fun little 2 hour excursion into rulesets today because one of our team members is using the inplace RuleEditor in eclipse (on linux, no standalone available) and added two rules using BooleanAssignments.

Apparently, if you edit this Class-field image

the resulting .d2wmodel file is written like this which is not correct. image

The outer class always needs to be com.webobjects.directtoweb.Rule and the ...BooleanAssignment should only be written into the rhs part of the plist.

The inplace editor will still open the file but WO won't load the ruleset and the standalone editor crashes on load.

I think the error is in the RuleEditor.java file:

wrong:

void setClassName(final String classname) {
    rule.setAssignmentClassName(classname);

    updateRules();
}

correct:

void setClassName(final String classname) {
    RightHandSide rhs = rule.getRightHandSide();
    rhs.setAssignmentClassName(classname);

    updateRules();
}

But I can't test/fix it :-/

nullterminated commented 2 years ago

I'm pretty sure the in place rule editor never actually worked. I believe I've got it fixed up enough to actually use now without butchering your rule files. Changes include fixing this bug (thanks for reporting), making rules save on a single line for easy git diffing, writing rules to a d2wmodel.txt file as well as rule model file, support for key comparison qualifiers on the LHS, custom selectors with the "key selector: value" format, sorting saved rules by priority, and fixing the priority sorting in the UI.

It still lacks support for rule model groups, there's no checkbox for disabling rules (disabled rules display a RuleIsDisabled = 'YES' in the LHS qualifier), there's still no file association for d2wmodel files, and there's not a nice combo box on the editor like there is on the cocoa version.

But it seems like it should now be usable at least. There's some minor formatting differences on LHS qualifiers, where something like

smartRelationship.isToMany = '1'

becomes

smartRelationship.isToMany = 1

but these look harmless. Since the thing never really worked in the first place, I went ahead and pushed my changes. Hopefully this makes it a little nicer for everyone.