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 isForkNode;
037
038    public boolean isStartNode;
039
040    public boolean isEndNode;
041
042    public String id;
043
044    public String title;
045
046    public String state;
047
048    public boolean isMerge;
049
050    public boolean isMultiTask;
051
052    public boolean hasSubWorkflow;
053
054    public NodeView(GraphNode node, Locale locale) {
055        this.x = Integer.parseInt((String) node.getDocument().getPropertyValue(GraphNode.PROP_NODE_X_COORDINATE));
056        this.y = Integer.parseInt((String) node.getDocument().getPropertyValue(GraphNode.PROP_NODE_Y_COORDINATE));
057        this.isForkNode = node.isFork();
058        this.isStartNode = node.isStart();
059        this.isEndNode = node.isStop();
060        this.id = node.getId();
061        String titleProp = (String) node.getDocument().getPropertyValue(GraphNode.PROP_TITLE);
062        this.title = JsonGraphRoute.getI18nLabel(titleProp, locale);
063        this.state = node.getDocument().getCurrentLifeCycleState();
064        this.isMerge = node.isMerge();
065        this.isMultiTask = node.hasMultipleTasks();
066        this.hasSubWorkflow = node.hasSubRoute();
067    }
068
069    public String getId() {
070        return id;
071    }
072
073    public String getState() {
074        return state;
075    }
076
077    public String getTitle() {
078        return title;
079    }
080
081    public int getX() {
082        return x;
083    }
084
085    public int getY() {
086        return y;
087    }
088
089    public boolean isEndNode() {
090        return isEndNode;
091    }
092
093    /**
094     * @since 11.1
095     */
096    public boolean isForkNode() {
097        return isForkNode;
098    }
099
100    public boolean isStartNode() {
101        return isStartNode;
102    }
103}