Skip to content
Jinyoung Jang edited this page Oct 11, 2016 · 2 revisions

Validation Framework

Modeler 에서의 표시

PropertySettingDialog.java


package org.uengine.modeling;

...
public class PropertySettingDialog extends ModalWindow{


    public PropertySettingDialog(ElementView elementView){
        setElementView(elementView);

...
        setPanel(element);

        if(element instanceof Validatable){   // validation panel 의 구성
            ValidationContext validationContext = ((Validatable) element).validate(new HashMap());

            List<LeveledException> exceptions = new ArrayList<LeveledException>();

            if(validationContext.size() > 0){

                exceptions.addAll(validationContext);

                setValidationPanel(new ValidationPanel());

                getValidationPanel().setExceptions(exceptions);
            }

        }

    }

    ValidationPanel validationPanel;
        public ValidationPanel getValidationPanel() {
            return validationPanel;
        }
        public void setValidationPanel(ValidationPanel validationPanel) {
            this.validationPanel = validationPanel;
        }


    // Key Unbinding. Because protect Unwanted Action When set Properties,
    @ServiceMethod(payload={"panel", "elementView"}, target= ServiceMethodContext.TARGET_APPEND/*, validate = true, keyBinding = "Enter"*/)
    public Object apply(){
        IElement element = (IElement)getPanel();

        if(element instanceof IModelingTimeSensitive){
            ((IModelingTimeSensitive) element).afterModelingTime();
        }

        getElementView().setElement(element);

        if(element instanceof Validatable){
            ValidationContext vc = ((Validatable) element).validate(new HashMap());

             /// 오류 마커의 표시를 유도함 :  setIntegrity(1)
            if(element instanceof IIntegrityElement) {
                if (vc.size() > 0) {
                    ((IIntegrityElement)element).setIntegrity(1);
                } else {
                    ((IIntegrityElement)element).setIntegrity(0);
                }
            }
        }

...
        return new Object[]{new Remover(new PropertySettingDialog()), new Refresh(getElementView(), true)};

    }

}


오류 마커의 표시: ActivityView.ejs.js


var org_uengine_kernel_view_ActivityView = function(objectId, className){

	org_uengine_modeling_ElementView.apply(this, new Array(objectId, className));

	var modeler = mw3.getAutowiredObject('org.uengine.modeling.Modeler');
	this.object.element.tracingTag = modeler.getFaceHelper().getTracingTag();


	// draw markers and badges
	{
		var me = this.canvas._RENDERER, rElement = me._getREleById(OG.Util.isElement(this.element) ? this.element.id : this.element),
			geometry = rElement ? rElement.node.shape.geom : null,
			envelope, _upperLeft, _bBoxRect, _rect, _rect1,
			_size = me._CONFIG.COLLAPSE_SIZE,
			_hSize = _size / 2;

		....

		//draw validation error image
		{
			var badge_suffix = "_ValidErr";

			_rect1 = me._getREleById(rElement.id + badge_suffix);
			if (_rect1) {
				me._remove(_rect1);
			}

			if(this.object.element.integrity){


				envelope = geometry.getBoundary();
				var position = envelope.getUpperRight();

				_rect1 = me._PAPER.image("images/opengraph/fail.png", position.x - 25, position.y + 5, 20, 20);

				me._add(_rect1, rElement.id + badge_suffix);
				_rect1.insertAfter(rElement);
				rElement.appendChild(_rect1);
			}
		}
	}
...

Related Implementations

  1. https://github.com/TheOpenCloudEngine/uengine-bpm/commit/043f831f30eb8344c767953f36f66ccc519623f8