001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * <a href="mailto:grenard@nuxeo.com">Guillaume Renard</a> 018 * 019 */ 020 021package org.nuxeo.ecm.platform.routing.core.impl.jsongraph; 022 023import java.util.Locale; 024 025import org.nuxeo.ecm.platform.routing.core.impl.GraphNode; 026 027/** 028 * @since 7.2 029 */ 030public class NodeView { 031 032 public int x; 033 034 public int y; 035 036 public boolean isStartNode; 037 038 public boolean isEndNode; 039 040 public String id; 041 042 public String title; 043 044 public String state; 045 046 public boolean isMerge; 047 048 public boolean isMultiTask; 049 050 public boolean hasSubWorkflow; 051 052 public NodeView(GraphNode node, Locale locale) { 053 this.x = Integer.parseInt((String) node.getDocument().getPropertyValue(GraphNode.PROP_NODE_X_COORDINATE)); 054 this.y = Integer.parseInt((String) node.getDocument().getPropertyValue(GraphNode.PROP_NODE_Y_COORDINATE)); 055 this.isStartNode = node.isStart(); 056 this.isEndNode = node.isStop(); 057 this.id = node.getId(); 058 String titleProp = (String) node.getDocument().getPropertyValue(GraphNode.PROP_TITLE); 059 this.title = JsonGraphRoute.getI18nLabel(titleProp, locale); 060 this.state = node.getDocument().getCurrentLifeCycleState(); 061 this.isMerge = node.isMerge(); 062 this.isMultiTask = node.hasMultipleTasks(); 063 this.hasSubWorkflow = node.hasSubRoute(); 064 } 065 066 public String getId() { 067 return id; 068 } 069 070 public String getState() { 071 return state; 072 } 073 074 public String getTitle() { 075 return title; 076 } 077 078 public int getX() { 079 return x; 080 } 081 082 public int getY() { 083 return y; 084 } 085 086 public boolean isEndNode() { 087 return isEndNode; 088 } 089 090 public boolean isStartNode() { 091 return isStartNode; 092 } 093}