RuleNode.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * Created by jacky on 2016/7/18.
  3. */
  4. import ruleSVG from './svg/rule.svg';
  5. import BaseNode from './BaseNode.js';
  6. export default class RuleNode extends BaseNode{
  7. getSvgIcon(){
  8. return ruleSVG;
  9. }
  10. toXML(){
  11. const json=this.toJSON();
  12. json.type="RuleNode";
  13. const nodeName=this.getNodeName(json.type);
  14. const nodeProps=this.getXMLNodeBaseProps(json);
  15. let xml=`<${nodeName} ${nodeProps} file="${this.file}" version="${this.version}">`;
  16. xml+=this.getFromConnectionsXML();
  17. xml+=`</${nodeName}>`;
  18. return xml;
  19. }
  20. initFromJson(json){
  21. super.initFromJson(json);
  22. this.file=json.file;
  23. this.version=json.version;
  24. }
  25. validate(){
  26. let errorInfo=super.validate();
  27. if(errorInfo)return errorInfo;
  28. if(!this.file){
  29. errorInfo=`节点${this.name}的文件属性不能为空`;
  30. return errorInfo;
  31. }
  32. if(!this.version){
  33. errorInfo=`节点${this.version}的版本属性不能为空`;
  34. }
  35. return errorInfo;
  36. }
  37. }