diff options
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle')
66 files changed, 0 insertions, 7983 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/ActivityDef.java b/src/main/java/com/c2kernel/lifecycle/ActivityDef.java deleted file mode 100644 index d783534..0000000 --- a/src/main/java/com/c2kernel/lifecycle/ActivityDef.java +++ /dev/null @@ -1,162 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-import java.util.Vector;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.lifecycle.instance.Activity;
-import com.c2kernel.lifecycle.instance.WfVertex;
-import com.c2kernel.utils.DescriptionObject;
-import com.c2kernel.utils.FileStringUtility;
-/**
- * @version $Revision: 1.45 $ $Date: 2005/10/05 07:39:36 $
- * @author $Author: abranson $
- */
-public class ActivityDef extends WfVertexDef implements C2KLocalObject, DescriptionObject
-{
- private int mId = -1;
- private String mName = "";
- private int mVersion = -1;
- public boolean changed = false;
- /**
- * @see java.lang.Object#Object()
- */
- public ActivityDef()
- {
- mErrors = new Vector<String>(0, 1);
- setProperties(new WfCastorHashMap());
- setIsLayoutable(false);
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#setID(int)
- */
- @Override
- public void setID(int id)
- {
- mId = id;
- if (mName.equals(""))
- setName(String.valueOf(id));
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#getID()
- */
- @Override
- public int getID()
- {
- return mId;
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#setName(java.lang.String)
- */
- @Override
- public void setName(String n)
- {
- mName = n;
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#getName()
- */
- @Override
- public String getName()
- {
- return mName;
- }
-
- @Override
- public void setVersion(int v)
- {
- mVersion = v;
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#getName()
- */
- @Override
- public int getVersion()
- {
- return mVersion;
- }
- /**
- * @see com.c2kernel.lifecycle.WfVertexDef#getErrors()
- */
- @Override
- public String getErrors()
- {
- return super.getErrors();
- }
- /**
- * Method linkToSlot.
- *
- * @param actSl
- * @param name
- */
- public void linkToSlot(ActivitySlotDef actSl, String name, String name2)
- {
- actSl.setActivityDef(FileStringUtility.convert(name));
- actSl.getProperties().put("Name", name2.replace('/', '_'));
- actSl.setName(name+" slot");
- setName(FileStringUtility.convert(name));
- }
- /**
- * @see com.c2kernel.lifecycle.WfVertexDef#verify()
- */
- @Override
- public boolean verify()
- {
- return true;
- }
- /**
- * @see com.c2kernel.entity.C2KLocalObject#getClusterType()
- */
- @Override
- public String getClusterType()
- {
- return null;
- }
- public String getActName()
- {
- return getName();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.c2kernel.lifecycle.commonInterface.ActType#getDescName()
- */
- public String getDescName()
- {
- return getName();
- }
-
- @Override
- public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException{
- return instantiate(getName());
- }
- public WfVertex instantiate(String name) throws ObjectNotFoundException, InvalidDataException
- {
- Activity act = new Activity();
- configureInstance(act);
- act.setName(name);
- act.setType(getName());
- return act;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java b/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java deleted file mode 100644 index 07a2867..0000000 --- a/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java +++ /dev/null @@ -1,200 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.graph.traversal.GraphTraversal;
-import com.c2kernel.lifecycle.instance.Activity;
-import com.c2kernel.lifecycle.instance.WfVertex;
-import com.c2kernel.utils.KeyValuePair;
-import com.c2kernel.utils.LocalObjectLoader;
-/**
- * @version $Revision: 1.46 $ $Date: 2005/10/05 07:39:36 $
- * @author $Author: abranson $
- */
-public class ActivitySlotDef extends WfVertexDef
-{
- private String activityDef;
-
- /**
- * Method setActivityDef.
- *
- * @param oActivityDef
- */
- public void setActivityDef(String oActivityDef)
- {
- activityDef = oActivityDef;
- }
- /**
- * Method getActivityDef.
- *
- * @return String
- */
- public String getActivityDef()
- {
- return activityDef;
- }
- /**
- * @see java.lang.Object#Object()
- */
- public ActivitySlotDef()
- {
- getProperties().put("Name", "");
- getProperties().put("Version", 0);
- }
-
- public ActivityDef getTheActivityDef() throws ObjectNotFoundException, InvalidDataException
- {
- ActivityDef actDef = LocalObjectLoader.getActDef(getActivityDef(), getVersionNumberProperty("Version"));
- if (actDef instanceof CompositeActivityDef)
- mIsComposite = true;
- return actDef;
- }
- /**
- * @see com.c2kernel.lifecycle.WfVertexDef#verify()
- */
- /** launch the verification of the ActivityDef */
- @Override
- public boolean verify()
- {
- mErrors.removeAllElements();
- boolean err = true;
- int nbInEdgres = getInEdges().length;
- int nbOutEdges = getOutEdges().length;
- if (nbInEdgres == 0 && this.getID() != getParent().getChildrenGraphModel().getStartVertexId())
- {
- mErrors.add("Unreachable");
- err = false;
- }
- if (nbInEdgres > 1)
- {
- mErrors.add("Bad nb of previous");
- err = false;
- }
- if (nbOutEdges > 1)
- {
- mErrors.add("too many next");
- err = false;
- }
- if (nbOutEdges == 0)
- {
- if (!((CompositeActivityDef) getParent()).hasGoodNumberOfActivity())
- {
- mErrors.add("too many endpoints");
- err = false;
- }
- }
-
- Vertex[] allSiblings = getParent().getChildGraphModel().getVertices();
- String thisName = (String)getProperties().get("Name");
- if (thisName == null || thisName.length()==0) mErrors.add("Slot name is empty");
- else for (Vertex v : allSiblings) {
- if (v instanceof ActivitySlotDef && v.getID()!=getID()) {
- ActivitySlotDef otherSlot = (ActivitySlotDef)v;
- String otherName = (String)otherSlot.getProperties().get("Name");
- if (otherName != null && otherName.equals(thisName)) {
- mErrors.add("Duplicate slot name");
- err = false;
- }
- }
- }
-
- KeyValuePair[] props;
- try {
- props = getTheActivityDef().getProperties().getKeyValuePairs();
- for (KeyValuePair prop : props) {
- if (prop.isAbstract() && !getProperties().containsKey(prop.getKey())) {
- mErrors.add("Abstract property '"+prop.getKey()+"' not defined in slot");
- err = false;
- }
- }
- } catch (Exception ex) { }
-
-
- // Loop check
- Vertex[] outV = getOutGraphables();
- Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
- boolean errInLoop = false;
- for (Vertex element : outV) {
- for (Vertex anteVertice : anteVertices)
- if (!loop() && element.getID() == anteVertice.getID())
- errInLoop = true;
- }
- if (errInLoop)
- {
- mErrors.add("Problem in Loop");
- err = false;
- }
- return err;
- }
- /**
- * Method getNextWfVertices.
- *
- * @return WfVertexDef[]
- */
- public WfVertexDef[] getNextWfVertices()
- {
- return (WfVertexDef[]) getOutGraphables();
- }
- /**
- * @see com.c2kernel.graph.model.GraphableVertex#isLayoutable()
- */
- /**
- * @see com.c2kernel.graph.model.GraphableVertex#getIsLayoutable()
- */
- public boolean isLayoutable()
- {
- return true;
- }
- /**
- * Method getInfo.
- *
- * @return CastorHashMap
- */
- private void configureInstance(Activity act)
- {
- KeyValuePair[] k = getProperties().getKeyValuePairs();
- for (KeyValuePair element : k)
- act.getProperties().put(element.getKey(), element.getValue(), element.isAbstract());
- act.setCentrePoint(getCentrePoint());
- act.setOutlinePoints(getOutlinePoints());
- act.setInEdgeIds(getInEdgeIds());
- act.setOutEdgeIds(getOutEdgeIds());
- act.setName(getActName());
- act.setID(getID());
- }
-
- public String getActName()
- {
- return (String) getProperties().get("Name");
- }
-
- @Override
- public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException {
- Activity newActivity = (Activity)getTheActivityDef().instantiate();
- configureInstance(newActivity);
- if (newActivity.getProperties().getAbstract().size() > 0) {
- throw new InvalidDataException("Abstract properties not overridden: "+newActivity.getProperties().getAbstract().toString());
- }
- return newActivity;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/AndSplitDef.java b/src/main/java/com/c2kernel/lifecycle/AndSplitDef.java deleted file mode 100644 index fc653e8..0000000 --- a/src/main/java/com/c2kernel/lifecycle/AndSplitDef.java +++ /dev/null @@ -1,134 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-
-import java.util.Vector;
-
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.graph.traversal.GraphTraversal;
-import com.c2kernel.lifecycle.instance.AndSplit;
-import com.c2kernel.lifecycle.instance.WfVertex;
-/**
- * @version $Revision: 1.19 $ $Date: 2005/09/29 10:18:31 $
- * @author $Author: abranson $
- */
-
-public class AndSplitDef extends WfVertexDef
-{
- /**
- * @see java.lang.Object#Object()
- */
- public AndSplitDef()
- {
- mErrors = new Vector<String>(0, 1);
- getProperties().put("RoutingScriptName", "");
- getProperties().put("RoutingScriptVersion", "");
- }
-
- /**
- * @see com.c2kernel.lifecycle.WfVertexDef#verify()
- */
- @Override
- public boolean verify()
- {
- mErrors.removeAllElements();
- boolean err = true;
- int nbInEdges = getInEdges().length;
- if (nbInEdges == 0 && this.getID() != getParent().getChildrenGraphModel().getStartVertexId())
- {
- mErrors.add("Unreachable");
- err = false;
- }
- else if (nbInEdges > 1)
- {
- mErrors.add("Bad nb of previous");
- err = false;
- }
- else
- {
- if (getOutEdges().length <= 1)
- {
- mErrors.add("not enough next");
- err = false;
- }
- else if (!(this instanceof LoopDef))
- {
- Vertex[] outV = getOutGraphables();
- Vertex[] anteVertices =
- GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
- boolean loop = false;
- boolean errInLoop = true;
- for (int i = 0; i < outV.length; i++)
- {
- for (int j = 0; j < anteVertices.length; j++)
- if (!loop && outV[i].getID() == anteVertices[j].getID())
- {
- if (outV[i] instanceof LoopDef)
- {
- loop = true;
- j = anteVertices.length;
- i = outV.length;
- }
- else
- {
- errInLoop = false;
- }
- }
- }
- if (errInLoop && loop)
- {
- mErrors.add("Problem in Loop");
- err = false;
- }
- }
- }
- return err;
- }
-
- @Override
- public boolean loop()
- {
- boolean loop2 = false;
- if (!loopTested)
- {
- loopTested = true;
- if (getOutGraphables().length != 0)
- {
- Vertex[] outVertices = getOutGraphables();
- for (int i = 0; i < outVertices.length; i++)
- {
- WfVertexDef tmp = (WfVertexDef) getOutGraphables()[i];
- loop2 = loop2 || tmp.loop();
- }
- }
- }
- loopTested = false;
- return loop2;
- }
-
- @Override
- public WfVertex instantiate() {
- AndSplit newSplit = new AndSplit();
- configureInstance(newSplit);
- return newSplit;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java b/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java deleted file mode 100644 index c48595f..0000000 --- a/src/main/java/com/c2kernel/lifecycle/CompositeActivityDef.java +++ /dev/null @@ -1,265 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.graph.model.GraphModel;
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.graph.model.GraphableVertex;
-import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
-import com.c2kernel.lifecycle.instance.CompositeActivity;
-import com.c2kernel.lifecycle.instance.Next;
-import com.c2kernel.lifecycle.instance.WfVertex;
-import com.c2kernel.utils.Language;
-import com.c2kernel.utils.Logger;
-/**
- * @version $Revision: 1.93 $ $Date: 2005/10/05 07:39:36 $
- * @author $Author: abranson $
- */
-public class CompositeActivityDef extends ActivityDef
-{
- private final TypeNameAndConstructionInfo[] mVertexTypeNameAndConstructionInfo =
- {
- new TypeNameAndConstructionInfo(Language.translate("Activity"), "Atomic"),
- new TypeNameAndConstructionInfo(Language.translate("Composite"), "Composite"),
- new TypeNameAndConstructionInfo(Language.translate("AND Split"), "And"),
- new TypeNameAndConstructionInfo(Language.translate("OR Split"), "Or"),
- new TypeNameAndConstructionInfo(Language.translate("XOR Split"), "XOr"),
- new TypeNameAndConstructionInfo(Language.translate("Join"), "Join"),
- new TypeNameAndConstructionInfo(Language.translate("Loop"), "Loop"),
- };
- private final TypeNameAndConstructionInfo[] mEdgeTypeNameAndConstructionInfo =
- {
- new TypeNameAndConstructionInfo(Language.translate("Next Edge"), "Next")
- };
- public TypeNameAndConstructionInfo[] getVertexTypeNameAndConstructionInfo()
- {
- return mVertexTypeNameAndConstructionInfo;
- }
- public TypeNameAndConstructionInfo[] getEdgeTypeNameAndConstructionInfo()
- {
- return mEdgeTypeNameAndConstructionInfo;
- }
-
- public CompositeActivityDef()
- {
- super();
- setChildrenGraphModel(new GraphModel(new WfVertexDefOutlineCreator()));
- setIsComposite(true);
- }
-
- /**
- * Method addNextDef.
- *
- * @param origin
- * @param terminus
- * @return NextDef
- */
- public NextDef addNextDef(WfVertexDef origin, WfVertexDef terminus)
- {
- NextDef returnNxt = new NextDef(origin, terminus);
- getChildrenGraphModel().addEdgeAndCreateId(returnNxt, origin, terminus);
- return returnNxt;
- }
- /**
- * Method addExistingActivityDef.
- *
- * @param actDef
- * @param point
- */
- public ActivitySlotDef addExistingActivityDef(String name, ActivityDef actDef, GraphPoint point)
- {
- changed = true;
- ActivitySlotDef child = new ActivitySlotDef();
- addChild(child, point);
- actDef.linkToSlot(child, actDef.getName(), name);
- return child;
- }
- /**
- * Method newChild.
- *
- * @param Name
- * @param Type
- * @param location
- * @return WfVertexDef
- */
- public WfVertexDef newChild(String Name, String Type, GraphPoint location)
- {
- changed = true;
- WfVertexDef child;
- if (Type.equals("Or"))
- {
- child = new OrSplitDef();
- addChild(child, location);
- Logger.msg(5, Type + " " + child.getID() + " added to " + this.getID());
- }
- else if (Type.equals("XOr"))
- {
- child = new XOrSplitDef();
- addChild(child, location);
- Logger.msg(5, Type + " " + child.getID() + " added to " + this.getID());
- }
- else if (Type.equals("And"))
- {
- child = new AndSplitDef();
- addChild(child, location);
- Logger.msg(5, Type + " " + child.getID() + " added to " + this.getID());
- }
- else if (Type.equals("Loop"))
- {
- child = new LoopDef();
- addChild(child, location);
- Logger.msg(5, Type + " " + child.getID() + " added to " + this.getID());
- }
- else if (Type.equals("Atomic"))
- {
- child = new ActivitySlotDef();
- ActivityDef act = new ActivityDef();
- act.changed = true;
- addChild(child, location);
- act.linkToSlot((ActivitySlotDef) child, Name, Name);
- act.getProperties().put("Description", Name);
- Logger.msg(5, Type + " " + child.getID() + " added to " + this.getID());
- }
- else if (Type.equals("Join"))
- {
- child = new JoinDef();
- child.getProperties().put("Type", "Join");
- addChild(child, location);
- Logger.msg(5, Type + " " + child.getID() + " added to " + this.getID());
- }
- else if (Type.equals("Route"))
- {
- child = new JoinDef();
- child.getProperties().put("Type", "Route");
- addChild(child, location);
- Logger.msg(5, Type + " " + child.getID() + " added to " + this.getID());
- }
- else
- {
- child = new ActivitySlotDef();
- CompositeActivityDef act = new CompositeActivityDef();
- act.changed = true;
- addChild(child, location);
- act.linkToSlot((ActivitySlotDef) child, Name, Name);
- Logger.msg(5, Type + " " + child.getID() + " added to " + this.getID());
- }
- return child;
- }
- /**
- * Method instantiateAct.
- *
- * @return CompositeActivity
- */
- @Override
- public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException {
- return instantiate(getName());
- }
-
- @Override
- public WfVertex instantiate(String name) throws ObjectNotFoundException, InvalidDataException
- {
- CompositeActivity cAct = new CompositeActivity();
- configureInstance(cAct);
- cAct.setType(getName());
- cAct.setName(name);
- GraphableVertex[] vertexDefs = getLayoutableChildren();
- WfVertex[] wfVertices = new WfVertex[vertexDefs.length];
- for (int i = 0; i < vertexDefs.length; i++)
- {
- WfVertexDef vertDef = (WfVertexDef)vertexDefs[i];
- wfVertices[i] = vertDef.instantiate();
- wfVertices[i].setParent(cAct);
- }
- Next[] nexts = new Next[getChildrenGraphModel().getEdges().length];
- for (int i = 0; i < getChildrenGraphModel().getEdges().length; i++)
- {
- NextDef nextDef = (NextDef) getChildrenGraphModel().getEdges()[i];
- nexts[i] = nextDef.instantiate();
- nexts[i].setParent(cAct);
- }
- cAct.getChildrenGraphModel().setStartVertexId(getChildrenGraphModel().getStartVertexId());
- cAct.getChildrenGraphModel().setEdges(nexts);
- cAct.getChildrenGraphModel().setVertices(wfVertices);
- cAct.getChildrenGraphModel().setNextId(getChildrenGraphModel().getNextId());
- cAct.getChildrenGraphModel().resetVertexOutlines();
- return cAct;
- }
-
- /**
- * Method hasGoodNumberOfActivity.
- *
- * @return boolean
- */
-
- public boolean hasGoodNumberOfActivity()
- {
- int endingAct = 0;
- GraphableVertex[] graphableVertices = this.getLayoutableChildren();
- if (graphableVertices != null)
- for (GraphableVertex graphableVertice : graphableVertices) {
- WfVertexDef vertex = (WfVertexDef) graphableVertice;
- if (getChildrenGraphModel().getOutEdges(vertex).length == 0)
- endingAct++;
- }
- if (endingAct > 1)
- return false;
- return true;
- }
-
- /**
- * @see com.c2kernel.graph.model.GraphableVertex#getPath()
- */
- @Override
- public String getPath()
- {
- if (getParent() == null)
- return getName();
- return super.getPath();
- }
- @Override
- public void setChildrenGraphModel(GraphModel childrenGraph) {
- super.setChildrenGraphModel(childrenGraph);
- childrenGraph.setVertexOutlineCreator(new WfVertexDefOutlineCreator());
- }
- //deprecated
- public String[] getCastorNonLayoutableChildren() {
- return new String[0];
- }
-
- public void setCastorNonLayoutableChildren(String[] dummy) { }
-
- @Override
- public boolean verify() {
- boolean err = super.verify();
- GraphableVertex[] vChildren = getChildren();
- for (int i = 0; i < vChildren.length; i++)
- {
- WfVertexDef wfvChild = (WfVertexDef)vChildren[i];
- if (!(wfvChild.verify()))
- {
- mErrors.add(wfvChild.getName()+": "+wfvChild.getErrors());
- err = false;
- }
- }
- return err;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/JoinDef.java b/src/main/java/com/c2kernel/lifecycle/JoinDef.java deleted file mode 100644 index fcc5bab..0000000 --- a/src/main/java/com/c2kernel/lifecycle/JoinDef.java +++ /dev/null @@ -1,88 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-
-import com.c2kernel.lifecycle.instance.Join;
-import com.c2kernel.lifecycle.instance.WfVertex;
-
-/**
- * @version $Revision: 1.18 $ $Date: 2005/09/29 10:18:31 $
- * @author $Author: abranson $
- */
-public class JoinDef extends WfVertexDef
-{
- /**
- * @see java.lang.Object#Object()
- */
- public JoinDef()
- {
- }
- /**
- * @see com.c2kernel.lifecycle.WfVertexDef#verify()
- */
- @Override
- public boolean verify()
- {
- mErrors.removeAllElements();
- int nbOutEdges = getOutEdges().length;
- int nbInEdges = getInEdges().length;
- String type = (String) getProperties().get("Type");
- if (nbInEdges < 1)
- {
- mErrors.add("not enough previous");
- return false;
- }
- if (type != null && type.equals("Route"))
- {
- if (nbInEdges > 1)
- {
- mErrors.add("Bad nb of previous");
- return false;
- }
- }
- if (nbOutEdges > 1)
- {
- mErrors.add("too many next");
- return false;
- }
- if (nbOutEdges == 0)
- {
- if (!((CompositeActivityDef) getParent()).hasGoodNumberOfActivity())
- {
- mErrors.add("too many endpoints");
- return false;
- }
- }
- return true;
- }
- @Override
- public boolean isJoin()
- {
- return true;
- }
-
- @Override
- public WfVertex instantiate() {
- Join newJoin = new Join();
- configureInstance(newJoin);
- return newJoin;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/LoopDef.java b/src/main/java/com/c2kernel/lifecycle/LoopDef.java deleted file mode 100644 index 5c2c119..0000000 --- a/src/main/java/com/c2kernel/lifecycle/LoopDef.java +++ /dev/null @@ -1,98 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.graph.traversal.GraphTraversal;
-import com.c2kernel.lifecycle.instance.Loop;
-import com.c2kernel.lifecycle.instance.WfVertex;
-
-/**
- * @version $Revision: 1.19 $ $Date: 2005/09/29 10:18:31 $
- * @author $Author: abranson $
- */
-
-public class LoopDef extends XOrSplitDef
-{
- public boolean hasLoop = false;
- public int isNext = 0;
-
- /**
- * @see java.lang.Object#Object()
- */
- public LoopDef()
- {
- super();
- }
-
- /**
- * @see com.c2kernel.lifecycle.WfVertexDef#loop()
- */
- @Override
- public boolean loop()
- {
- return true;
- }
-
- /**
- * @see com.c2kernel.lifecycle.WfVertexDef#verify()
- */
- @Override
- public boolean verify()
- {
- if (!super.verify()) return false;
- Vertex[] nexts = getOutGraphables();
- Vertex[] anteVertices =
- GraphTraversal.getTraversal(this.getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
- int k = 0;
- int l = 0;
- Vertex[] brothers = getParent().getChildren();
- for (Vertex brother : brothers)
- if (brother instanceof LoopDef) l++;
- for (Vertex next : nexts)
- for (Vertex anteVertice : anteVertices)
- if (next.equals(anteVertice))
- k++;
- if (k != 1 && !(l>1))
- {
- mErrors.add("bad number of pointing back nexts");
- return false;
- }
-// if (nexts.length>2) {
-// mErrors.add("you must only have 2 nexts");
-// return false;
-// }
- return true;
- }
-
- @Override
- public boolean isLoop() {
- return true;
- }
-
- @Override
- public WfVertex instantiate() {
- Loop newLoop = new Loop();
- configureInstance(newLoop);
- return newLoop;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/NextDef.java b/src/main/java/com/c2kernel/lifecycle/NextDef.java deleted file mode 100644 index 7fc2ed9..0000000 --- a/src/main/java/com/c2kernel/lifecycle/NextDef.java +++ /dev/null @@ -1,115 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.graph.model.GraphableEdge;
-import com.c2kernel.lifecycle.instance.Next;
-/**
- * @version $Revision: 1.32 $ $Date: 2006/03/03 13:52:21 $
- * @author $Author: abranson $
- */
-public class NextDef extends GraphableEdge
-{
- /**
- * @see java.lang.Object#Object()
- */
- public NextDef()
- {
- }
- /**
- * Method verify.
- *
- * @return boolean
- */
- public boolean verify()
- {
- return true;
- }
- /**
- * Method NextDef.
- *
- * @param pre
- * @param nex
- */
- /** create and initialize a link between an Activities */
- public NextDef(WfVertexDef pre, WfVertexDef nex)
- {
- setParent(pre.getParent());
- if (pre instanceof OrSplitDef || pre instanceof XOrSplitDef)
- {
- int num = pre.getOutGraphables().length;
- try
- {
- num = Integer.parseInt((String) pre.getProperties().get("LastNum"));
- }
- catch (Exception e)
- {
- }
- getProperties().put("Alias", String.valueOf(num));
- pre.getProperties().put("LastNum", String.valueOf(num + 1));
- }
- }
- @Override
- public boolean containsPoint(GraphPoint p)
- {
- GraphPoint originPoint = getOriginPoint();
- GraphPoint terminusPoint = getTerminusPoint();
- GraphPoint midPoint = new GraphPoint();
- if (("Broken +".equals(getProperties().get("Type"))))
- {
- midPoint.x = (originPoint.x + terminusPoint.x) / 2;
- midPoint.y = (originPoint.y + terminusPoint.y) / 2;
- }
- else if (("Broken -".equals(getProperties().get("Type"))))
- {
- boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
- midPoint.x = arrowOnY ? terminusPoint.x : (originPoint.x + terminusPoint.x) / 2;
- midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : originPoint.y;
- }
- else if (("Broken |".equals(getProperties().get("Type"))))
- {
- boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
- midPoint.x = arrowOnY ? originPoint.x : (originPoint.x + terminusPoint.x) / 2;
- midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : terminusPoint.y;
- }
- else
- {
- midPoint.x = originPoint.x + (terminusPoint.x - originPoint.x) / 2;
- midPoint.y = originPoint.y + (terminusPoint.y - originPoint.y) / 2;
- }
- int minX = midPoint.x - 10;
- int minY = midPoint.y - 10;
- int maxX = midPoint.x + 10;
- int maxY = midPoint.y + 10;
- return (p.x >= minX) && (p.x <= maxX) && (p.y >= minY) && (p.y <= maxY);
- }
-
- public Next instantiate() {
- Next next = new Next();
- next.setID(getID());
- next.setOriginVertexId(getOriginVertexId());
- next.setTerminusVertexId(getTerminusVertexId());
- next.setProperties(getProperties());
- next.setOriginPoint(getOriginPoint());
- next.setTerminusPoint(getTerminusPoint());
- return next;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/OrSplitDef.java b/src/main/java/com/c2kernel/lifecycle/OrSplitDef.java deleted file mode 100644 index 86597f2..0000000 --- a/src/main/java/com/c2kernel/lifecycle/OrSplitDef.java +++ /dev/null @@ -1,44 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-import com.c2kernel.lifecycle.instance.OrSplit;
-import com.c2kernel.lifecycle.instance.WfVertex;
-/**
- * @version $Revision: 1.13 $ $Date: 2005/12/01 14:23:15 $
- * @author $Author: abranson $
- */
-public class OrSplitDef extends AndSplitDef
-{
- /**
- * @see java.lang.Object#Object()
- */
- public OrSplitDef()
- {
- super();
- }
-
- @Override
- public WfVertex instantiate() {
- OrSplit newSplit = new OrSplit();
- configureInstance(newSplit);
- return newSplit;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/WfCastorHashMap.java b/src/main/java/com/c2kernel/lifecycle/WfCastorHashMap.java deleted file mode 100644 index 922a92d..0000000 --- a/src/main/java/com/c2kernel/lifecycle/WfCastorHashMap.java +++ /dev/null @@ -1,48 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-import com.c2kernel.utils.CastorHashMap;
-/**
- * @version $Revision: 1.29 $ $Date: 2005/05/20 13:07:13 $
- * @author $Author: abranson $
- */
-public class WfCastorHashMap extends CastorHashMap
-{
- /**
- * @see java.lang.Object#Object()
- */
- public WfCastorHashMap()
- {
- put("Show time", true);
- put("Breakpoint", false);
- put("Description", "");
- put("Agent Role", "");
- put("Agent Name", "");
- put("SchemaType", "");
- put("SchemaVersion", "");
- put("ScriptName", "");
- put("ScriptVersion", "");
- put("StateMachineName", "Default");
- put("StateMachineVersion", 0);
- put("Viewpoint", "");
- put("OutcomeInit", "");
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java b/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java deleted file mode 100644 index 08e6451..0000000 --- a/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java +++ /dev/null @@ -1,111 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-
-import java.util.Vector;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.graph.model.GraphableVertex;
-import com.c2kernel.lifecycle.instance.WfVertex;
-import com.c2kernel.utils.KeyValuePair;
-
-/**
- * @version $Revision: 1.22 $ $Date: 2005/11/15 15:56:38 $
- * @author $Author: abranson $
- */
-public abstract class WfVertexDef extends GraphableVertex
-{
- public Vector<String> mErrors;
-
- protected boolean loopTested;
-
- /**
- * @see java.lang.Object#Object()
- */
- /** @label wf */
- public WfVertexDef()
- {
- mErrors = new Vector<String>(0, 1);
- setIsLayoutable(true);
- }
-
- public abstract WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException;
-
- public void configureInstance(WfVertex newVertex) {
- KeyValuePair[] k = getProperties().getKeyValuePairs();
- for (KeyValuePair element : k)
- newVertex.getProperties().put(element.getKey(), element.getValue(), element.isAbstract());
- newVertex.setID(getID());
- if (getIsLayoutable()) {
- newVertex.setInEdgeIds(getInEdgeIds());
- newVertex.setOutEdgeIds(getOutEdgeIds());
- newVertex.setCentrePoint(getCentrePoint());
- newVertex.setOutlinePoints(getOutlinePoints());
- }
- }
-
- /**
- * Method verify.
- *
- * @return boolean
- */
- public abstract boolean verify();
-
- /**
- * Method getErrors.
- *
- * @return String
- */
- public String getErrors()
- {
- if (mErrors.size() == 0)
- return "No error";
- else if (mErrors.size() == 1)
- return mErrors.elementAt(0);
- else {
- StringBuffer errorBuffer = new StringBuffer();
- for (String error : mErrors) {
- if (errorBuffer.length() > 0) errorBuffer.append("\n");
- errorBuffer.append(error);
- }
- return errorBuffer.toString();
- }
- }
-
- /**
- * Method loop.
- *
- * @return boolean
- */
- public boolean loop()
- {
- boolean loop2 = false;
- if (!loopTested)
- {
- loopTested = true;
- if (getOutGraphables().length != 0)
- loop2 = ((WfVertexDef) getOutGraphables()[0]).loop();
- }
- loopTested = false;
- return loop2;
- }
-}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/WfVertexDefOutlineCreator.java b/src/main/java/com/c2kernel/lifecycle/WfVertexDefOutlineCreator.java deleted file mode 100644 index d2322d3..0000000 --- a/src/main/java/com/c2kernel/lifecycle/WfVertexDefOutlineCreator.java +++ /dev/null @@ -1,70 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.graph.model.VertexOutlineCreator;
-
-public class WfVertexDefOutlineCreator implements VertexOutlineCreator
-{
- private static final int mActivityWidth = 130;
- private static final int mActivityHeight = 60;
- private static final int mSplitJoinWidth = 60;
- private static final int mSplitJoinHeight = 25;
-
- @Override
- public void setOutline(Vertex vertex)
- {
- GraphPoint centrePoint = vertex.getCentrePoint();
- GraphPoint[] outlinePoints = new GraphPoint[ 4 ];
- int vertexWidth = 0;
- int vertexHeight = 0;
-
-
- if ( vertex instanceof ActivitySlotDef )
- {
- vertexWidth = mActivityWidth;
- vertexHeight = mActivityHeight;
- }
- else
- {
- vertexWidth = mSplitJoinWidth;
- vertexHeight = mSplitJoinHeight;
- }
-
- outlinePoints[ 0 ] = new GraphPoint();
- outlinePoints[ 0 ].x = centrePoint.x - vertexWidth / 2;
- outlinePoints[ 0 ].y = centrePoint.y - vertexHeight / 2;
- outlinePoints[ 1 ] = new GraphPoint();
- outlinePoints[ 1 ].x = centrePoint.x + vertexWidth / 2;
- outlinePoints[ 1 ].y = centrePoint.y - vertexHeight / 2;
- outlinePoints[ 2 ] = new GraphPoint();
- outlinePoints[ 2 ].x = centrePoint.x + vertexWidth / 2;
- outlinePoints[ 2 ].y = centrePoint.y + vertexHeight / 2;
- outlinePoints[ 3 ] = new GraphPoint();
- outlinePoints[ 3 ].x = centrePoint.x - vertexWidth / 2;
- outlinePoints[ 3 ].y = centrePoint.y + vertexHeight / 2;
-
- vertex.setOutlinePoints( outlinePoints );
- }
-}
-
diff --git a/src/main/java/com/c2kernel/lifecycle/XOrSplitDef.java b/src/main/java/com/c2kernel/lifecycle/XOrSplitDef.java deleted file mode 100644 index 563aa65..0000000 --- a/src/main/java/com/c2kernel/lifecycle/XOrSplitDef.java +++ /dev/null @@ -1,48 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle;
-
-import com.c2kernel.lifecycle.instance.WfVertex;
-import com.c2kernel.lifecycle.instance.XOrSplit;
-
-
-/**
- * @version $Revision: 1.14 $ $Date: 2005/09/29 10:18:31 $
- * @author $Author: abranson $
- */
-
-public class XOrSplitDef extends AndSplitDef
-{
- /**
- * @see java.lang.Object#Object()
- */
- public XOrSplitDef()
- {
- super();
- }
-
- @Override
- public WfVertex instantiate() {
- XOrSplit newSplit = new XOrSplit();
- configureInstance(newSplit);
- return newSplit;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java deleted file mode 100644 index 4dfe6ca..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java +++ /dev/null @@ -1,572 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.GTimeStamp;
-import com.c2kernel.common.InvalidCollectionModification;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.agent.Job;
-import com.c2kernel.events.Event;
-import com.c2kernel.events.History;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.lifecycle.WfCastorHashMap;
-import com.c2kernel.lifecycle.instance.stateMachine.State;
-import com.c2kernel.lifecycle.instance.stateMachine.StateMachine;
-import com.c2kernel.lifecycle.instance.stateMachine.Transition;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.InvalidAgentPathException;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.Path;
-import com.c2kernel.lookup.RolePath;
-import com.c2kernel.persistency.outcome.Outcome;
-import com.c2kernel.persistency.outcome.Schema;
-import com.c2kernel.persistency.outcome.Viewpoint;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.DateUtility;
-import com.c2kernel.utils.LocalObjectLoader;
-import com.c2kernel.utils.Logger;
-/**
- * @version $Revision: 1.222 $ $Date: 2005/10/05 07:39:37 $
- * @author $Author: abranson $
- */
-public class Activity extends WfVertex
-{
- /**
- * vector of errors (Strings) that is constructed each time verify() is launched
- */
- protected Vector<String> mErrors;
- /** @associates a State machine engine */
- private StateMachine machine;
- protected int state = -1;
- /** true is available to be executed */
- public boolean active = false;
- /** used in verify() */
- private boolean loopTested;
- private GTimeStamp mStateDate;
- private String mType;
-
- public Activity()
- {
- super();
- setProperties(new WfCastorHashMap());
- getProperties().put("StateMachineName", getDefaultSMName());
- mErrors = new Vector<String>(0, 1);
- mStateDate = new GTimeStamp();
- DateUtility.setToNow(mStateDate);
- }
-
- protected String getDefaultSMName() {
- return "Default";
- }
-
- /** add the activity which id is idNext as next of the current one */
- void addNext(String idNext)
- {
- new Next(this, (WfVertex) getParent().search(idNext));
- }
- /**
- * adds a New link between the current Activity and the WfVertex passed in param
- */
- @Override
- public Next addNext(WfVertex vertex)
- {
- return new Next(this, vertex);
- }
-
- public StateMachine getStateMachine() throws InvalidDataException {
- if (machine == null) {
- String name = (String)getProperties().get("StateMachineName");
- int version = getVersionNumberProperty("StateMachineVersion");
- try {
- machine = LocalObjectLoader.getStateMachine(name, version);
- } catch (ObjectNotFoundException ex) {
- if (name.equals(getDefaultSMName()) && version == 0) { // default state machine not imported yet. Fake it.
- try {
- String marshalledSM = Gateway.getResource().getTextResource(null, "boot/SM/"+getDefaultSMName()+".xml");
- StateMachine bootstrap = (StateMachine)Gateway.getMarshaller().unmarshall(marshalledSM);
- bootstrap.validate();
- machine = bootstrap;
- return bootstrap;
- } catch (Exception ex2) {
- Logger.error(ex2);
- throw new InvalidDataException("Could not bootstrap default state machine from resources.");
- }
- }
- Logger.error(ex);
- throw new InvalidDataException("Error loading state machine '"+name+"' v"+version);
- }
- }
- return machine;
- }
-
- /** return the current State of the State machine (Used in Serialisation) */
- public int getState() throws InvalidDataException
- {
- if (state == -1)
- state = getStateMachine().getInitialStateCode();
- return state;
- }
- public String getStateName() throws InvalidDataException
- {
- return getStateMachine().getState(getState()).getName();
- }
-
- /** Sets a new State */
- public void setState(int state)
- {
- this.state = state;
- }
-
- public boolean isFinished() throws InvalidDataException {
- return getStateMachine().getState(getState()).isFinished();
- }
-
-
- /** cf Item request
- * @throws ObjectNotFoundException
- * @throws PersistencyException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated
- * @throws CannotManageException
- * @throws InvalidCollectionModification */
- public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException, ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException, InvalidCollectionModification
- {
-
- // Find requested transition
- Transition transition = getStateMachine().getTransition(transitionID);
-
- // Check if the transition is possible
- String usedRole = transition.getPerformingRole(this, agent);
-
- // Verify outcome
- Schema schema = null;
- String viewName = null;
- boolean storeOutcome = false;
- if (transition.hasOutcome(getProperties())) {
- schema = transition.getSchema(getProperties());
- viewName = (String)getProperties().get("Viewpoint");
- if (requestData != null && requestData.length()>0)
- storeOutcome = true;
- else if (transition.getOutcome().isRequired())
- throw new InvalidDataException("Transition requires outcome data, but none was given");
- }
-
- // Get new state
- State newState = getStateMachine().traverse(this, transition, agent);
-
- // Run extra logic in predefined steps here
- String outcome = runActivityLogic(agent, itemPath, transitionID, requestData);
-
- // set new state and reservation
- setState(newState.getId());
- getProperties().put("Agent Name", transition.getReservation(this, agent));
-
- // store new event
- Event newEvent = null;
- try {
- History hist = getWf().getHistory();
- if (storeOutcome)
- newEvent = hist.addEvent(agent, usedRole, getName(), getPath(), getType(), schema.docType, schema.docVersion,
- getStateMachine().getName(), getStateMachine().getVersion(), transition, viewName);
- else
- newEvent = hist.addEvent(agent, usedRole, getName(), getPath(), getType(),
- getStateMachine().getName(), getStateMachine().getVersion(), transition);
-
- Logger.msg(7, "Activity::auditEvent() - Event:" + newEvent.getName() + " was added to the AuditTrail");
-
- if (storeOutcome) {
- Outcome newOutcome = new Outcome(newEvent.getID(), outcome, schema.docType, schema.docVersion);
- Gateway.getStorage().put(itemPath, newOutcome, getWf());
-
- // update specific view if defined
- if (viewName != null && !viewName.equals("")) {
- Viewpoint currentView = new Viewpoint(itemPath, schema.docType, viewName, schema.docVersion, newEvent.getID());
- Gateway.getStorage().put(itemPath, currentView, getWf());
- }
- // update last view
- Viewpoint currentView = new Viewpoint(itemPath, schema.docType, "last", schema.docVersion, newEvent.getID());
- Gateway.getStorage().put(itemPath, currentView, getWf());
- }
- Gateway.getStorage().commit(getWf());
- } catch (PersistencyException ex) {
- Logger.error(ex);
- Gateway.getStorage().abort(getWf());
- throw ex;
- }
-
- if (newState.isFinished()) {
- if (!getProperties().get("Breakpoint").equals(Boolean.TRUE))
- runNext(agent, itemPath);
- }
-
- DateUtility.setToNow(mStateDate);
-
- //refresh all the job lists
- String agentRole = getCurrentAgentRole();
- if (agentRole != null && agentRole.length()>0) {
- try {
- RolePath myRole = Gateway.getLookup().getRolePath(agentRole);
- pushJobsToAgents(itemPath, myRole);
- } catch (ObjectNotFoundException ex) { // non-existent role
- Logger.msg(7, "Activity.pushJobsToAgents() - Activity role '"+agentRole+" not found.");
- }
- }
-
-
- return outcome;
- }
-
- protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
- int transitionID, String requestData) throws
- InvalidDataException,
- InvalidCollectionModification,
- ObjectAlreadyExistsException,
- ObjectCannotBeUpdated,
- ObjectNotFoundException,
- PersistencyException,
- CannotManageException
- {
- // Overriden in predefined steps
- return requestData;
- }
-
- @Override
- public boolean verify()
- {
- mErrors.removeAllElements();
- int nbInEdgres = getInEdges().length;
- int nbOutEdges = getOutEdges().length;
- if (nbInEdgres == 0 && this.getID() != getParent().getChildrenGraphModel().getStartVertexId())
- {
- mErrors.add("Unreachable");
- return false;
- }
- else if (nbInEdgres > 1)
- {
- mErrors.add("Bad nb of previous");
- return false;
- }
- else if (nbOutEdges > 1)
- {
- mErrors.add("too many next");
- return false;
- }
- else if (nbOutEdges == 0)
- {
- if (!((CompositeActivity) getParent()).hasGoodNumberOfActivity())
- {
- mErrors.add("too many endpoints");
- return false;
- }
- }
-// else
-// {
-// Vertex[] outV = getOutGraphables();
-// Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
-// boolean errInLoop = false;
-// for (int i = 0; i < outV.length; i++)
-// {
-// for (int j = 0; j < anteVertices.length; j++)
-// if (!loop() && outV[i].getID() == anteVertices[j].getID())
-// errInLoop = true;
-// }
-// if (errInLoop)
-// {
-// mErrors.add("Error In Loop");
-// return false;
-// }
-// }
- return true;
- }
- /** Used in verify() */
- @Override
- public boolean loop()
- {
- boolean loop2 = false;
- if (!loopTested)
- {
- loopTested = true;
- if (getOutGraphables().length != 0)
- loop2 = ((WfVertex) getOutGraphables()[0]).loop();
- }
- loopTested = false;
- return loop2;
- }
- /** sets the next activity available if possible
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated */
- @Override
- public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- setActive(false);
- try
- {
- Vertex[] outVertices = getOutGraphables();
- Vertex[] outVertices2 = getOutGraphables();
- boolean hasNoNext = false;
- boolean out = false;
- while (!out)
- if (outVertices2.length > 0)
- {
- if (outVertices2[0] instanceof Join)
- outVertices2 = ((WfVertex) outVertices2[0]).getOutGraphables();
- else
- out = true;
- }
- else
- {
- hasNoNext = true;
- out = true;
- }
- Logger.debug(8, Arrays.toString(outVertices) + " " + Arrays.toString(outVertices2));
- if (!hasNoNext)
- ((WfVertex) outVertices[0]).run(agent, itemPath);
- else
- {
- if (getParent() != null && getParent().getName().equals("domain")) // workflow
- // finished
- setActive(true);
- else
- {
- CompositeActivity parent = (CompositeActivity) getParent();
- if (parent != null)
- parent.runNext(agent, itemPath);
- }
- }
- }
- catch (InvalidDataException s)
- {
- setActive(true);
- throw s;
- }
- }
- /** @return the only Next of the Activity */
- public Next getNext()
- {
- if (getOutEdges().length > 0)
- return (Next) getOutEdges()[0];
- else
- return null;
- }
- /** reinitialises the Activity and propagate (for Loop)
- * @throws InvalidDataException
- * @throws ObjectNotFoundException */
- @Override
- public void reinit(int idLoop) throws InvalidDataException
- {
- Vertex[] outVertices = getOutGraphables();
- setState(getStateMachine().getInitialState().getId());
- if (outVertices.length > 0)
- {
- WfVertex nextAct = (WfVertex) outVertices[0];
- nextAct.reinit(idLoop);
- }
- }
- /** return the String that identifies the errors found in th activity */
- @Override
- public String getErrors()
- {
- if (mErrors.size() == 0)
- return "No error";
- return mErrors.elementAt(0);
- }
- /**
- * called by precedent Activity runNext() for setting the activity able to be executed
- * @throws InvalidDataException
- * @throws ObjectAlreadyExistsException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws ObjectNotFoundException
- * @throws PersistencyException
- * @throws ObjectCannotBeUpdated
- */
- @Override
- public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- Logger.debug(8, getPath() + " run " + getState());
-
- if (!getActive()) setActive(true);
- boolean finished = getStateMachine().getState(getState()).isFinished();
- if (finished)
- {
- runNext(agent, itemPath);
- }
- else
- {
- DateUtility.setToNow(mStateDate);
- pushJobsToAgents(itemPath);
- }
- }
- /**
- * sets the activity available to be executed on start of Workflow or composite activity (when it is the first one of the (sub)process
- * @throws InvalidDataException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectCannotBeUpdated
- */
- @Override
- public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- Logger.debug(8, getPath() + " runfirst");
- run(agent, itemPath);
- }
- /** @return the current ability to be executed */
- public boolean getActive()
- {
- return active;
- }
- /** sets the ability to be executed */
- public void setActive(boolean acti)
- {
- active = acti;
- }
- /** @return the Description field of properties */
- public String getDescription()
- {
- if (getProperties().containsKey("Description"))
- return (String) (getProperties().get("Description"));
- return "No description";
- }
- public String getCurrentAgentName()
- {
- return (String) getProperties().get("Agent Name");
- }
- public String getCurrentAgentRole()
- {
- return (String) getProperties().get("Agent Role");
- }
-
- /**
- * returns the lists of jobs for the activity and children (cf com.c2kernel.entity.Job)
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- * @throws InvalidAgentPathException
- */
- public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFoundException, InvalidDataException
- {
- return calculateJobsBase(agent, itemPath, false);
- } //
- public ArrayList<Job> calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFoundException, InvalidDataException
- {
- return calculateJobsBase(agent, itemPath, true);
- }
- private ArrayList<Job> calculateJobsBase(AgentPath agent, ItemPath itemPath, boolean includeInactive) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
- {
- Logger.msg(7, "calculateJobs - " + getPath());
- ArrayList<Job> jobs = new ArrayList<Job>();
- Map<Transition, String> transitions;
- if ((includeInactive || getActive()) && !getName().equals("domain")) {
- transitions = getStateMachine().getPossibleTransitions(this, agent);
- Logger.msg(7, "Activity.calculateJobs() - Got " + transitions.size() + " transitions.");
- for (Transition transition : transitions.keySet()) {
- Logger.msg(7, "Creating Job object for transition " + transition);
- jobs.add(new Job(this, itemPath, transition, agent, transitions.get(transition)));
- }
- }
- return jobs;
- }
-
-
- public void pushJobsToAgents(ItemPath itemPath) {
- String agentRole = getCurrentAgentRole();
- if (agentRole != null && agentRole.length()>0) {
- try {
- RolePath myRole = Gateway.getLookup().getRolePath(agentRole);
- pushJobsToAgents(itemPath, myRole);
- } catch (ObjectNotFoundException ex) { // non-existent role
- Logger.msg(7, "Activity.pushJobsToAgents() - Activity role '"+agentRole+" not found.");
- }
- }
- }
-
- public void pushJobsToAgents(ItemPath itemPath, RolePath role)
- {
- if (role.hasJobList())
- new JobPusher(this, itemPath, role).start();
- Iterator<Path> childRoles = role.getChildren();
- while (childRoles.hasNext()) {
- RolePath childRole = (RolePath)childRoles.next();
- pushJobsToAgents(itemPath, childRole);
- }
- }
-
- /**
- * Returns the startDate.
- *
- * @return GTimeStamp
- */
- public GTimeStamp getStateDate()
- {
- return mStateDate;
- }
- public void setStateDate(GTimeStamp startDate)
- {
- mStateDate = startDate;
- }
-
- @Deprecated
- public void setActiveDate(GTimeStamp date)
- { }
- @Deprecated
- public void setStartDate(GTimeStamp date)
- {
- setStateDate(date);
- }
-
- /**
- * Returns the type.
- *
- * @return String
- */
- public String getType()
- {
- return mType;
- } /**
- * Sets the type.
- *
- * @param type
- * The type to set
- */
- public void setType(String type)
- {
- mType = type;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/AdvancementCalculator.java b/src/main/java/com/c2kernel/lifecycle/instance/AdvancementCalculator.java deleted file mode 100644 index 6f2c9ce..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/AdvancementCalculator.java +++ /dev/null @@ -1,242 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-/* Created on 11 mars 2004 */
-package com.c2kernel.lifecycle.instance;
-import java.util.Hashtable;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.graph.model.Vertex;
-//import com.c2kernel.utils.Logger;
-/** @author XSeb74 */
-public class AdvancementCalculator
-{
- private CompositeActivity activity;
- private Hashtable<Vertex, Object> isMarked;
- private Hashtable<Vertex, Vertex> HasNextMarked;
- public Hashtable<String, Vertex> hasprevActive;
- private long mCurrentNbActExp = 0;
- private long mMaximuNbActexp = 0;
- private long mNbActpassed = 0;
- private long mNbActpassedWithCurrent = 0;
- private long mNbActLeftWithCurrent = 0;
- private long mNbActLeftWithoutCurrent = 0;
- private boolean mIsbranchActive = false;
- private boolean mIsbranchFinished = true;
- private boolean mHasPrevActive = false;
- public AdvancementCalculator()
- {
- isMarked = new Hashtable<Vertex, Object>();
- HasNextMarked = new Hashtable<Vertex, Vertex>();
- hasprevActive = new Hashtable<String, Vertex>();
- }
- public void calculate(CompositeActivity act) throws InvalidDataException
- {
-// Logger.debug(0, act.getName()+" >>>>>>>>>");
- if (act instanceof Workflow)
- {
- calculate((CompositeActivity) act.search("workflow/domain"));
- return;
- }
- activity = act;
- Vertex v = activity.getChildGraphModel().getStartVertex();
- check(v, this);
- isMarked = new Hashtable<Vertex, Object>();
- calc(v, this);
-// Logger.debug(0, act.getName()+" <<<<<<<<<");
- }
- private void check(Vertex v, AdvancementCalculator current)
- {
- current.isMarked.put(v, "");
- Vertex[] nexts = current.activity.getChildGraphModel().getOutVertices(v);
- for (Vertex next : nexts)
- if (current.isMarked.get(next) != null)
- current.HasNextMarked.put(v, next);
- else
- check(next, current);
- int j=0;
- for (Vertex next : nexts)
- if (current.HasNextMarked.get(next) != null)
- j++;
- if (j != 0 && j==nexts.length) current.HasNextMarked.put(v, nexts[0]);
- }
- private void calc(Vertex v, AdvancementCalculator current) throws InvalidDataException
- {
- if (current.isMarked.get(v) != null && !(v instanceof Join))
- return;
- if (v instanceof Activity)
- {
- current.isMarked.put(v, current);
- Activity act = (Activity) v;
- if (v instanceof CompositeActivity)
- {
- CompositeActivity cact = (CompositeActivity) v;
- AdvancementCalculator adv = new AdvancementCalculator();
- adv.isMarked = current.isMarked;
- adv.HasNextMarked = current.HasNextMarked;
- adv.calculate(cact);
- current.mCurrentNbActExp += adv.mCurrentNbActExp;
- current.mMaximuNbActexp += adv.mMaximuNbActexp;
- current.mNbActpassed += adv.mNbActpassed;
- current.mNbActpassedWithCurrent += adv.mNbActpassedWithCurrent;
- current.mIsbranchActive = current.mIsbranchActive || adv.mIsbranchActive || act.getActive();
- current.mNbActLeftWithCurrent += adv.mNbActLeftWithCurrent;
- current.mNbActLeftWithoutCurrent += adv.mNbActLeftWithoutCurrent;
- current.mHasPrevActive |= adv.mHasPrevActive || act.getActive() || adv.hasprevActive.size()!=0;
- }
- else
- {
- current.mCurrentNbActExp += 1;
- current.mMaximuNbActexp += 1;
- if (act.isFinished())
- {
- current.mNbActpassed += 1;
- current.mNbActpassedWithCurrent += 1;
- }
- else if (act.getActive())
- {
- current.mIsbranchActive = true;
- current.mIsbranchFinished = false;
- current.mHasPrevActive = true;
- current.mNbActpassedWithCurrent += 1;
- current.mNbActLeftWithCurrent += 1;
- }
- else
- {
- current.mIsbranchFinished = false;
- current.mNbActLeftWithCurrent += 1;
- current.mNbActLeftWithoutCurrent += 1;
- }
- }
- }
- Vertex[] nexts = current.activity.getChildGraphModel().getOutVertices(v);
- if (v instanceof Split)
- {
- current.isMarked.put(v, current);
- AdvancementCalculator[] advs = new AdvancementCalculator[nexts.length];
- for (int i = 0; i < nexts.length; i++)
- {
- advs[i] = new AdvancementCalculator();
- advs[i].mHasPrevActive = current.mHasPrevActive;
- advs[i].isMarked = current.isMarked;
- advs[i].HasNextMarked = current.HasNextMarked;
- advs[i].activity = current.activity;
- if ((v instanceof Loop) && (current.HasNextMarked.get(nexts[i]) != null))
-// Logger.debug(0, v.getID() + " " + nexts[i].getID() + " HasNextMarked")
- ;
- else
- calc(nexts[i], advs[i]);
- }
- long maximuNbActexp = 0;
- long currentNbActExp = 0;
- long NbActpassed = 0;
- long NbActpassedWithCurrent = 0;
- long NbActLeftWithCurrent = 0;
- long NbActLeftWithoutCurrent = 0;
- boolean hasNobranchFinished = true;
- boolean hasNoBranchActive = true;
- for (AdvancementCalculator adv : advs) {
- if (adv.mIsbranchActive)
- hasNoBranchActive = false;
- if (adv.mIsbranchFinished)
- hasNobranchFinished = false;
- }
- for (AdvancementCalculator adv : advs) {
-
- if (maximuNbActexp < adv.mMaximuNbActexp)
- maximuNbActexp = adv.mMaximuNbActexp;
- if (adv.mIsbranchActive || adv.mIsbranchFinished || (hasNoBranchActive && hasNobranchFinished))
- {
- if (NbActpassed < adv.mNbActpassed)
- NbActpassed = adv.mNbActpassed;
- if (NbActpassedWithCurrent < adv.mNbActpassedWithCurrent)
- NbActpassedWithCurrent = adv.mNbActpassedWithCurrent;
- if (NbActLeftWithCurrent < adv.mNbActLeftWithCurrent)
- NbActLeftWithCurrent = adv.mNbActLeftWithCurrent;
- if (NbActLeftWithoutCurrent < adv.mNbActLeftWithoutCurrent)
- NbActLeftWithoutCurrent += adv.mNbActLeftWithoutCurrent;
- if (currentNbActExp < adv.mCurrentNbActExp)
- currentNbActExp = adv.mCurrentNbActExp;
- }
- }
- current.mCurrentNbActExp += currentNbActExp;
- current.mNbActpassedWithCurrent += NbActpassedWithCurrent;
- current.mMaximuNbActexp += maximuNbActexp;
- current.mNbActpassed += NbActpassed;
- current.mIsbranchActive = current.mIsbranchActive || !hasNoBranchActive;
- current.mNbActLeftWithCurrent += NbActLeftWithCurrent;
- current.mNbActLeftWithoutCurrent += NbActLeftWithoutCurrent;
- return;
- }
- if (v instanceof Join)
- {
- AdvancementCalculator adv;
- if (current.isMarked.get(v) == null)
- {
- adv = new AdvancementCalculator();
- adv.isMarked = current.isMarked;
- adv.HasNextMarked = current.HasNextMarked;
- adv.activity = current.activity;
- adv.mHasPrevActive = current.mHasPrevActive;
- current.isMarked.put(v, adv);
- if (nexts.length == 1)
- calc(nexts[0], adv);
- }
- else
- adv = (AdvancementCalculator) current.isMarked.get(v);
- current.mCurrentNbActExp += adv.mCurrentNbActExp;
- current.mMaximuNbActexp += adv.mMaximuNbActexp;
- current.mNbActpassed += adv.mNbActpassed;
- current.mNbActpassedWithCurrent += adv.mNbActpassedWithCurrent;
- current.mIsbranchActive = current.mIsbranchActive || (current.mMaximuNbActexp == 0 && adv.mIsbranchActive);
- if (current.mHasPrevActive)
- hasprevActive.put(String.valueOf(v.getID()), v);
- current.mNbActLeftWithCurrent += adv.mNbActLeftWithCurrent;
- current.mNbActLeftWithoutCurrent += adv.mNbActLeftWithoutCurrent;
- return;
- }
- if (nexts.length != 0)
- calc(nexts[0], current);
- }
- public long getLongestWayInAct()
- {
- return mMaximuNbActexp;
- }
- public long getCurrentLongestWayInAct()
- {
- return mCurrentNbActExp;
- }
- public long getNbActLeftWithActive()
- {
- return mNbActLeftWithCurrent;
- }
- public long getNbActLeftWithoutActive()
- {
- return mNbActLeftWithoutCurrent;
- }
- public long getNbActPassedWithoutActive()
- {
- return mNbActpassed;
- }
- public long getNbActPassedWithActive()
- {
- return mNbActpassedWithCurrent;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java b/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java deleted file mode 100644 index 5e08e3d..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java +++ /dev/null @@ -1,48 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-/**
- * @version $Revision: 1.16 $ $Date: 2005/05/10 15:14:54 $
- * @author $Author: abranson $
- */
-public class AndSplit extends Split
-{
- /**
- * @see java.lang.Object#Object()
- */
- public AndSplit()
- {
- super();
- }
- @Override
- public void runNext(AgentPath agent, ItemPath item) throws InvalidDataException
- {
- AdvancementCalculator adv = new AdvancementCalculator();
- adv.calculate((CompositeActivity) getParent());
- Vertex[] outVertices = getOutGraphables();
- for (Vertex outVertice : outVertices)
- ((WfVertex) outVertice).run(agent, item);
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java b/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java deleted file mode 100644 index 9bb5c84..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java +++ /dev/null @@ -1,468 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-
-import java.util.ArrayList;
-
-import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidCollectionModification;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.agent.Job;
-import com.c2kernel.graph.model.GraphModel;
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.graph.model.GraphableVertex;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.InvalidAgentPathException;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.utils.Logger;
-
-/**
- * @version $Revision: 1.86 $ $Date: 2005/10/05 07:39:37 $
- * @author $Author: abranson $
- */
-public class CompositeActivity extends Activity
-{
-
-
- /*
- * --------------------------------------------
- * ----------------CONSTRUCTOR-----------------
- * --------------------------------------------
- */
- public CompositeActivity()
- {
- super();
- setChildrenGraphModel(new GraphModel(new WfVertexOutlineCreator()));
- setIsComposite(true);
- }
-
- // State machine
- public static final int START = 0;
- public static final int COMPLETE = 1;
- @Override
- protected String getDefaultSMName() {
- return "CompositeActivity";
- }
-
- @Override
- public void setChildrenGraphModel(GraphModel childrenGraph) {
- super.setChildrenGraphModel(childrenGraph);
- childrenGraph.setVertexOutlineCreator(new WfVertexOutlineCreator());
- }
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#verify()
- */
- /*
- * -------------------------------------------- --------------Other
- * Functions--------------- --------------------------------------------
- */
- /** launch the verification of the subprocess() */
- @Override
- public boolean verify()
- {
- boolean err = super.verify();
- GraphableVertex[] vChildren = getChildren();
- for (int i = 0; i < vChildren.length; i++)
- {
- if (!((WfVertex) vChildren[i]).verify())
- {
- mErrors.add("error in children");
- return false;
- }
- }
- return err;
- }
-
- /**
- * Method initChild.
- *
- * @param act
- * @param first
- * @param point
- */
- /**
- * Create an initialize a Activity attached to the current activity
- *
- * @param first :
- * if true, the activity Waiting will be one of the first
- * launched by the parent activity
- */
- public void initChild(Activity act, boolean first, GraphPoint point)
- {
- this.addChild(act, new GraphPoint(point.x, point.y));
- if (first)
- {
- getChildrenGraphModel().setStartVertexId(act.getID());
- Logger.msg(5, "com.c2kernel.lifecycle.CompositeActivity :: " + getID() + " is first");
- }
- }
-
- /**
- * Method newChild.
- *
- * @param Name
- * @param Type
- * @param point
- * @return WfVertex
- */
- public WfVertex newExistingChild(Activity child, String Name, GraphPoint point)
- {
- child.setName(Name);
- addChild(child, new GraphPoint(point.x, point.y));
- return child;
- }
-
- /**
- * Method newChild.
- *
- * @param Name
- * @param Type
- * @param point
- * @return WfVertex
- */
- public WfVertex newChild(String Name, String Type, GraphPoint point)
- {
- WfVertex v = newChild(Type, point);
- v.setName(Name);
- return v;
- }
-
- /**
- * Method newChild.
- *
- * @param vertexTypeId
- * @param point
- * @return WfVertex
- */
- public WfVertex newChild(String vertexTypeId, GraphPoint point)
- {
- WfVertex wfVertex = null;
- if (vertexTypeId.equals("Atomic"))
- {
- wfVertex = newAtomChild("False id", false, point);
- } else if (vertexTypeId.equals("Composite"))
- {
- wfVertex = newCompChild("False id", false, point);
- } else if (vertexTypeId.endsWith("Split"))
- {
- if (vertexTypeId.startsWith("Or"))
- {
- wfVertex = newSplitChild("Or", point);
- } else if (vertexTypeId.startsWith("XOr"))
- {
- wfVertex = newSplitChild("XOr", point);
- } else if (vertexTypeId.startsWith("Loop"))
- {
- wfVertex = newSplitChild("Loop", point);
- } else
- {
- wfVertex = newSplitChild("And", point);
- }
- } else if (vertexTypeId.equals("Join"))
- {
- wfVertex = newJoinChild(point);
- } else if (vertexTypeId.equals("Route"))
- {
- wfVertex = newRouteChild(point);
- }
- return wfVertex;
- }
-
- /**
- * Method newCompChild.
- *
- * @param id
- * @param first
- * @param point
- * @return CompositeActivity Create an initialize a composite Activity
- * attached to the current activity
- */
- public CompositeActivity newCompChild(String id, boolean first, GraphPoint point)
- {
- CompositeActivity act = new CompositeActivity();
- initChild(act, first, point);
- act.setName(id);
- return act;
- }
-
- /**
- * Method newAtomChild.
- *
- * @param id
- * @param first
- * @param point
- * @return Activity Create an initialize an Atomic Activity attached to the
- * current activity
- *
- */
- public Activity newAtomChild(String id, boolean first, GraphPoint point)
- {
- Activity act = new Activity();
- initChild(act, first, point);
- act.setName(id);
- return act;
- }
-
- /**
- * Method newSplitChild.
- *
- * @param Type
- * @param point
- * @return Split
- */
- public Split newSplitChild(String Type, GraphPoint point)
- {
- Split split;
- if (Type.equals("Or"))
- {
- split = new OrSplit();
- } else if (Type.equals("XOr"))
- {
- split = new XOrSplit();
- } else if (Type.equals("Loop"))
- {
- split = new Loop();
- } else
- {
- split = new AndSplit();
- }
- addChild(split, new GraphPoint(point.x, point.y));
- return split;
- }
-
- /**
- * Method newJoinChild.
- *
- * @param point
- * @return Join
- */
- public Join newJoinChild(GraphPoint point)
- {
- Join join = new Join();
- join.getProperties().put("Type", "Join");
- addChild(join, new GraphPoint(point.x, point.y));
- return join;
- }
-
- public Join newRouteChild(GraphPoint point)
- {
- Join join = new Join();
- join.getProperties().put("Type", "Route");
- addChild(join, new GraphPoint(point.x, point.y));
- return join;
- }
-
- /**
- * Method search.
- *
- * @param ids
- * @return WfVertex
- */
- WfVertex search(int ids)
- {
- for (int i = 0; i < getChildren().length; i++)
- {
- WfVertex ver = (WfVertex) getChildren()[i];
- if (ver instanceof Split)
- {
- if (ver.getID() == ids)
- {
- return ver;
- }
- }
- if (ver instanceof Join)
- {
- if (ver.getID() == ids)
- {
- return ver;
- }
- }
- }
- return null;
- }
-
- /**
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated
- * @see com.c2kernel.lifecycle.instance.WfVertex#run()
- */
- @Override
- public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- super.run(agent, itemPath);
- if (getChildrenGraphModel().getStartVertex() != null && !getStateMachine().getState(state).isFinished())
- {
- WfVertex first = (WfVertex) getChildrenGraphModel().getStartVertex();
- first.run(agent, itemPath);
- }
- }
-
- @Override
- public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- if (!getStateMachine().getState(state).isFinished())
- try {
- request(agent, itemPath, CompositeActivity.COMPLETE, null);
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- Logger.error(e); // current agent couldn't complete the composite, so leave it
- }
- super.runNext(agent, itemPath);
- }
-
- - /**
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- * @throws InvalidAgentPathException
- * @see com.c2kernel.lifecycle.instance.Activity#calculateJobs()
- */
- @Override
- public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFoundException, InvalidDataException
- {
- ArrayList<Job> jobs = new ArrayList<Job>();
- boolean childActive = false;
- if (recurse)
- for (int i = 0; i < getChildren().length; i++)
- if (getChildren()[i] instanceof Activity)
- {
- Activity child = (Activity) getChildren()[i];
- jobs.addAll(child.calculateJobs(agent, itemPath, recurse));
- childActive |= child.active;
- }
- if (!childActive)
- jobs.addAll(super.calculateJobs(agent, itemPath, recurse));
- return jobs;
- }
-
- @Override
- public ArrayList<Job> calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFoundException, InvalidDataException
- {
- ArrayList<Job> jobs = new ArrayList<Job>();
- if (recurse)
- for (int i = 0; i < getChildren().length; i++)
- if (getChildren()[i] instanceof Activity)
- {
- Activity child = (Activity) getChildren()[i];
- jobs.addAll(child.calculateAllJobs(agent, itemPath, recurse));
- }
- jobs.addAll(super.calculateAllJobs(agent, itemPath, recurse));
- return jobs;
- }
-
- /**
- * Method addNext.
- *
- * @param origin
- * @param terminus
- * @return Next
- */
- public Next addNext(WfVertex origin, WfVertex terminus)
- {
- return new Next(origin, terminus);
- }
-
- /**
- * Method addNext.
- *
- * @param originID
- * @param terminusID
- * @return Next
- */
- public Next addNext(int originID, int terminusID)
- {
- Next n = new Next();
- n.setParent(this);
- getChildrenGraphModel().addEdgeAndCreateId(n, originID, terminusID);
- return n;
- }
-
- /**
- * Method hasGoodNumberOfActivity.
- *
- * @return boolean
- */
- public boolean hasGoodNumberOfActivity()
- {
- int endingAct = 0;
- for (int i = 0; i < getChildren().length; i++)
- {
- WfVertex vertex = (WfVertex) getChildren()[i];
- if (getChildrenGraphModel().getOutEdges(vertex).length == 0)
- endingAct++;
- }
- if (endingAct > 1)
- return false;
- return true;
- }
-
- /**
- * @see com.c2kernel.lifecycle.instance.Activity#getType()
- */
- @Override
- public String getType()
- {
- return super.getType();
- }
-
- /**
- * @throws InvalidDataException
- *
- */
- @Override
- public void reinit(int idLoop) throws InvalidDataException
- {
- super.reinit(idLoop);
- if (getChildrenGraphModel().getStartVertex() != null && !getStateMachine().getState(state).isFinished())
- ((WfVertex) getChildrenGraphModel().getStartVertex()).reinit(idLoop);
- }
-
- @Override
- public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException, ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException, InvalidCollectionModification
- {
- if (getChildrenGraphModel().getStartVertex() != null && !getStateMachine().getState(state).isFinished() && transitionID == CompositeActivity.START)
- ((WfVertex) getChildrenGraphModel().getStartVertex()).run(agent, itemPath);
-
- return super.request(agent, itemPath, transitionID, requestData);
- }
-
- public void refreshJobs(ItemPath itemPath)
- {
- GraphableVertex[] children = getChildren();
- for (GraphableVertex element : children)
- if (element instanceof CompositeActivity)
- ((CompositeActivity) element).refreshJobs(itemPath);
- else if (element instanceof Activity)
- ((Activity) element).pushJobsToAgents(itemPath);
- }
-}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java b/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java deleted file mode 100644 index 681dd93..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java +++ /dev/null @@ -1,80 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-
-import java.util.Iterator;
-
-import com.c2kernel.entity.Agent;
-import com.c2kernel.entity.AgentHelper;
-import com.c2kernel.entity.agent.JobArrayList;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.Path;
-import com.c2kernel.lookup.RolePath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-final class JobPusher extends Thread {
- private final Activity activity;
- private final RolePath myRole;
- private final ItemPath itemPath;
-
- JobPusher(Activity activity, ItemPath itemPath, RolePath role) {
- this.activity = activity;
- this.itemPath = itemPath;
- this.myRole = role;
- }
-
- @Override
- public void run()
- {
- Thread.currentThread().setName("Agent job pusher for "+itemPath+":"+activity.getName()+" to role "+myRole);
- for (Iterator<Path> e = myRole.getChildren(); e.hasNext();)
- {
- AgentPath nextAgent = (AgentPath)e.next();
- Logger.msg(7, "Activity.pushJobsToAgents() - Calculating jobs for " + nextAgent);
- try
- {
- // get joblist for user
- JobArrayList jobList = new JobArrayList(this.activity.calculateJobs(nextAgent, itemPath, false));
- Logger.msg(7, "Activity.pushJobsToAgents() - User will receive " + jobList.list.size() + " jobs");
- String stringJobs = Gateway.getMarshaller().marshall(jobList);
- // push it to the agent
- org.omg.CORBA.Object agentIOR = nextAgent.getIOR();
- Agent thisAgent = AgentHelper.narrow(agentIOR);
- Logger.msg(7, "Calling agent "+thisAgent.getSystemKey()+" from "+activity.getPath());
- thisAgent.refreshJobList(itemPath.getSystemKey(), activity.getPath(), stringJobs);
- }
- catch (Exception ex)
- {
- Logger.error(
- "Agent "
- + nextAgent
- + " of role "
- + myRole
- + " could not be found to be informed of a change in "
- + itemPath);
- Logger.error(ex);
- }
- }
-
- }
-}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Join.java b/src/main/java/com/c2kernel/lifecycle/instance/Join.java deleted file mode 100644 index 1a415d7..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/Join.java +++ /dev/null @@ -1,232 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-import java.util.Vector;
-
-import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.graph.traversal.GraphTraversal;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-/**
- * @version $Revision: 1.52 $ $Date: 2005/05/10 15:14:54 $
- * @author $Author: abranson $
- */
-public class Join extends WfVertex
-{
- public Vector<String> mErrors;
- /**
- * @see java.lang.Object#Object()
- */
- public Join()
- {
- super();
- mErrors = new Vector<String>(0, 1);
- }
- private boolean loopTested;
- public int counter = 0;
-
- /**
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated
- * @see com.c2kernel.lifecycle.instance.WfVertex#runNext()
- */
- @Override
- public void runNext(AgentPath agent, ItemPath item) throws InvalidDataException
- {
- AdvancementCalculator adv = new AdvancementCalculator();
- adv.calculate((CompositeActivity) getParent());
- if (adv.hasprevActive.get(String.valueOf(getID())) == null)
- {
- Vertex[] outVertices = getOutGraphables();
- if (outVertices.length > 0)
- {
- WfVertex nextAct = (WfVertex) outVertices[0];
- nextAct.run(agent, item);
- }
- else
- super.runNext(agent, item);
- }
- }
- /**
- * Method addNext.
- *
- * @param idNext
- */
- public void addNext(String idNext)
- {
- new Next(this, (WfVertex) getParent().search(idNext));
- }
- /**
- * @throws InvalidDataException
- * @see com.c2kernel.lifecycle.instance.WfVertex#reinit(int)
- */
- @Override
- public void reinit(int idLoop) throws InvalidDataException
- {
- Vertex[] outVertices = getOutGraphables();
- if (outVertices.length == 1)
- {
- WfVertex nextAct = (WfVertex) outVertices[0];
- nextAct.reinit(idLoop);
- }
- }
-
- @Override
- public boolean verify()
- {
- mErrors.removeAllElements();
- int nbOutEdges = getOutEdges().length;
- int nbInEdges = getInEdges().length;
- String type = (String) getProperties().get("Type");
- if (nbInEdges < 1)
- {
- mErrors.add("not enough previous");
- return false;
- }
- if (type != null && type.equals("Route"))
- {
- if (nbInEdges > 1)
- {
- mErrors.add("Bad nb of previous");
- return false;
- }
- }
- if (nbOutEdges > 1)
- {
- mErrors.add("too many next");
- return false;
- }
- if (nbOutEdges == 0)
- {
- if (!((CompositeActivity) getParent()).hasGoodNumberOfActivity())
- {
- mErrors.add("too many endpoints");
- return false;
- }
- }
- Vertex[] outV = getOutGraphables();
- Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
- boolean loop = false;
- boolean errInLoop = false;
- for (int i = 0; i < outV.length; i++)
- {
- for (int j = 0; j < anteVertices.length; j++)
- if (!loop && outV[i].getID() == anteVertices[j].getID())
- {
- if (outV[i] instanceof Loop)
- {
- loop = true;
- j = anteVertices.length;
- i = outV.length;
- }
- else
- {
- errInLoop = true;
- }
- }
- }
- if (errInLoop && loop)
- {
- mErrors.add("Problem in Loop");
- return false;
- }
- return true;
- }
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#getErrors()
- */
- @Override
- public String getErrors()
- {
- if (mErrors.size() == 0)
- return "No error";
- else
- return mErrors.elementAt(0);
- }
- /**
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated
- * @see com.c2kernel.lifecycle.instance.WfVertex#run()
- */
- @Override
- public void run(AgentPath agent, ItemPath item) throws InvalidDataException
- {
- runNext(agent, item);
- }
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#addNext(com.c2kernel.lifecycle.instance.WfVertex)
- */
- @Override
- public Next addNext(WfVertex vertex)
- {
- return new Next(this, vertex);
- }
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#loop()
- */
- @Override
- public boolean loop()
- {
- boolean loop2 = false;
- if (!loopTested)
- {
- loopTested = true;
- if (getOutGraphables().length != 0)
- loop2 = ((WfVertex) getOutGraphables()[0]).loop();
- }
- else
- loop2 = true;
- loopTested = false;
- return loop2;
- }
- @Override
- public void runFirst(AgentPath agent, ItemPath item) throws InvalidDataException
- {
- runNext(agent, item);
- }
- /*
- * (non-Javadoc)
- *
- * @see com.c2kernel.graph.model.Vertex#isJoin()
- */
- @Override
- public boolean isJoin()
- {
- return true;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Loop.java b/src/main/java/com/c2kernel/lifecycle/instance/Loop.java deleted file mode 100644 index 1553fdf..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/Loop.java +++ /dev/null @@ -1,129 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.graph.traversal.GraphTraversal;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.utils.Logger;
-/**
- * @version $Revision: 1.35 $ $Date: 2005/05/10 15:14:54 $
- * @author $Author: abranson $
- */
-public class Loop extends XOrSplit
-{
- /**
- * @see java.lang.Object#Object()
- */
- public Loop()
- {
- super();
- }
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#loop()
- */
- @Override
- public boolean loop()
- {
- return true;
- }
- @Override
- public void followNext(Next activeNext, AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- WfVertex v = activeNext.getTerminusVertex();
- if (!isInPrev(v))
- v.run(agent, itemPath);
- else
- {
- v.reinit(getID());
- v.run(agent, itemPath);
- }
- }
- /**
- * @throws InvalidDataException
- * @see com.c2kernel.lifecycle.instance.WfVertex#reinit(int)
- */
- @Override
- public void reinit(int idLoop) throws InvalidDataException
- {
- Logger.msg(8, "Loop.reinit");
- if (idLoop == getID())
- return;
- else
- {
- Vertex[] outVertices = getOutGraphables();
- for (int j = 0; j < outVertices.length; j++)
- {
- if (!isInPrev(outVertices[j]))
- ((WfVertex) outVertices[j]).reinit(idLoop);
- }
- }
- }
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#verify()
- */
- @Override
- public boolean verify()
- {
- boolean err = super.verify();
- Vertex[] nexts = getOutGraphables();
- Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
- int k = 0;
- int l = 0;
- Vertex[] brothers = getParent().getChildren();
- for (Vertex brother : brothers)
- if (brother instanceof Loop)
- l++;
- for (Vertex next : nexts) {
- for (Vertex anteVertice : anteVertices)
- if (next.getID() == anteVertice.getID())
- k++;
- }
- if (k != 1 && !(l > 1))
- {
- mErrors.add("bad number of pointing back nexts");
- return false;
- }
- // if (nexts.length>2) {
- // mErrors.add("you must only have 2 nexts");
- // return false;
- // }
- return err;
- }
- private boolean isInPrev(Vertex vertex)
- {
- int id = vertex.getID();
- Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
- for (Vertex anteVertice : anteVertices) {
- if (anteVertice.getID() == id)
- {
- return true;
- }
- }
- return false;
- }
- @Override
- public boolean isLoop()
- {
- return true;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Next.java b/src/main/java/com/c2kernel/lifecycle/instance/Next.java deleted file mode 100644 index b4e05c8..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/Next.java +++ /dev/null @@ -1,103 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.graph.model.GraphableEdge;
-
-/**
- * @version $Revision: 1.58 $ $Date: 2005/05/10 15:14:54 $
- * @author $Author: abranson $
- */
-/** this class represents the link between 2 successive activities */
-public class Next extends GraphableEdge
-{
- /**
- * @see java.lang.Object#Object()
- */
- public Next()
- {
- super();
- }
-
- /**
- * Method Next.
- * @param pre
- * @param nex
- */
- /** create and initialize a link between an Activities */
- public Next(WfVertex pre, WfVertex nex)
- {
- super(pre, nex);
- getProperties().put("Alias","");
- getProperties().put("Type","Straight");
- }
-
- /**
- * Method verify.
- * @return boolean
- */
- public boolean verify()
- {
- return true;
- }
- public WfVertex getTerminusVertex()
- {
- return (WfVertex)((CompositeActivity)getParent()).getWf().search(getParent().getPath()+"/"+this.getTerminusVertexId());
- }
- @Override
- public boolean containsPoint(GraphPoint p)
- {
- GraphPoint originPoint = getOriginPoint();
- GraphPoint terminusPoint = getTerminusPoint();
- GraphPoint midPoint = new GraphPoint();
-
- if (("Broken +".equals(getProperties().get("Type"))))
- {
- midPoint.x = (originPoint.x + terminusPoint.x) / 2;
- midPoint.y = (originPoint.y + terminusPoint.y) / 2;
- }
- else if (("Broken -".equals(getProperties().get("Type"))))
- {
- boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
- midPoint.x = arrowOnY ? terminusPoint.x : (originPoint.x + terminusPoint.x) / 2;
- midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : originPoint.y;
- }
- else if (("Broken |".equals(getProperties().get("Type"))))
- {
- boolean arrowOnY = !(originPoint.y - terminusPoint.y < 60 && originPoint.y - terminusPoint.y > -60);
- midPoint.x = arrowOnY ? originPoint.x : (originPoint.x + terminusPoint.x) / 2;
- midPoint.y = arrowOnY ? (originPoint.y + terminusPoint.y) / 2 : terminusPoint.y;
- }
- else
- {
- midPoint.x = originPoint.x + (terminusPoint.x - originPoint.x) / 2;
- midPoint.y = originPoint.y + (terminusPoint.y - originPoint.y) / 2;
- }
-
- int minX = midPoint.x - 10;
- int minY = midPoint.y - 10;
- int maxX = midPoint.x + 10;
- int maxY = midPoint.y + 10;
-
- return (p.x >= minX) && (p.x <= maxX) && (p.y >= minY) && (p.y <= maxY);
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java b/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java deleted file mode 100644 index 349000d..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java +++ /dev/null @@ -1,89 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-import java.util.StringTokenizer;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.graph.model.DirectedEdge;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.scripting.ScriptingEngineException;
-import com.c2kernel.utils.Logger;
-/**
- * @version $Revision: 1.22 $ $Date: 2005/05/10 15:14:54 $
- * @author $Author: abranson $
- */
-public class OrSplit extends Split
-{
- /**
- * @see java.lang.Object#Object()
- */
- public OrSplit()
- {
- super();
- }
- @Override
- public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- String nexts;
- String scriptName = (String) getProperties().get("RoutingScriptName");
- Integer scriptVersion = getVersionNumberProperty("RoutingScriptVersion");
- try {
- nexts = this.evaluateScript(scriptName, scriptVersion, itemPath).toString();
- } catch (ScriptingEngineException e) {
- Logger.error(e);
- throw new InvalidDataException("Error running routing script "+scriptName+" v"+scriptVersion);
- }
- StringTokenizer tok = new StringTokenizer(nexts, ",");
- Logger.msg(7, tok.countTokens() + " nexts to activate:" + nexts);
- int active = 0;
- try
- {
- DirectedEdge[] outEdges = getOutEdges();
- AdvancementCalculator adv = new AdvancementCalculator();
- adv.calculate((CompositeActivity)getParent());
- while (tok.hasMoreTokens())
- {
- String thisNext = tok.nextToken();
- Logger.msg(7, "Finding next " + thisNext);
- for (DirectedEdge outEdge : outEdges) {
- Next nextEdge = (Next) outEdge;
- if (thisNext != null && thisNext.equals(nextEdge.getProperties().get("Alias")))
- {
- WfVertex term = nextEdge.getTerminusVertex();
- term.run(agent, itemPath);
- Logger.msg(7, "Running " + nextEdge.getProperties().get("Alias"));
- active++;
- }
- }
- }
- // if no active nexts throw exception
- }
- catch (Exception e)
- {
- Logger.error(e);
- }
- if (active == 0)
- throw new InvalidDataException("No nexts were activated!");
- }
-
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Split.java b/src/main/java/com/c2kernel/lifecycle/instance/Split.java deleted file mode 100644 index d4fb0fd..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/Split.java +++ /dev/null @@ -1,238 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-
-import java.util.Vector;
-
-import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.graph.traversal.GraphTraversal;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-
-/**
- * @version $Revision: 1.47 $ $Date: 2006/05/29 13:17:45 $
- * @author $Author: abranson $
- */
-public abstract class Split extends WfVertex
-{
- public Vector<String> mErrors;
-
- /**
- * @see java.lang.Object#Object()
- */
- public Split()
- {
- mErrors = new Vector<String>(0, 1);
- getProperties().put("RoutingScriptName", "");
- getProperties().put("RoutingScriptVersion", "");
- }
-
- private boolean loopTested;
-
- /**
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated
- * @see com.c2kernel.lifecycle.instance.WfVertex#runNext()
- */
- @Override
- public abstract void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException;
-
- /**
- * Method addNext.
- *
- * @param idNext
- */
- void addNext(String idNext)
- {
- new Next(this, (WfVertex) getParent().search(idNext));
- }
-
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#addNext(com.c2kernel.lifecycle.instance.WfVertex)
- */
- @Override
- public Next addNext(WfVertex vertex)
- {
- Next nxt = new Next(this, vertex);
- int num = getOutGraphables().length;
- try
- {
- num = Integer.parseInt((String) getProperties().get("LastNum"));
- } catch (Exception e)
- {
- }
- nxt.getProperties().put("Alias", String.valueOf(num));
- getProperties().put("LastNum", String.valueOf(num + 1));
- return nxt;
- }
-
- @Override
- public void reinit(int idLoop) throws InvalidDataException
- {
- Vertex[] outVertices = getOutGraphables();
- for (Vertex outVertice : outVertices)
- ((WfVertex) outVertice).reinit(idLoop);
- }
-
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#verify()
- */
- @Override
- public boolean verify()
- {
- mErrors.removeAllElements();
- int nbInEdgres = getParent().getChildrenGraphModel().getInEdges(this).length;
- if (nbInEdgres == 0 && this.getID() != getParent().getChildrenGraphModel().getStartVertexId())
- {
- mErrors.add("not enough previous");
- return false;
- }
- if (nbInEdgres > 1)
- {
- mErrors.add("Bad nb of previous");
- return false;
- }
- if (getOutEdges().length <= 1 && !(this instanceof Loop))
- {
- mErrors.add("not enough next");
- return false;
- }
- if (!(this instanceof Loop))
- {
- Vertex[] outV = getOutGraphables();
- Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
- boolean loop = false;
- boolean errInLoop = true;
- for (int i = 0; i < outV.length; i++)
- {
- for (int j = 0; j < anteVertices.length; j++)
- if (!loop && outV[i].getID() == anteVertices[j].getID())
- {
- if (outV[i] instanceof Loop)
- {
- loop = true;
- j = anteVertices.length;
- i = outV.length;
- } else
- {
- errInLoop = false;
- }
- }
- }
- if (errInLoop && loop)
- {
- mErrors.add("Problem in Loop");
- return false;
- }
- }
- return true;
- }
-
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#getErrors()
- */
- @Override
- public String getErrors()
- {
- if (mErrors.size() == 0)
- return "No error";
- else
- return mErrors.elementAt(0);
- }
-
- /**
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated
- * @see com.c2kernel.lifecycle.instance.WfVertex#run()
- */
- @Override
- public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- runNext(agent, itemPath);
- }
-
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#loop()
- */
- @Override
- public boolean loop()
- {
- boolean loop2 = false;
- if (!loopTested)
- {
- loopTested = true;
- if (getOutGraphables().length != 0)
- {
- Vertex[] outVertices = getOutGraphables();
- for (int i = 0; i < outVertices.length; i++)
- {
- WfVertex tmp = (WfVertex) getOutGraphables()[i];
- loop2 = loop2 || tmp.loop();
- }
- }
- }
- loopTested = false;
- return loop2;
- }
-
- public String[] nextNames()
- {
- Vertex[] vs = getOutGraphables();
- String[] result = new String[vs.length];
- for (int i = 0; i < vs.length; i++)
- result[i] = vs[i].getName();
- return result;
- }
-
- protected boolean isInTable(String test, String[] list)
- {
- if (test == null)
- return false;
- for (String element : list)
- if (test.equals(element))
- return true;
- return false;
- }
-
- @Override
- public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- runNext(agent, itemPath);
- }
-
-}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java deleted file mode 100644 index 9bf0fd4..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java +++ /dev/null @@ -1,222 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-
-
-
-import java.util.HashMap;
-
-import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.graph.model.GraphableVertex;
-import com.c2kernel.lifecycle.routingHelpers.ViewpointDataHelper;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.scripting.Script;
-import com.c2kernel.scripting.ScriptingEngineException;
-import com.c2kernel.utils.KeyValuePair;
-import com.c2kernel.utils.Logger;
-
-/**
- * @version $Revision: 1.38 $ $Date: 2005/09/07 13:46:31 $
- * @author $Author: abranson $
- */
-public abstract class WfVertex extends GraphableVertex
-{
- /**sets the activity available to be executed on start of Workflow or composite activity (when it is the first one of the
- * (sub)process
- * @throws InvalidDataException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectCannotBeUpdated */
- public abstract void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidDataException;
-
- /**
- * @see java.lang.Object#Object()
- */
- public WfVertex()
- {
- super();
- setIsLayoutable(true);
- setIsComposite(false);
- }
-
- /**
- * Method runNext.
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated
- */
- public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- try
- {
- ((CompositeActivity)getParent()).request(agent, itemPath, CompositeActivity.COMPLETE, null);
- }
- catch (Exception e)
- {
- //Logger.error(e);
- }
-
- }
-
- /**
- * Method reinit.
- * @param idLoop
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- */
- public abstract void reinit( int idLoop ) throws InvalidDataException;
-
- /**
- * Method verify.
- * @return boolean
- */
- public abstract boolean verify();
-
- /**
- * Method getErrors.
- * @return String
- */
- public abstract String getErrors();
-
- /**
- * Method run.
- * @throws InvalidDataException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws PersistencyException
- * @throws ObjectCannotBeUpdated
- */
- public abstract void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException;
-
- /**
- * Method loop.
- * @return boolean
- */
- public abstract boolean loop();
-
- /**
- * Method addNext.
- * @param vertex
- */
- public abstract Next addNext(WfVertex vertex);
-
- protected Object evaluateScript(String scriptName, Integer scriptVersion, ItemPath itemPath) throws ScriptingEngineException
- {
-
- try
- {
- Script script = getScript(scriptName, scriptVersion);
-
- KeyValuePair[] k = getProperties().getKeyValuePairs();
- HashMap<?, ?> requiredInput = script.getAllInputParams();
- for (KeyValuePair element : k) {
- if (requiredInput.containsKey(element.getKey()))
- {
- String value = element.getStringValue();
- Object inputParam = value;
-
- if (value.startsWith("viewpoint//"))
- {
- value = value.substring(11);
- if (value.startsWith("."))
- value = itemPath.getUUID() + value.substring(1);
- try {
- inputParam = ViewpointDataHelper.get(value)[0];
- } catch (ArrayIndexOutOfBoundsException ex) {
- throw new InvalidDataException("Could not retrieve data from viewpoint: "+value);
- }
- }
- if (value.startsWith("property//"))
- {
- value = value.substring(10);
- try {
- inputParam = Gateway.getStorage().get(itemPath, ClusterStorage.PROPERTY+"/"+value, null);
- } catch (ObjectNotFoundException ex) {
- inputParam = null;
- }
- }
- Logger.msg(5, "Split.evaluateScript() - Setting param " + element.getKey() + " to " + inputParam);
- script.setInputParamValue(element.getKey(), inputParam);
- }
- }
-
- //TODO: is this right?
- if (requiredInput.containsKey("item")) {
- script.setInputParamValue("item", Gateway.getProxyManager().getProxy(itemPath));
- }
- if (requiredInput.containsKey("agent")) {
- AgentPath systemAgent = Gateway.getLookup().getAgentPath("system");
- script.setInputParamValue("agent", Gateway.getProxyManager().getProxy(systemAgent));
- }
- Object retVal = script.execute();
- Logger.msg(2, "Split.evaluateScript() - Script returned "+retVal);
- if (retVal == null) retVal = "";
- return retVal;
- }
- catch (Exception e)
- {
- Logger.msg(1, "Split.evaluateScript() - Error: Script " + scriptName);
- Logger.error(e);
- throw new ScriptingEngineException();
- }
- }
-
- private static Script getScript(String name, Integer version) throws ScriptingEngineException
- {
- if (name == null || name.length() == 0)
- throw new ScriptingEngineException("Script name is empty");
- Script script;
- if (version!=null) {
- script = new Script(name, version);
- }
- else { // empty version: try expression
- int split = name.indexOf(":");
- script = new Script(name.substring(0, split), name.substring(split + 1));
- }
-
- return script;
- }
-
-
- public Workflow getWf()
- {
- return ((CompositeActivity)getParent()).getWf();
- }
-}
-
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/WfVertexOutlineCreator.java b/src/main/java/com/c2kernel/lifecycle/instance/WfVertexOutlineCreator.java deleted file mode 100644 index e13b4e3..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/WfVertexOutlineCreator.java +++ /dev/null @@ -1,69 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.graph.model.VertexOutlineCreator;
-
-public class WfVertexOutlineCreator implements VertexOutlineCreator
-{
- private static final int mActivityWidth = 130;
- private static final int mActivityHeight = 60;
- private static final int mSplitJoinWidth = 60;
- private static final int mSplitJoinHeight = 25;
-
- @Override
- public void setOutline(Vertex vertex)
- {
- GraphPoint centrePoint = vertex.getCentrePoint();
- GraphPoint[] outlinePoints = new GraphPoint[ 4 ];
- int vertexWidth = 0;
- int vertexHeight = 0;
-
- if(vertex instanceof Activity)
- {
- vertexWidth = mActivityWidth;
- vertexHeight = mActivityHeight;
- }
- else
- {
- vertexWidth = mSplitJoinWidth;
- vertexHeight = mSplitJoinHeight;
- }
-
- outlinePoints[ 0 ] = new GraphPoint();
- outlinePoints[ 0 ].x = centrePoint.x - vertexWidth / 2;
- outlinePoints[ 0 ].y = centrePoint.y - vertexHeight / 2;
- outlinePoints[ 1 ] = new GraphPoint();
- outlinePoints[ 1 ].x = centrePoint.x + vertexWidth / 2;
- outlinePoints[ 1 ].y = centrePoint.y - vertexHeight / 2;
- outlinePoints[ 2 ] = new GraphPoint();
- outlinePoints[ 2 ].x = centrePoint.x + vertexWidth / 2;
- outlinePoints[ 2 ].y = centrePoint.y + vertexHeight / 2;
- outlinePoints[ 3 ] = new GraphPoint();
- outlinePoints[ 3 ].x = centrePoint.x - vertexWidth / 2;
- outlinePoints[ 3 ].y = centrePoint.y + vertexHeight / 2;
-
- vertex.setOutlinePoints( outlinePoints );
- }
-}
-
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java b/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java deleted file mode 100644 index f152adc..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java +++ /dev/null @@ -1,265 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-import java.util.ArrayList;
-
-import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidCollectionModification;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.entity.agent.Job;
-import com.c2kernel.events.History;
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.InvalidAgentPathException;
-import com.c2kernel.lookup.InvalidItemPathException;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.utils.Language;
-import com.c2kernel.utils.Logger;
-/**
- * @version $Revision: 1.64 $ $Date: 2005/09/30 07:09:48 $
- * @author $Author: abranson $
- */
-public class Workflow extends CompositeActivity implements C2KLocalObject
-{
- public History history;
- private ItemPath itemPath = null;
-
- /** TypeNameAndConstructionInfo[] variables added by Steve */
- private final TypeNameAndConstructionInfo[] mVertexTypeNameAndConstructionInfo =
- {
- new TypeNameAndConstructionInfo(Language.translate("AND Split"), "AndSplit"),
- new TypeNameAndConstructionInfo(Language.translate("OR Split"), "OrSplit"),
- new TypeNameAndConstructionInfo(Language.translate("XOR Split"), "XOrSplit"),
- new TypeNameAndConstructionInfo(Language.translate("Join"), "Join"),
- new TypeNameAndConstructionInfo(Language.translate("Loop"), "LoopSplit"),
- new TypeNameAndConstructionInfo(Language.translate("Activity"), "Atomic"),
- new TypeNameAndConstructionInfo(Language.translate("Composite"), "Composite")
- };
- private final TypeNameAndConstructionInfo[] mEdgeTypeNameAndConstructionInfo =
- {
- new TypeNameAndConstructionInfo(Language.translate("Next"), "Next")
- };
- /**
- * @see java.lang.Object#Object()
- */
- public Workflow()
- {
- }
-
- public Workflow(CompositeActivity domain, PredefinedStepContainer predef) {
- this();
- domain.setName("domain");
- initChild(domain, true, new GraphPoint(150, 100));
- addChild(predef, new GraphPoint(300, 100));
- }
-
- public History getHistory() throws InvalidDataException {
- if (history == null) {
- if (itemPath == null)
- throw new InvalidDataException("Workflow not initialized.");
- history = new History(itemPath, this);
- }
- return history;
- }
-
- /**
- * Method getVertexTypeNameAndConstructionInfo.
- *
- * @return TypeNameAndConstructionInfo[]
- */
- /** getVertexTypeNameAndConstructionInfo() added by Steve */
- public TypeNameAndConstructionInfo[] getVertexTypeNameAndConstructionInfo()
- {
- return mVertexTypeNameAndConstructionInfo;
- }
- /**
- * Method getEdgeTypeNameAndConstructionInfo.
- *
- * @return TypeNameAndConstructionInfo[]
- */
- /** getVertexTypeNameAndConstructionInfo() added by Steve */
- public TypeNameAndConstructionInfo[] getEdgeTypeNameAndConstructionInfo()
- {
- return mEdgeTypeNameAndConstructionInfo;
- }
- /**
- * Method requestAction.
- *
- * @param agentInfo
- * @param stepPath
- * @param transitionID
- * @param reguestData
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws InvalidDataException
- * @throws PersistencyException
- * @throws ObjectCannotBeUpdated
- * @throws CannotManageException
- * @throws InvalidCollectionModification
- */
- //requestData is xmlstring
- public String requestAction(AgentPath agent, String stepPath, ItemPath itemPath, int transitionID, String requestData)
- throws ObjectNotFoundException, AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectCannotBeUpdated, CannotManageException, InvalidCollectionModification
- {
- Logger.msg(3, "Action: " + transitionID + " " + stepPath + " by " + agent);
- if (search(stepPath) != null)
- return ((Activity) search(stepPath)).request(agent, itemPath, transitionID, requestData);
- else
- throw new ObjectNotFoundException(stepPath + " not found");
- }
-
- /**
- * @see com.c2kernel.graph.model.GraphableVertex#getPath()
- */
- @Override
- public String getPath()
- {
- return "workflow";
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#getName()
- */
- @Override
- public String getName()
- {
- return "workflow";
- }
- /**
- * @see com.c2kernel.lifecycle.instance.Activity#getType()
- */
- @Override
- public String getType()
- {
- return "workflow";
- }
- /**
- * @see com.c2kernel.graph.model.Vertex#setName(java.lang.String)
- */
- @Override
- public void setName(String name)
- {
- }
- /**
- * @see com.c2kernel.lifecycle.instance.WfVertex#verify()
- */
- @Override
- public boolean verify()
- {
- for (int i = 0; i < getChildren().length; i++)
- {
- if (!((WfVertex) getChildren()[i]).verify())
- {
- mErrors.add("error in children");
- return false;
- }
- }
- return true;
- }
- /**
- * @see com.c2kernel.lifecycle.instance.Activity#getWf()
- */
- @Override
- public Workflow getWf()
- {
- return this;
- }
- /**
- * Method initialise.
- *
- * @param systemKey
- * @throws InvalidDataException
- * @throws ObjectNotFoundException
- * @throws AccessRightsException
- * @throws InvalidTransitionException
- * @throws ObjectAlreadyExistsException
- * @throws ObjectCannotBeUpdated
- */
- public void initialise(ItemPath itemPath, AgentPath agent) throws InvalidDataException
- {
- setItemPath(itemPath);
- runFirst(agent, itemPath);
- }
-
- public ItemPath getItemPath() {
- return itemPath;
- }
-
- public void setItemPath(ItemPath itemPath) {
- this.itemPath = itemPath;
- }
-
- public void setItemUUID( String uuid ) throws InvalidItemPathException
- {
- setItemPath(new ItemPath(uuid));
- }
-
- public String getItemUUID() {
- return getItemPath().getUUID().toString();
- }
-
- /**
- * if type = 0 only domain steps will be queried if type = 1 only predefined steps will be queried else both will be queried
- * @param agent
- * @param itemSysKey
- * @param type
- * @return
- * @throws ObjectNotFoundException
- * @throws InvalidDataException
- * @throws InvalidAgentPathException
- */
- public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, int type) throws InvalidAgentPathException, ObjectNotFoundException, InvalidDataException
- {
- ArrayList<Job> jobs = new ArrayList<Job>();
- if (type != 1)
- jobs.addAll(((CompositeActivity) search("workflow/domain")).calculateJobs(agent, itemPath, true));
- if (type != 0)
- jobs.addAll(((CompositeActivity) search("workflow/predefined")).calculateJobs(agent, itemPath, true));
- return jobs;
- }
- /**
- * @see com.c2kernel.lifecycle.instance.CompositeActivity#hasGoodNumberOfActivity()
- */
- @Override
- public boolean hasGoodNumberOfActivity()
- {
- return true;
- }
- /**
- * @see com.c2kernel.entity.C2KLocalObject#getClusterType()
- */
- @Override
- public String getClusterType()
- {
- return ClusterStorage.LIFECYCLE;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java b/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java deleted file mode 100644 index 7b47fd5..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java +++ /dev/null @@ -1,83 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance;
-
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.graph.model.DirectedEdge;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.scripting.ScriptingEngineException;
-import com.c2kernel.utils.Logger;
-
-/**
- * @version $Revision: 1.23 $ $Date: 2006/03/03 13:52:21 $
- * @author $Author: abranson $
- */
-public class XOrSplit extends Split
-{
- /**
- * @see java.lang.Object#Object()
- */
- public XOrSplit()
- {
- super();
- }
-
- @Override
- public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException
- {
- ArrayList<DirectedEdge> nextsToFollow = new ArrayList<DirectedEdge>();
- String nexts;
- String scriptName = (String) getProperties().get("RoutingScriptName");
- Integer scriptVersion = getVersionNumberProperty("RoutingScriptVersion");
- try {
- nexts = this.evaluateScript(scriptName, scriptVersion, itemPath).toString();
- } catch (ScriptingEngineException e) {
- Logger.error(e);
- throw new InvalidDataException("Error running routing script "+scriptName+" v"+scriptVersion);
- }
-
- StringTokenizer tok = new StringTokenizer(nexts,",");
- String[] nextsTab = new String[tok.countTokens()];
- for (int i=0;i<nextsTab.length;i++)
- nextsTab[i] = tok.nextToken();
-
- DirectedEdge[] outEdges = getOutEdges();
- for (DirectedEdge outEdge : outEdges) {
- if (isInTable((String)((Next)outEdge).getProperties().get("Alias"), nextsTab))
- nextsToFollow.add(outEdge);
- }
-// Logger.debug(0, getID()+" following "+nexts);
- if (nextsToFollow.size() != 1)
- throw new InvalidDataException("not good number of active next");
-
- followNext((Next)nextsToFollow.get(0), agent, itemPath);
-
- }
-
- public void followNext(Next activeNext, AgentPath agent, ItemPath itemPath) throws InvalidDataException {
- activeNext.getTerminusVertex().run(agent, itemPath);
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java deleted file mode 100644 index a39e815..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java +++ /dev/null @@ -1,66 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-import java.util.Arrays;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
- * @version $Revision: 1.31 $
- **************************************************************************/
-public class AddC2KObject extends PredefinedStep
-{
- /**************************************************************************
- * Constructor for Castror
- **************************************************************************/
- public AddC2KObject()
- {
- super();
- getProperties().put("Agent Role", "Admin");
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, PersistencyException {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1) throw new InvalidDataException("AddC2KObject: Invalid parameters "+Arrays.toString(params));
- C2KLocalObject obj;
- try {
- obj = (C2KLocalObject)Gateway.getMarshaller().unmarshall(params[0]);
- } catch (Exception e) {
- throw new InvalidDataException("AddC2KObject: Could not unmarshall new object: "+params[0]);
- }
- Gateway.getStorage().put(item, obj, null );
- return requestData;
- }
-}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java deleted file mode 100644 index 8723d3b..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java +++ /dev/null @@ -1,61 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-
-
-import java.util.Arrays;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.DomainPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.LookupManager;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class AddDomainPath extends PredefinedStep
-{
- public AddDomainPath()
- {
- super();
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "AddDomainPath: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1) throw new InvalidDataException("AddDomainPath: Invalid parameters "+Arrays.toString(params));
-
- LookupManager lookupManager = Gateway.getLookupManager();
-
- DomainPath domainPath = new DomainPath(params[0], item);
- lookupManager.add(domainPath);
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java deleted file mode 100644 index 90db8e1..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java +++ /dev/null @@ -1,104 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-import java.util.Arrays;
-
-import com.c2kernel.collection.Dependency;
-import com.c2kernel.common.InvalidCollectionModification;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.CastorHashMap;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
- * @version $Revision: 1.8 $
- **************************************************************************/
-public class AddMemberToCollection extends PredefinedStep
-{
- /**************************************************************************
- * Constructor for Castor
- **************************************************************************/
- public AddMemberToCollection()
- {
- super();
- }
-
-
- /**
- * Generates a new slot in a Dependency for the given item
- *
- * Params:
- * 0 - collection name
- * 1 - target entity key
- * @throws ObjectAlreadyExistsException
- * @throws PersistencyException
- * @throws ObjectNotFoundException
- * @throws InvalidCollectionModification
- */
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException, InvalidCollectionModification {
-
- String collName;
- ItemPath newChild;
- Dependency dep;
- CastorHashMap props = null;
-
- // extract parameters
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "AddMemberToCollection: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- try {
- collName = params[0];
- newChild = new ItemPath(params[1]);
- if (params.length > 2)
- props = (CastorHashMap)Gateway.getMarshaller().unmarshall(params[2]);
-
- } catch (Exception e) {
- throw new InvalidDataException("AddMemberToCollection: Invalid parameters "+Arrays.toString(params));
- }
-
- // load collection
- C2KLocalObject collObj;
- collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null);
- if (!(collObj instanceof Dependency)) throw new InvalidDataException("AddMemberToCollection: AddMemberToCollection operates on Dependency collections only.");
- dep = (Dependency)collObj;
-
- // find member and assign entity
- if (props == null)
- dep.addMember(newChild);
- else
- dep.addMember(newChild, props, null);
-
- Gateway.getStorage().put(newChild, dep, null);
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java deleted file mode 100644 index 99fd666..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java +++ /dev/null @@ -1,109 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-import java.util.Arrays;
-
-import com.c2kernel.collection.AggregationDescription;
-import com.c2kernel.collection.CollectionDescription;
-import com.c2kernel.collection.DependencyDescription;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
- * @version $Revision: 1.8 $
- **************************************************************************/
-public class AddNewCollectionDescription extends PredefinedStep
-{
- /**************************************************************************
- * Constructor for Castor
- **************************************************************************/
- public AddNewCollectionDescription()
- {
- super();
- }
-
-
- /**
- * Generates a new empty collection description. Collection instances should
- * be added by an Admin, who can do so using AddC2KObject.
- *
- * Params:
- * 0 - collection name
- * 1 - collection type (Aggregation, Dependency)
- * @throws PersistencyException
- */
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException {
-
- String collName;
- String collType;
-
- // extract parameters
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "AddNewCollectionDescription: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 2)
- throw new InvalidDataException("AddNewCollectionDescription: Invalid parameters "+Arrays.toString(params));
-
- collName = params[0];
- collType = params[1];
-
- // check if collection already exists
- try {
- Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null);
- throw new ObjectAlreadyExistsException("Collection '"+collName+"' already exists");
- } catch (ObjectNotFoundException ex) {
- // collection doesn't exist
- } catch (PersistencyException ex) {
- Logger.error(ex);
- throw new PersistencyException("AddNewCollectionDescription: Error checking for collection '"+collName+"': "+ex.getMessage());
- }
-
-
- CollectionDescription<?> newCollDesc;
-
- if (collType.equals("Aggregation"))
- newCollDesc = new AggregationDescription(collName);
- if (collType.equals("Dependency"))
- newCollDesc = new DependencyDescription(collName);
- else
- throw new InvalidDataException("AddNewCollectionDescription: Invalid collection type specified: '"+collType+"'. Must be Aggregation or Dependency.");
-
- // store it
- try {
- Gateway.getStorage().put(item, newCollDesc, null);
- } catch (PersistencyException e) {
- throw new PersistencyException("AddNewCollectionDescription: Error saving new collection '"+collName+"': "+e.getMessage());
- }
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java deleted file mode 100644 index 3d9e5d3..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java +++ /dev/null @@ -1,127 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-import java.util.Arrays;
-
-import com.c2kernel.collection.Aggregation;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.property.PropertyDescription;
-import com.c2kernel.property.PropertyDescriptionList;
-import com.c2kernel.property.PropertyUtility;
-import com.c2kernel.utils.CastorHashMap;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
- * @version $Revision: 1.8 $
- **************************************************************************/
-public class AddNewSlot extends PredefinedStep
-{
- /**************************************************************************
- * Constructor for Castor
- **************************************************************************/
- public AddNewSlot()
- {
- super();
- }
-
-
- /**
- * Creates a new slot in the given aggregation, that holds instances of the given item description
- *
- * Params:
- * <ol><li>Collection name</li>
- * <li>Item Description key (optional)</li>
- * <li>Item Description version (optional)</li>
- * </ol>
- *
- * @throws InvalidDataException Then the parameters were incorrect
- * @throws PersistencyException There was a problem loading or saving the collection from persistency
- * @throws ObjectNotFoundException A required object, such as the collection or a PropertyDescription outcome, wasn't found
- */
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, PersistencyException, ObjectNotFoundException {
-
- String collName;
- ItemPath descKey = null;
- String descVer = "last";
- Aggregation agg;
-
- // extract parameters
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "AddNewSlot: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
-
- // resolve desc item path and version
- try {
- collName = params[0];
- if (params.length > 1 && params[1].length() > 0) descKey = new ItemPath(params[1]);
- if (params.length > 2 && params[2].length() > 0) descVer = params[2];
- } catch (Exception e) {
- throw new InvalidDataException("AddNewSlot: Invalid parameters "+Arrays.toString(params));
- }
-
- // load collection
- C2KLocalObject collObj;
- try {
- collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null);
- } catch (PersistencyException ex) {
- Logger.error(ex);
- throw new PersistencyException("AddNewSlot: Error loading collection '\"+collName+\"': "+ex.getMessage());
- }
- if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AddNewSlot: AddNewSlot operates on Aggregation collections only.");
- agg = (Aggregation)collObj;
-
- // get props
- CastorHashMap props = new CastorHashMap();
- StringBuffer classProps = new StringBuffer();
- if (descKey != null) {
- PropertyDescriptionList propList;
- propList = PropertyUtility.getPropertyDescriptionOutcome(descKey, descVer);
- for (PropertyDescription pd : propList.list) {
- props.put(pd.getName(), pd.getDefaultValue());
- if (pd.getIsClassIdentifier())
- classProps.append((classProps.length()>0?",":"")).append(pd.getName());
- }
- }
-
- agg.addSlot(props, classProps.toString());
-
- try {
- Gateway.getStorage().put(item, agg, null);
- } catch (PersistencyException e) {
- Logger.error(e);
- throw new PersistencyException("AddNewSlot: Error saving collection '"+collName+"': "+e.getMessage());
- }
-
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java deleted file mode 100644 index 04d6770..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java +++ /dev/null @@ -1,120 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-import java.util.Arrays;
-
-import com.c2kernel.collection.Aggregation;
-import com.c2kernel.collection.AggregationMember;
-import com.c2kernel.common.InvalidCollectionModification;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
- * @version $Revision: 1.8 $
- **************************************************************************/
-public class AssignItemToSlot extends PredefinedStep
-{
- /**************************************************************************
- * Constructor for Castor
- **************************************************************************/
- public AssignItemToSlot()
- {
- super();
- }
-
-
- /**
- * Params:
- * 0 - collection name
- * 1 - slot number
- * 2 - target entity key
- * @throws ObjectNotFoundException
- * @throws PersistencyException
- * @throws ObjectCannotBeUpdated
- * @throws InvalidCollectionModification
- */
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, PersistencyException, ObjectCannotBeUpdated, InvalidCollectionModification {
-
- String collName;
- int slotNo;
- ItemPath childItem;
- Aggregation agg;
-
- // extract parameters
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "AssignItemToSlot: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
-
- try {
- collName = params[0];
- slotNo = Integer.parseInt(params[1]);
- childItem = new ItemPath(params[2]);
- } catch (Exception e) {
- throw new InvalidDataException("AssignItemToSlot: Invalid parameters "+Arrays.toString(params));
- }
-
- // load collection
- C2KLocalObject collObj;
- try {
- collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null);
- } catch (PersistencyException ex) {
- Logger.error(ex);
- throw new PersistencyException("AssignItemToSlot: Error loading collection '\"+collName+\"': "+ex.getMessage());
- }
- if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AssignItemToSlot: AssignItemToSlot operates on Aggregation collections only.");
- agg = (Aggregation)collObj;
-
- // find member and assign entity
- boolean stored = false;
- for (AggregationMember member : agg.getMembers().list) {
- if (member.getID() == slotNo) {
- if (member.getItemPath() != null)
- throw new ObjectCannotBeUpdated("AssignItemToSlot: Member slot "+slotNo+" not empty");
- member.assignItem(childItem);
- stored = true;
- break;
- }
- }
- if (!stored) {
- throw new ObjectNotFoundException("AssignItemToSlot: Member slot "+slotNo+" not found.");
- }
-
- try {
- Gateway.getStorage().put(item, agg, null);
- } catch (PersistencyException e) {
- throw new PersistencyException("AssignItemToSlot: Error saving collection '"+collName+"': "+e.getMessage());
- }
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java deleted file mode 100644 index 1bfb8d0..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java +++ /dev/null @@ -1,113 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-import java.util.Arrays;
-
-import com.c2kernel.collection.Aggregation;
-import com.c2kernel.collection.AggregationMember;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
- * @version $Revision: 1.8 $
- **************************************************************************/
-public class ClearSlot extends PredefinedStep
-{
- /**************************************************************************
- * Constructor for Castor
- **************************************************************************/
- public ClearSlot()
- {
- super();
- }
-
-
- /**
- * Params:
- * 0 - collection name
- * 1 - slot number
- * @throws ObjectNotFoundException
- * @throws PersistencyException
- * @throws ObjectCannotBeUpdated
- */
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, PersistencyException, ObjectCannotBeUpdated {
-
- String collName;
- int slotNo;
- Aggregation agg;
-
- // extract parameters
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "ClearSlot: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
-
- try {
- collName = params[0];
- slotNo = Integer.parseInt(params[1]);
- } catch (Exception e) {
- throw new InvalidDataException("ClearSlot: Invalid parameters "+Arrays.toString(params));
- }
-
- // load collection
- try {
- agg = (Aggregation)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null);
- } catch (PersistencyException ex) {
- Logger.error(ex);
- throw new PersistencyException("ClearSlot: Error loading collection '"+collName+"': "+ex.getMessage());
- }
-
- // find member and clear
- boolean stored = false;
- for (AggregationMember member : agg.getMembers().list) {
- if (member.getID() == slotNo) {
- if (member.getItemPath() != null)
- throw new ObjectCannotBeUpdated("ClearSlot: Member slot "+slotNo+" already empty");
- member.clearItem();
- stored = true;
- break;
- }
- }
- if (!stored) {
- throw new ObjectNotFoundException("ClearSlot: Member slot "+slotNo+" not found.");
- }
-
-
- try {
- Gateway.getStorage().put(item, agg, null);
- } catch (PersistencyException e) {
- Logger.error(e);
- throw new PersistencyException("ClearSlot: Error storing collection");
- }
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateNewCollectionVersion.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateNewCollectionVersion.java deleted file mode 100644 index 8e68ae3..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateNewCollectionVersion.java +++ /dev/null @@ -1,102 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-import java.util.Arrays;
-
-import com.c2kernel.collection.Collection;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
- * @version $Revision: 1.8 $
- **************************************************************************/
-public class CreateNewCollectionVersion extends PredefinedStep
-{
- /**************************************************************************
- * Constructor for Castor
- **************************************************************************/
- public CreateNewCollectionVersion()
- {
- super();
- }
-
-
- /**
- * Generates a new snapshot of a collection from its current state. The
- * new version is given the next available number, starting at 0.
- *
- * Params:
- * 0 - Collection name
- * @throws InvalidDataException
- * @throws PersistencyException
- *
- * @throws ObjectNotFoundException when there is no collection present with
- * that name
- */
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, PersistencyException, ObjectNotFoundException
- {
- String collName;
-
- // extract parameters
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "CreateNewCollectionVersion: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1)
- throw new InvalidDataException("CreateNewCollectionVersion: Invalid parameters "+Arrays.toString(params));
-
- collName = params[0];
- Collection<?> coll = (Collection<?>)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null);
-
- // find last numbered version
- int lastVer = -1;
- String[] versions = Gateway.getStorage().getClusterContents(item, ClusterStorage.COLLECTION+"/"+collName);
- for (String thisVerStr : versions) {
- try {
- int thisVer = Integer.parseInt(thisVerStr);
- if (thisVer > lastVer) lastVer = thisVer;
- } catch (NumberFormatException ex) { } // ignore non-integer versions
- }
-
- // Remove it from the cache before we change it
- Gateway.getStorage().clearCache(item, ClusterStorage.COLLECTION+"/"+collName+"/last");
- // Set the version
- coll.setVersion(lastVer+1);
-
- // store it
- try {
- Gateway.getStorage().put(item, coll, null);
- } catch (PersistencyException e) {
- throw new PersistencyException("CreateNewCollectionVersion: Error saving new collection '"+collName+"': "+e.getMessage());
- }
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java deleted file mode 100644 index 12cb488..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java +++ /dev/null @@ -1,105 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-import java.util.Arrays;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.events.Event;
-import com.c2kernel.events.History;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.TransactionManager;
-import com.c2kernel.persistency.outcome.Outcome;
-import com.c2kernel.persistency.outcome.Viewpoint;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * $Revision: 1.21 $
- * $Date: 2005/06/02 12:17:22 $
- *
- * Params: Schemaname_version:Viewpoint (optional), Outcome, Timestamp (optional
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-public class Import extends PredefinedStep
-{
- public Import()
- {
- super();
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, PersistencyException {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "Import: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
-
- int split1 = params[0].indexOf('_');
- int split2 = params[0].indexOf(':');
-
- if (split1 == -1)
- throw new InvalidDataException("Import: Invalid parameters "+Arrays.toString(params));
-
- requestData = params[1];
-
- String schemaName = params[0].substring(0, split1);
- String viewpoint = null;
- int schemaVersion;
- if (split2 > -1) {
- schemaVersion = Integer.parseInt(params[0].substring(split1+1, split2));
- viewpoint = params[0].substring(split2+1);
- }
- else
- schemaVersion = Integer.parseInt(params[0].substring(split1+1));
-
- String timestamp;
- if (params.length == 3)
- timestamp = params[2];
- else
- timestamp = Event.timeToString(Event.getGMT());
-
- // write event, outcome and viewpoints to storage
-
- TransactionManager storage = Gateway.getStorage();
- Object locker = getWf();
- History hist = getWf().getHistory();
- Event event = hist.addEvent(agent, getCurrentAgentRole(), getName(), getPath(), getType(), schemaName, schemaVersion, getStateMachine().getName(), getStateMachine().getVersion(), getStateMachine().getTransition(transitionID), viewpoint, timestamp);
-
- try {
- storage.put(item, new Outcome(event.getID(), requestData, schemaName, schemaVersion), locker);
- storage.put(item, new Viewpoint(item, schemaName, viewpoint, schemaVersion, event.getID()), locker);
- if (!"last".equals(viewpoint))
- storage.put(item, new Viewpoint(item, schemaName, "last", schemaVersion, event.getID()), locker);
- } catch (PersistencyException e) {
- storage.abort(locker);
- throw e;
- }
- storage.commit(locker);
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java deleted file mode 100644 index 9b6d6c4..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java +++ /dev/null @@ -1,191 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-import java.io.StringReader;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-
-import com.c2kernel.lifecycle.instance.Activity;
-import com.c2kernel.lifecycle.instance.predefined.agent.AgentPredefinedStepContainer;
-import com.c2kernel.lifecycle.instance.predefined.item.ItemPredefinedStepContainer;
-import com.c2kernel.lifecycle.instance.predefined.server.ServerPredefinedStepContainer;
-import com.c2kernel.persistency.outcome.Outcome;
-import com.c2kernel.utils.Logger;
-/***********************************************************************************************************************************************************************************************************************************************************************************************************
- * @author $Author: sgaspard $ $Date: 2004/09/21 10:32:17 $
- * @version $Revision: 1.14 $
- **********************************************************************************************************************************************************************************************************************************************************************************************************/
-public abstract class PredefinedStep extends Activity
-{
- /*******************************************************************************************************************************************************************************************************************************************************************************************************
- * predefined Steps are always Active, and have only one transition subclasses could override this method (if necessary)
- ******************************************************************************************************************************************************************************************************************************************************************************************************/
-
- private boolean isPredefined = false;
- public static final int DONE = 0;
- public static final int AVAILABLE = 0;
-
- public PredefinedStep() {
- super();
- getProperties().put("SchemaType", "PredefinedStepOutcome");
- getProperties().put("SchemaVersion", "0");
- }
-
- @Override
- public boolean getActive()
- {
- if (isPredefined)
- return true;
- else
- return super.getActive();
- }
-
-
-
- @Override
- protected String getDefaultSMName() {
- return "PredefinedStep";
- }
-
- @Override
- public String getErrors()
- {
- if (isPredefined)
- return getName();
- else
- return super.getErrors();
- }
- @Override
- public boolean verify()
- {
- if (isPredefined)
- return true;
- else
- return super.verify();
- }
- /**
- * Returns the isPredefined.
- *
- * @return boolean
- */
- public boolean getIsPredefined()
- {
- return isPredefined;
- }
- /**
- * Sets the isPredefined.
- *
- * @param isPredefined
- * The isPredefined to set
- */
- public void setIsPredefined(boolean isPredefined)
- {
- this.isPredefined = isPredefined;
- }
- @Override
- public String getType()
- {
- return getName();
- }
-
- static public String getPredefStepSchemaName(String stepName) {
- PredefinedStepContainer[] allSteps = { new ItemPredefinedStepContainer(), new AgentPredefinedStepContainer(), new ServerPredefinedStepContainer() };
- for (PredefinedStepContainer thisContainer : allSteps) {
- String stepPath = thisContainer.getName()+"/"+stepName;
- Activity step = (Activity)thisContainer.search(stepPath);
- if (step != null) {
- return (String)step.getProperties().get("SchemaType");
- }
- }
- return "PredefinedStepOutcome"; // default to standard if not found - server may be a newer version
- }
-
- // generic bundling of parameters
- static public String bundleData(String[] data)
- {
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document dom = builder.newDocument();
- Element root = dom.createElement("PredefinedStepOutcome");
- dom.appendChild(root);
- for (String element : data) {
- Element param = dom.createElement("param");
- Text t = dom.createTextNode(element);
- param.appendChild(t);
- root.appendChild(param);
- }
-
- return Outcome.serialize(dom, false);
-
- }
- catch (Exception e)
- {
- Logger.error(e);
- StringBuffer xmlData = new StringBuffer().append("<PredefinedStepOutcome>");
- for (String element : data)
- xmlData.append("<param><![CDATA[").append(element).append("]]></param>");
- xmlData.append("</PredefinedStepOutcome>");
- return xmlData.toString();
- }
- }
-
- // generic bundling of single parameter
- static public String bundleData(String data)
- {
- return bundleData(new String[]{ data });
- }
-
- public static String[] getDataList(String xmlData)
- {
- try
- {
- Document scriptDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xmlData)));
- NodeList nodeList = scriptDoc.getElementsByTagName("param");
- String[] result = new String[nodeList.getLength()];
- for (int i = 0; i < nodeList.getLength(); i++)
- {
- Node n = nodeList.item(i).getFirstChild();
- if (n instanceof CDATASection)
- result[i] = ((CDATASection) n).getData();
- else if (n instanceof Text)
- result[i] = ((Text) n).getData();
- }
- return result;
- }
- catch (Exception ex)
- {
- Logger.error("Exception::PredefinedStep::getDataList()");
- Logger.error(ex);
- }
- return null;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java deleted file mode 100644 index e1f9ffc..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java +++ /dev/null @@ -1,79 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.lifecycle.instance.CompositeActivity;
-public abstract class PredefinedStepContainer extends CompositeActivity
-{
- protected int num = 0;
-
- public PredefinedStepContainer()
- {
- super();
- setName("predefined");
- getProperties().put("Description", "Contains all predefined Steps");
- createChildren();
- }
- public void createChildren()
- {
- predInit("AddDomainPath", "Adds a new path to this entity in the LDAP domain tree", new AddDomainPath());
- predInit("RemoveDomainPath", "Removes an existing path to this Entity from the LDAP domain tree", new RemoveDomainPath());
- predInit("ReplaceDomainWorkflow", "Replaces the domain CA with the supplied one. Used by the GUI to save new Wf layout", new ReplaceDomainWorkflow());
- predInit("AddC2KObject", "Adds or overwrites a C2Kernel object for this Item", new AddC2KObject());
- predInit("RemoveC2KObject", "Removes the named C2Kernel object from this Item.", new RemoveC2KObject());
- predInit("WriteProperty", "Writes a property to the Item", new WriteProperty());
- predInit("WriteViewpoint", "Writes a viewpoint to the Item", new WriteViewpoint());
- predInit("AddNewCollectionDescription", "Creates a new collection description in this Item", new AddNewCollectionDescription());
- predInit("CreateNewCollectionVersion", "Creates a new numbered collection version in this Item from the current one.", new CreateNewCollectionVersion());
- predInit("AddNewSlot", "Creates a new slot in the given aggregation, that holds instances of the item description of the given key", new AddNewSlot());
- predInit("AssignItemToSlot", "Assigns the referenced entity to a pre-existing slot in an aggregation", new AssignItemToSlot());
- predInit("ClearSlot", "Clears an aggregation member slot, given a slot no or entity key", new ClearSlot());
- predInit("RemoveSlotFromCollection", "Removed the given slot from the aggregation", new RemoveSlotFromCollection());
- predInit("AddMemberToCollection", "Creates a new member slot for the given item in a dependency, and assigns the item", new AddMemberToCollection());
- predInit("Import", "Imports an outcome into the Item, with a given schema and viewpoint", new Import());
-
- }
-
- public void predInit(String alias, String Description, PredefinedStep act)
- {
- act.setName(alias);
- act.setType(alias);
- act.getProperties().put("Description", Description);
- act.setCentrePoint(new GraphPoint());
- act.setIsPredefined(true);
- addChild(act, new GraphPoint(100, 75 * ++num));
- }
- @Override
- public boolean verify()
- {
- return true;
- }
- @Override
- public String getErrors()
- {
- return "predefined";
- }
- @Override
- public boolean getActive()
- {
- return true;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java deleted file mode 100644 index ef7d16b..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java +++ /dev/null @@ -1,69 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-
-import java.util.Arrays;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2005/11/15 15:56:38 $
- * @version $Revision: 1.28 $
- **************************************************************************/
-public class RemoveC2KObject extends PredefinedStep
-{
- public RemoveC2KObject()
- {
- super();
- getProperties().put("Agent Role", "Admin");
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, PersistencyException {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "RemoveC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1)
- throw new InvalidDataException("RemoveC2KObject: Invalid parameters "+Arrays.toString(params));
- String path = params[0];
-
- try
- {
- Gateway.getStorage().remove( item, path, null );
- }
- catch( PersistencyException ex )
- {
- throw new PersistencyException("RemoveC2KObject: Error removing object '"+path+"': "+ex.getMessage());
- }
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java deleted file mode 100644 index 3308003..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java +++ /dev/null @@ -1,72 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-
-
-import java.util.Arrays;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.DomainPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.LookupManager;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class RemoveDomainPath extends PredefinedStep
-{
- public RemoveDomainPath()
- {
- super();
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "RemoveDomainPath: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1) throw new InvalidDataException("RemoveDomainPath: Invalid parameters "+Arrays.toString(params));
-
- DomainPath domainPath = new DomainPath(params[0]);
- if (!domainPath.exists())
- throw new ObjectNotFoundException("RemoveDomainPath: Domain path "+domainPath.toString()+" does not exist.");
-
- if (domainPath.getType()!=DomainPath.ENTITY)
-
- try {
- if (!domainPath.getItemPath().equals(item))
- throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" is not an alias of the current Item "+item);
- } catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" is a context.");
- }
-
- LookupManager lookupManager = Gateway.getLookupManager();
- lookupManager.delete(domainPath);
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java deleted file mode 100644 index 7bd921b..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java +++ /dev/null @@ -1,130 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-
-import java.util.Arrays;
-
-import com.c2kernel.collection.Collection;
-import com.c2kernel.collection.CollectionMember;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
- * @version $Revision: 1.8 $
- **************************************************************************/
-public class RemoveSlotFromCollection extends PredefinedStep
-{
- /**************************************************************************
- * Constructor for Castor
- **************************************************************************/
- public RemoveSlotFromCollection()
- {
- super();
- }
-
-
- /**
- * Params:
- * 0 - collection name
- * 1 - slot number OR if null:
- * 2 - target entity key
- * @throws ObjectNotFoundException
- * @throws PersistencyException
- */
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, PersistencyException {
-
- String collName;
- int slotNo = -1;
- ItemPath currentChild = null;
- Collection<? extends CollectionMember> coll;
-
- // extract parameters
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "RemoveSlotFromCollection: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
-
- try {
- collName = params[0];
- if (params.length>1 && params[1].length()>0) slotNo = Integer.parseInt(params[1]);
- if (params.length>2 && params[2].length()>0) currentChild = new ItemPath(params[2]);
- } catch (Exception e) {
- throw new InvalidDataException("RemoveSlotFromCollection: Invalid parameters "+Arrays.toString(params));
- }
-
- if (slotNo == -1 && currentChild == null)
- throw new InvalidDataException("RemoveSlotFromCollection: Must give either slot number or entity key");
-
- // load collection
- try {
- coll = (Collection<? extends CollectionMember>)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null);
- } catch (PersistencyException ex) {
- Logger.error(ex);
- throw new PersistencyException("RemoveSlotFromCollection: Error loading collection '\"+collName+\"': "+ex.getMessage());
- }
-
- // check the slot is there if it's given by id
- CollectionMember slot = null;
- if (slotNo > -1) {
- slot = coll.getMember(slotNo);
- }
-
- // if both parameters are supplied, check the given item is actually in that slot
- if (slot != null && currentChild != null && !slot.getItemPath().equals(currentChild)) {
- throw new ObjectNotFoundException("RemoveSlotFromCollection: Item "+currentChild+" was not in slot "+slotNo);
- }
-
- if (slotNo == -1) { // find slot from entity key
- for (CollectionMember member : coll.getMembers().list) {
- if (member.getItemPath().equals(currentChild)) {
- slotNo = member.getID();
- break;
- }
- }
- }
- if (slotNo == -1) {
- throw new ObjectNotFoundException("Could not find "+currentChild+" in collection "+coll.getName());
- }
-
- // Remove the slot
- coll.removeMember(slotNo);
-
- // Store the collection
- try {
- Gateway.getStorage().put(item, coll, null);
- } catch (PersistencyException e) {
- Logger.error(e);
- throw new PersistencyException("Error storing collection");
- }
-
- return requestData;
-
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java deleted file mode 100644 index f2d34c4..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java +++ /dev/null @@ -1,76 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-//Java
-import java.util.Arrays;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.lifecycle.instance.CompositeActivity;
-import com.c2kernel.lifecycle.instance.Workflow;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class ReplaceDomainWorkflow extends PredefinedStep
-{
- public ReplaceDomainWorkflow()
- {
- super();
- getProperties().put("Agent Role", "Admin");
- }
-
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, PersistencyException {
-
- Workflow lifeCycle = getWf();
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1) throw new InvalidDataException("AddC2KObject: Invalid parameters "+Arrays.toString(params));
-
- lifeCycle.getChildGraphModel().removeVertex(lifeCycle.search("workflow/domain"));
- CompositeActivity domain;
- try {
- domain = (CompositeActivity) Gateway.getMarshaller().unmarshall(params[0]);
- } catch (Exception e) {
- Logger.error(e);
- throw new InvalidDataException("ReplaceDomainWorkflow: Could not unmarshall new workflow: "+e.getMessage());
- }
- domain.setName("domain");
- lifeCycle.initChild(domain, true, new GraphPoint(150, 100));
- // if new workflow, activate it, otherwise refresh the jobs
- if (!domain.active) lifeCycle.run(agent, item);
- else lifeCycle.refreshJobs(item);
-
- // store new wf
- try {
- Gateway.getStorage().put(item, lifeCycle, null);
- } catch (PersistencyException e) {
- throw new PersistencyException("ReplaceDomainWorkflow: Could not write new workflow to storage: "+e.getMessage());
- }
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java deleted file mode 100644 index 2813f43..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java +++ /dev/null @@ -1,79 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-import java.util.Arrays;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.property.Property;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
- * @version $Revision: 1.3 $
- **************************************************************************/
-public class WriteProperty extends PredefinedStep
-{
- /**************************************************************************
- * Constructor for Castror
- **************************************************************************/
- public WriteProperty()
- {
- super();
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectCannotBeUpdated, ObjectNotFoundException, PersistencyException {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "WriteProperty: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
-
- if (params.length != 2)
- throw new InvalidDataException("WriteProperty: invalid parameters "+Arrays.toString(params));
-
- String name = params[0];
- String newValue = params[1];
-
- Property prop;
-
- try {
- prop = (Property)Gateway.getStorage().get(item, ClusterStorage.PROPERTY+"/"+name, null);
- if (!prop.isMutable() && !newValue.equals(prop.getValue()))
- throw new ObjectCannotBeUpdated("WriteProperty: Property '"+name+"' is not mutable.");
- prop.setValue(newValue);
- Gateway.getStorage().put(item, prop, null);
- } catch (ObjectNotFoundException e) {
- throw new ObjectNotFoundException("WriteProperty: Property '"+name+"' not found.");
- }
-
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java deleted file mode 100644 index a8a17ce..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java +++ /dev/null @@ -1,87 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined;
-
-import java.util.Arrays;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.events.Event;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.outcome.Viewpoint;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class WriteViewpoint extends PredefinedStep {
-
- public WriteViewpoint() {
- super();
- }
-
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, PersistencyException {
-
- String schemaName;
- String viewName;
- int evId;
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "WriteViewpoint: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
-
- // outcometype, name and evId. Event and Outcome should be checked so schema version should be discovered.
- if (params.length != 3)
- throw new InvalidDataException("WriteViewpoint: Invalid parameters "+Arrays.toString(params));
-
- schemaName = params[0];
- viewName = params[1];
-
- try {
- evId = Integer.parseInt(params[2]);
- } catch (NumberFormatException ex) {
- throw new InvalidDataException("WriteViewpoint: Parameter 3 (EventId) must be an integer");
- }
-
- // Find event
-
- Event ev;
- try {
- ev = (Event)Gateway.getStorage().get(item, ClusterStorage.HISTORY+"/"+evId, null);
- } catch (PersistencyException e) {
- Logger.error(e);
- throw new PersistencyException("WriteViewpoint: Could not load event "+evId);
- }
-
- // Write new viewpoint
- Viewpoint newView = new Viewpoint(item, schemaName, viewName, ev.getSchemaVersion(), evId);
- try {
- Gateway.getStorage().put(item, newView, null);
- } catch (PersistencyException e) {
- Logger.error(e);
- throw new PersistencyException("WriteViewpoint: Could not store new viewpoint");
- }
- return requestData;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/AgentPredefinedStepContainer.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/AgentPredefinedStepContainer.java deleted file mode 100644 index 6ded51a..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/AgentPredefinedStepContainer.java +++ /dev/null @@ -1,47 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.agent;
-
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer;
-
-
-/**************************************************************************
- *
- * $Revision: 1.2 $
- * $Date: 2005/06/02 10:19:33 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-public class AgentPredefinedStepContainer extends PredefinedStepContainer {
-
-
- @Override
- public void createChildren()
- {
- super.createChildren();
- predInit("CreateAgentFromDescription", "Create a new item using this item as its description", new CreateAgentFromDescription());
- predInit("RemoveAgent", "Deletes the Agent", new RemoveAgent());
- predInit("SetAgentPassword", "Changes the Agent's password", new SetAgentPassword());
- predInit("SetAgentRoles", "Sets the roles of the Agent", new SetAgentRoles());
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java deleted file mode 100644 index a2dfeae..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java +++ /dev/null @@ -1,136 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.agent;
-
-import java.util.Arrays;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.CorbaServer;
-import com.c2kernel.entity.agent.ActiveEntity;
-import com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.RolePath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.property.PropertyArrayList;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2005/10/13 08:13:58 $
- * @version $Revision: 1.47 $
- **************************************************************************/
-public class CreateAgentFromDescription extends CreateItemFromDescription
-{
- public CreateAgentFromDescription()
- {
- super();
- }
-
- /**
- * Params:
- * <ol><li>New Agent name</li>
- * <li>Description version to use</li>
- * <li>Comma-delimited Role names to assign to the agent. Must already exist.</li>
- * <li>Initial properties to set in the new Agent</li>
- * </ol>
- * @throws ObjectNotFoundException
- * @throws InvalidDataException The input parameters were incorrect
- * @throws ObjectAlreadyExistsException The Agent already exists
- * @throws CannotManageException The Agent could not be created
- * @throws ObjectCannotBeUpdated The addition of the new entries into the LookupManager failed
- * @see com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription#runActivityLogic(com.c2kernel.lookup.AgentPath, int, int, java.lang.String)
- */
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws ObjectNotFoundException, InvalidDataException, ObjectAlreadyExistsException, CannotManageException, ObjectCannotBeUpdated {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "CreateAgentFromDescription: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length < 3 || params.length > 4)
- throw new InvalidDataException("CreateAgentFromDescription: Invalid parameters "+Arrays.toString(params));
-
- String newName = params[0];
- String descVer = params[1];
- String roles = params[2];
- PropertyArrayList initProps =
- params.length > 3 ? getInitProperties(params[3]):new PropertyArrayList();
-
- Logger.msg(1, "CreateAgentFromDescription::request() - Starting.");
-
- // check if given roles exist
- String[] roleArr = roles.split(",");
- for(int i=0; i<roleArr.length; i++) {
- RolePath thisRole = Gateway.getLookup().getRolePath(roleArr[i]);
- }
-
- // check if the path is already taken
- try {
- Gateway.getLookup().getAgentPath(newName);
- throw new ObjectAlreadyExistsException("The agent name " +newName+ " exists already.");
- } catch (ObjectNotFoundException ex) { }
-
- // generate new entity key
- Logger.msg(6, "CreateItemFromDescription - Requesting new agent path");
- AgentPath newAgentPath = new AgentPath(new ItemPath(), newName);
-
- // resolve the item factory
- Logger.msg(6, "CreateItemFromDescription - Resolving item factory");
-
- // create the Item object
- Logger.msg(3, "CreateItemFromDescription - Creating Item");
- CorbaServer factory = Gateway.getCorbaServer();
- if (factory == null) throw new CannotManageException("This process cannot create new Items");
- ActiveEntity newAgent = factory.createAgent(newAgentPath);
- Gateway.getLookupManager().add(newAgentPath);
-
- // initialise it with its properties and workflow
-
- Logger.msg(3, "CreateItemFromDescription - Initializing Item");
-
- try {
- newAgent.initialise(
- agent.getSystemKey(),
- Gateway.getMarshaller().marshall(getNewProperties(item, descVer, initProps, newName, agent)),
- Gateway.getMarshaller().marshall(getNewWorkflow(item, descVer)),
- Gateway.getMarshaller().marshall(getNewCollections(item, descVer))
- );
- } catch (PersistencyException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (Exception e) {
- throw new InvalidDataException("CreateAgentFromDescription: Problem initializing new Agent. See log: "+e.getMessage());
- }
-
- // add roles if given
-
- for(int i=1; i<roleArr.length; i++) {
- newAgent.addRole(roleArr[i]);
- }
-
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java deleted file mode 100644 index 41fc7ba..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java +++ /dev/null @@ -1,89 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.agent;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.InvalidAgentPathException;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.RolePath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class RemoveAgent extends PredefinedStep {
-
- public RemoveAgent() {
- super();
- }
-
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
- int transitionID, String requestData) throws InvalidDataException {
-
- Logger.msg(1, "RemoveAgent::request() - Starting.");
-
- AgentPath targetAgent;
- try {
- targetAgent = new AgentPath(itemPath);
- } catch (InvalidAgentPathException ex) {
- throw new InvalidDataException("Could not resolve "+itemPath+" as an Agent.");
- }
- String agentName = targetAgent.getAgentName();
-
- //remove from roles
- for (RolePath role: targetAgent.getRoles()) {
- try {
- Gateway.getLookupManager().removeRole(targetAgent, role);
- } catch (ObjectCannotBeUpdated e) {
- Logger.error(e);
- throw new InvalidDataException("Error removing "+agentName+" from Role "+role.getName());
- } catch (ObjectNotFoundException e) {
- Logger.error(e);
- throw new InvalidDataException("Tried to remove "+agentName+" from Role "+role.getName()+" that doesn't exist.");
- } catch (CannotManageException e) {
- throw new InvalidDataException("Tried to alter roles in a non-server process.");
- }
- }
-
- //clear out all storages
- try {
- Gateway.getStorage().removeCluster(targetAgent, "", null);
- } catch (PersistencyException e) {
- Logger.error(e);
- throw new InvalidDataException("Error deleting storage for "+agentName);
- }
-
- //remove entity path
- try {
- Gateway.getLookupManager().delete(targetAgent);
- } catch (Exception e) {
- throw new InvalidDataException("Error deleting AgentPath for "+agentName);
- }
- return requestData;
-
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java deleted file mode 100644 index 3832337..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java +++ /dev/null @@ -1,69 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.agent;
-
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.InvalidItemPathException;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class SetAgentPassword extends PredefinedStep {
-
- public SetAgentPassword() {
- super();
- }
-
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "SetAgentPassword: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1) throw new InvalidDataException("SetAgentPassword: Invalid parameters "+Arrays.toString(params));
-
- AgentPath targetAgent;
- try {
- targetAgent = new AgentPath(item);
- } catch (InvalidItemPathException ex) {
- throw new InvalidDataException("Can only set password on an Agent. "+item+" is an Item.");
- }
-
- try {
- Gateway.getLookupManager().setAgentPassword(targetAgent, params[0]);
- } catch (NoSuchAlgorithmException e) {
- Logger.error(e);
- throw new InvalidDataException("Cryptographic libraries for password hashing not found.");
- }
-
- params[1] = "REDACTED"; // censor user's password from outcome
- return bundleData(params);
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java deleted file mode 100644 index d326d05..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java +++ /dev/null @@ -1,93 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.agent;
-
-import java.util.ArrayList;
-
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.InvalidItemPathException;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.RolePath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class SetAgentRoles extends PredefinedStep {
-
- public SetAgentRoles() {
- super();
- }
-
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException {
-
- Logger.msg(1, "SetAgentRoles::request() - Starting.");
-
- String[] params = getDataList(requestData);
- AgentPath targetAgent;
- try {
- targetAgent = new AgentPath(item);
- } catch (InvalidItemPathException ex) {
- throw new InvalidDataException("Could not resolve syskey "+item+" as an Agent.");
- }
-
- RolePath[] currentRoles = targetAgent.getRoles();
- ArrayList<RolePath> requestedRoles = new ArrayList<RolePath>();
- for (int i=0; i<params.length; i++)
- try {
- requestedRoles.add(Gateway.getLookup().getRolePath(params[i]));
- } catch (ObjectNotFoundException e) {
- throw new InvalidDataException("Role "+params[i]+" not found");
- }
-
- ArrayList<RolePath> rolesToRemove = new ArrayList<RolePath>();
- for (RolePath existingRole : currentRoles) { //
- if (requestedRoles.contains(existingRole)) // if we have it, and it's requested, then it will be kept
- requestedRoles.remove(existingRole); // so remove it from request - this will be left with roles to be added
- else
- rolesToRemove.add(existingRole); // else this role will be removed
- }
-
- // remove roles not in new list
- for (RolePath roleToRemove : rolesToRemove)
- try {
- Gateway.getLookupManager().removeRole(targetAgent, roleToRemove);
- } catch (Exception e) {
- Logger.error(e);
- throw new InvalidDataException("Error removing role "+roleToRemove.getName());
- }
-
- // add requested roles we don't already have
- for (RolePath roleToAdd : requestedRoles)
- try {
- Gateway.getLookupManager().addRole(targetAgent, roleToAdd);
- } catch (Exception e) {
- Logger.error(e);
- throw new InvalidDataException("Error adding role "+roleToAdd.getName());
- }
-
- return requestData;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java deleted file mode 100644 index 140f68c..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java +++ /dev/null @@ -1,194 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.item;
-
-import com.c2kernel.collection.Collection;
-import com.c2kernel.collection.CollectionArrayList;
-import com.c2kernel.collection.CollectionDescription;
-import com.c2kernel.collection.CollectionMember;
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.CorbaServer;
-import com.c2kernel.entity.TraceableEntity;
-import com.c2kernel.lifecycle.CompositeActivityDef;
-import com.c2kernel.lifecycle.instance.CompositeActivity;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.DomainPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.property.Property;
-import com.c2kernel.property.PropertyArrayList;
-import com.c2kernel.property.PropertyDescriptionList;
-import com.c2kernel.property.PropertyUtility;
-import com.c2kernel.utils.LocalObjectLoader;
-import com.c2kernel.utils.Logger;
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2005/10/13 08:13:58 $
- * @version $Revision: 1.47 $
- **************************************************************************/
-public class CreateItemFromDescription extends PredefinedStep
-{
- public CreateItemFromDescription()
- {
- super();
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectAlreadyExistsException, CannotManageException, ObjectCannotBeUpdated, PersistencyException {
-
- String[] input = getDataList(requestData);
- String newName = input[0];
- String domPath = input[1];
- String descVer = input.length > 2 ? input[2]:"last";
- PropertyArrayList initProps =
- input.length > 3?getInitProperties(input[3]):new PropertyArrayList();
-
- Logger.msg(1, "CreateItemFromDescription - Starting.");
-
- // check if the path is already taken
- DomainPath context = new DomainPath(new DomainPath(domPath), newName);
- //Logger.debug(8,"context "+context.getItemPath()+" "+context.getPath()+" "+context.getString());
- if (context.exists())
- throw new ObjectAlreadyExistsException("The path " +context+ " exists already.");
-
- // get init objects
-
- /* ITEM CREATION */
-
- // generate new entity key
- Logger.msg(6, "CreateItemFromDescription - Requesting new item path");
- ItemPath newItemPath = new ItemPath();
-
- // resolve the item factory
- Logger.msg(6, "CreateItemFromDescription - Resolving item factory");
-
- // create the Item object
- Logger.msg(3, "CreateItemFromDescription - Creating Item");
- CorbaServer factory = Gateway.getCorbaServer();
- if (factory == null) throw new CannotManageException("This process cannot create new Items");
- TraceableEntity newItem = factory.createItem(newItemPath);
- Gateway.getLookupManager().add(newItemPath);
-
-
- // initialise it with its properties and workflow
-
- Logger.msg(3, "CreateItemFromDescription - Initializing Item");
-
- try {
- newItem.initialise(
- agent.getSystemKey(),
- Gateway.getMarshaller().marshall(getNewProperties(itemPath, descVer, initProps, newName, agent)),
- Gateway.getMarshaller().marshall(getNewWorkflow(itemPath, descVer)),
- Gateway.getMarshaller().marshall(getNewCollections(itemPath, descVer))
- );
- } catch (PersistencyException e) {
- throw e;
- } catch (Exception e) {
- throw new InvalidDataException("CreateAgentFromDescription: Problem initializing new Agent. See log: "+e.getMessage());
- }
- // add its domain path
- Logger.msg(3, "CreateItemFromDescription - Creating "+context);
- context.setItemPath(newItemPath);
- Gateway.getLookupManager().add(context);
- return requestData;
- }
-
- protected PropertyArrayList getInitProperties(String input) throws InvalidDataException {
- try {
- return (PropertyArrayList)Gateway.getMarshaller().unmarshall(input);
- } catch (Exception e) {
- Logger.error(e);
- throw new InvalidDataException("Initial property parameter was not a marshalled PropertyArrayList: "+input);
- }
- }
-
- protected PropertyArrayList getNewProperties(ItemPath itemPath, String descVer, PropertyArrayList initProps, String newName, AgentPath agent) throws ObjectNotFoundException, InvalidDataException {
- // copy properties -- intend to create from propdesc
- PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer);
- PropertyArrayList props = pdList.instantiate(initProps);
- // set Name prop or create if not present
- boolean foundName = false;
- for (Property prop : props.list) {
- if (prop.getName().equals("Name")) {
- foundName = true;
- prop.setValue(newName);
- }
- }
- if (!foundName) props.list.add(new Property("Name", newName, true));
- props.list.add( new Property("Creator", agent.getAgentName(), false));
- return props;
- }
-
- protected CompositeActivity getNewWorkflow(ItemPath itemPath, String descVer) throws ObjectNotFoundException, InvalidDataException, PersistencyException {
- // find the workflow def for the given description version
-
- String wfDefName = null; Integer wfDefVer = null;
-
- Collection<? extends CollectionMember> thisCol = (Collection<? extends CollectionMember>)Gateway.getStorage().get(itemPath, ClusterStorage.COLLECTION+"/workflow/"+descVer, null);
- CollectionMember wfMember = thisCol.getMembers().list.get(0);
- wfDefName = wfMember.resolveItem().getName();
- Object wfVerObj = wfMember.getProperties().get("Version");
- try {
- wfDefVer = Integer.parseInt(wfVerObj.toString());
- } catch (NumberFormatException ex) {
- throw new InvalidDataException("Invalid workflow version number: "+wfVerObj.toString());
- }
-
- // load workflow def
- if (wfDefName == null)
- throw new InvalidDataException("No workflow given or defined");
- if (wfDefVer == null)
- throw new InvalidDataException("No workflow def version given");
-
- try {
- CompositeActivityDef wfDef = (CompositeActivityDef)LocalObjectLoader.getActDef(wfDefName, wfDefVer);
- return (CompositeActivity)wfDef.instantiate();
- } catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("Workflow def '"+wfDefName+"'v"+wfDefVer+" not found");
- } catch (ClassCastException ex) {
- throw new InvalidDataException("Activity def '"+wfDefName+"' was not Composite");
- }
- }
-
- protected CollectionArrayList getNewCollections(ItemPath itemPath, String descVer) throws ObjectNotFoundException, PersistencyException {
- // loop through collections, collecting instantiated descriptions and finding the default workflow def
- CollectionArrayList colls = new CollectionArrayList();
- String[] collNames = Gateway.getStorage().getClusterContents(itemPath, ClusterStorage.COLLECTION);
- for (String collName : collNames) {
- Collection<? extends CollectionMember> thisCol = (Collection<? extends CollectionMember>)Gateway.getStorage().get(itemPath, ClusterStorage.COLLECTION+"/"+collName+"/"+descVer, null);
- if (thisCol instanceof CollectionDescription) {
- CollectionDescription<?> thisDesc = (CollectionDescription<?>)thisCol;
- colls.put(thisDesc.newInstance());
- }
- }
- return colls;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java deleted file mode 100644 index a34b202..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java +++ /dev/null @@ -1,79 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.item;
-
-
-
-import java.util.Iterator;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.common.PersistencyException;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.DomainPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.Path;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-
-/**************************************************************************
- *
- * @author $Author: abranson $ $Date: 2005/11/15 15:56:38 $
- * @version $Revision: 1.10 $
- **************************************************************************/
-public class Erase extends PredefinedStep
-{
- public Erase()
- {
- super();
- getProperties().put("Agent Role", "Admin");
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, PersistencyException {
-
- Logger.msg(1, "Erase::request() - Starting.");
-
- Iterator<Path> domPaths = Gateway.getLookup().searchAliases(item);
- while (domPaths.hasNext()) {
- DomainPath path = (DomainPath)domPaths.next();
- // delete them
- if (path.getItemPath().equals(item))
- Gateway.getLookupManager().delete(path);
- }
-
- //clear out all storages
- Gateway.getStorage().removeCluster(item, "", null);
-
- //remove entity path
- Gateway.getLookupManager().delete(item);
-
- Logger.msg(1, "Erase::request() - DONE.");
- return requestData;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/ItemPredefinedStepContainer.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/ItemPredefinedStepContainer.java deleted file mode 100644 index 57aefa3..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/ItemPredefinedStepContainer.java +++ /dev/null @@ -1,45 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.item;
-
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer;
-
-
-/**************************************************************************
- *
- * $Revision: 1.2 $
- * $Date: 2005/06/02 10:19:33 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-public class ItemPredefinedStepContainer extends PredefinedStepContainer {
-
-
- @Override
- public void createChildren()
- {
- super.createChildren();
- predInit("CreateItemFromDescription", "Create a new item using this item as its description", new CreateItemFromDescription());
- predInit("Erase", "Deletes all objects and domain paths for this item.", new Erase());
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java deleted file mode 100644 index e6bfba9..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java +++ /dev/null @@ -1,66 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.server;
-
-import java.util.Arrays;
-import java.util.Stack;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.DomainPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class AddDomainContext extends PredefinedStep {
-
- public AddDomainContext() {
- super();
- }
-
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "AddDomainContext: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1) throw new InvalidDataException("AddDomainContext: Invalid parameters "+Arrays.toString(params));
-
- DomainPath pathToAdd = new DomainPath(params);
- if (pathToAdd.exists())
- throw new ObjectAlreadyExistsException("Context "+pathToAdd+" already exists");
- // collect parent paths if they don't exist
- Stack<DomainPath> pathsToAdd = new Stack<DomainPath>();
- while(pathToAdd!= null && !pathToAdd.exists()) {
- pathsToAdd.push(pathToAdd);
- pathToAdd = pathToAdd.getParent();
- }
- while(!pathsToAdd.empty()) {
- pathToAdd = pathsToAdd.pop();
- Gateway.getLookupManager().add(pathToAdd);
- }
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java deleted file mode 100644 index 92f4357..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java +++ /dev/null @@ -1,67 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.server;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.imports.ImportAgent;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class CreateNewAgent extends PredefinedStep
-{
- public CreateNewAgent()
- {
- super();
- getProperties().put("SchemaType", "Agent");
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException {
-
- String redactedRequestData;
-
- ImportAgent newAgent;
- try {
- newAgent = (ImportAgent)Gateway.getMarshaller().unmarshall(requestData);
- } catch (Exception e1) {
- Logger.error(e1);
- throw new InvalidDataException("CreateNewAgent: Couldn't unmarshall new Agent: "+requestData);
- }
- newAgent.create(agent, true);
- newAgent.setPassword("REDACTED");
- try {
- redactedRequestData = Gateway.getMarshaller().marshall(newAgent);
- } catch (Exception e) {
- Logger.error(e);
- throw new InvalidDataException("CreateNewAgent: Couldn't marshall new Agent for outcome: "+newAgent);
- }
- return redactedRequestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java deleted file mode 100644 index fde9f82..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java +++ /dev/null @@ -1,62 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.server;
-
-
-
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidCollectionModification;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.imports.ImportItem;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class CreateNewItem extends PredefinedStep
-{
- public CreateNewItem()
- {
- super();
- getProperties().put("SchemaType", "Item");
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException, InvalidCollectionModification {
-
- ImportItem newItem;
- try {
- newItem = (ImportItem)Gateway.getMarshaller().unmarshall(requestData);
- } catch (Exception e) {
- Logger.error(e);
- throw new InvalidDataException("CreateNewAgent: Couldn't unmarshall new Agent: "+requestData);
- }
- newItem.create(agent, false);
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java deleted file mode 100644 index f99e54c..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java +++ /dev/null @@ -1,59 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.server;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.imports.ImportRole;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class CreateNewRole extends PredefinedStep
-{
- public CreateNewRole()
- {
- super();
- getProperties().put("SchemaType", "Role");
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException {
-
-
- ImportRole newRole;
- try {
- newRole = (ImportRole)Gateway.getMarshaller().unmarshall(requestData);
- } catch (Exception e) {
- Logger.error(e);
- throw new InvalidDataException("CreateNewAgent: Couldn't unmarshall new Agent: "+requestData);
- }
- newRole.create(agent, true);
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java deleted file mode 100644 index a4520aa..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java +++ /dev/null @@ -1,64 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.server;
-
-import java.util.Arrays;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.DomainPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class RemoveDomainContext extends PredefinedStep {
- public RemoveDomainContext() {
- super();
- }
-
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "RemoveDomainContext: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1) throw new InvalidDataException("RemoveDomainContext: Invalid parameters "+Arrays.toString(params));
-
- DomainPath pathToDelete = new DomainPath(params[0]);
- if (!pathToDelete.exists())
- throw new ObjectNotFoundException("Context "+pathToDelete+" does not exist");
-
- try {
- pathToDelete.getItemPath();
- throw new InvalidDataException("Path "+pathToDelete+" is an Entity. Use its own Erase step instead, or RemoveAgent.");
- } catch (ObjectNotFoundException ex) { }
-
- if (Gateway.getLookup().getChildren(pathToDelete).hasNext())
- throw new ObjectCannotBeUpdated("Context "+pathToDelete+" is not empty. Cannot delete.");
-
- Gateway.getLookupManager().delete(pathToDelete);
- return requestData;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java deleted file mode 100644 index a75b98c..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java +++ /dev/null @@ -1,67 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.server;
-
-import java.util.Arrays;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.LookupManager;
-import com.c2kernel.lookup.RolePath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
-
-public class RemoveRole extends PredefinedStep
-{
- public RemoveRole()
- {
- super();
- }
-
- //requestdata is xmlstring
- @Override
- protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException, CannotManageException, ObjectNotFoundException, ObjectCannotBeUpdated {
-
- String[] params = getDataList(requestData);
- if (Logger.doLog(3)) Logger.msg(3, "RemoveRole: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- if (params.length != 1) throw new InvalidDataException("RemoveRole: Invalid parameters "+Arrays.toString(params));
-
- LookupManager lookup = Gateway.getLookupManager();
-
- RolePath thisRole; AgentPath[] agents;
- thisRole = lookup.getRolePath(params[0]);
- agents = Gateway.getLookup().getAgents(thisRole);
-
- if (agents.length > 0)
- throw new ObjectCannotBeUpdated("Cannot remove role. "+agents.length+" agents still hold it.");
-
- lookup.delete(thisRole);
-
- return requestData;
-
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/ServerPredefinedStepContainer.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/ServerPredefinedStepContainer.java deleted file mode 100644 index 35ecd94..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/ServerPredefinedStepContainer.java +++ /dev/null @@ -1,62 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.predefined.server;
-
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer;
-
-/**************************************************************************
- *
- * $Revision: 1.2 $
- * $Date: 2005/06/02 10:19:33 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-public class ServerPredefinedStepContainer extends PredefinedStepContainer {
-
-
- @Override
- public void createChildren()
- {
- super.createChildren();
- serverPredInit("CreateNewItem", "Creates a new Item in this Server without description.", new CreateNewItem());
- serverPredInit("CreateNewAgent", "Creates a new Agent in this Server without description.", new CreateNewAgent());
- serverPredInit("CreateNewRole", "Creates a new Role in this Server.", new CreateNewRole());
- serverPredInit("RemoveRole", "Removes a Role from this Server.", new RemoveRole());
- serverPredInit("RemoveDomainContext", "Deletes an existing context in the domain tree, but only if empty", new RemoveDomainContext());
- serverPredInit("AddDomainContext", "Creates an empty domain context in the tree", new AddDomainContext());
- }
-
- public void serverPredInit(String alias, String Description, PredefinedStep act)
- {
- act.setName(alias);
- act.setType(alias);
- act.getProperties().put("Description", Description);
- act.getProperties().put("Agent Role", "Admin");
- act.setCentrePoint(new GraphPoint());
- act.setIsPredefined(true);
- addChild(act, new GraphPoint(100, 75 * ++num));
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/State.java b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/State.java deleted file mode 100644 index 3e9e247..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/State.java +++ /dev/null @@ -1,101 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.stateMachine;
-
-import java.util.HashMap;
-import java.util.Set;
-
-public class State {
-
- int id;
- String name;
- boolean finished = false; // If true, this state deactivates the current activity and the lifecycle proceeds
-
- HashMap<Integer, Transition> possibleTransitions;
-
- public State() {
- possibleTransitions = new HashMap<Integer, Transition>();
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return id+": "+name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public boolean isFinished() {
- return finished;
- }
-
- public void setFinished(boolean finished) {
- this.finished = finished;
- }
-
- public HashMap<Integer, Transition> getPossibleTransitions() {
- return possibleTransitions;
- }
-
- protected void addPossibleTransition(Transition possibleTransition) {
- possibleTransitions.put(possibleTransition.getId(), possibleTransition);
- }
-
- public Set<Integer> getPossibleTransitionIds() {
- return possibleTransitions.keySet();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + id;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- State other = (State) obj;
- if (id != other.id)
- return false;
- return true;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/StateMachine.java b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/StateMachine.java deleted file mode 100644 index cd61713..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/StateMachine.java +++ /dev/null @@ -1,177 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.stateMachine;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.InvalidTransitionException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lifecycle.instance.Activity;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.utils.DescriptionObject;
-import com.c2kernel.utils.Logger;
-
-public class StateMachine implements DescriptionObject
-{
- public String name;
- public int version;
-
- private ArrayList<State> states;
- private ArrayList<Transition> transitions;
- private final HashMap<Integer, State> stateCodes;
- private final HashMap<Integer, Transition> transitionCodes;
-
- State initialState;
- int initialStateCode;
- boolean isCoherent = false;
-
- public StateMachine() {
- states = new ArrayList<State>();
- transitions = new ArrayList<Transition>();
- stateCodes = new HashMap<Integer, State>();
- transitionCodes = new HashMap<Integer, Transition>();
- }
-
- public void setStates(ArrayList<State> newStates) {
- this.states = newStates;
- validate();
- }
-
- public void setTransitions(ArrayList<Transition> newTransitions) {
- this.transitions = newTransitions;
- validate();
- }
-
- public void validate() {
- stateCodes.clear();
- transitionCodes.clear();
- isCoherent = true;
-
- for (State state : states) {
- Logger.debug(6, "State "+state.id+": "+state.name);
- stateCodes.put(state.getId(), state);
- }
-
- if (stateCodes.containsKey(initialStateCode))
- initialState = stateCodes.get(initialStateCode);
- else
- isCoherent = false;
-
- for (Transition trans : transitions) {
- Logger.debug(6, "Transition "+trans.id+": "+trans.name);
- transitionCodes.put(trans.getId(), trans);
- isCoherent = isCoherent && trans.resolveStates(stateCodes);
- }
-
- }
-
- public ArrayList<State> getStates() {
- return states;
- }
-
- public ArrayList<Transition> getTransitions() {
- return transitions;
- }
-
- public State getInitialState() {
- return initialState;
- }
-
- public void setInitialState(State initialState) {
- this.initialState = initialState;
- initialStateCode = initialState.getId();
- }
-
- public int getInitialStateCode() {
- return initialStateCode;
- }
-
- public void setInitialStateCode(int initialStateCode) {
- this.initialStateCode = initialStateCode;
- initialState = stateCodes.get(initialStateCode);
- if (initialState == null) isCoherent = false;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public int getVersion() {
- return version;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public void setVersion(int version) {
- this.version = version;
- }
-
- public Transition getTransition(int transitionID) {
- return transitionCodes.get(transitionID);
- }
-
- public State getState(int stateID) {
- return stateCodes.get(stateID);
- }
-
- public Map<Transition, String> getPossibleTransitions(Activity act, AgentPath agent) throws ObjectNotFoundException, InvalidDataException {
- HashMap<Transition, String> returnList = new HashMap<Transition, String>();
- State currentState = getState(act.getState());
- for (Integer transCode : currentState.getPossibleTransitionIds()) {
- Transition possTrans = currentState.getPossibleTransitions().get(transCode);
- try {
- String role = possTrans.getPerformingRole(act, agent);
- returnList.put(possTrans, role);
- } catch (AccessRightsException ex) {
- if (Logger.doLog(5))
- Logger.msg(5, "Transition '"+possTrans+"' not possible for "+agent.getAgentName()+": "+ex.getMessage());
- }
- }
- return returnList;
- }
-
- public State traverse(Activity act, Transition transition, AgentPath agent) throws InvalidTransitionException, AccessRightsException, ObjectNotFoundException, InvalidDataException {
- State currentState = getState(act.getState());
- if (transition.originState.equals(currentState)) {
- transition.getPerformingRole(act, agent);
- return transition.targetState;
- }
- else
- throw new InvalidTransitionException("Transition '"+transition.getName()+"' not valid from state '"+currentState.getName());
-
- }
-
- public boolean isCoherent() {
- return isCoherent;
- }
-
-
-}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/Transition.java b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/Transition.java deleted file mode 100644 index 76ae602..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/Transition.java +++ /dev/null @@ -1,344 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.stateMachine;
-
-import java.util.HashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lifecycle.instance.Activity;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.RolePath;
-import com.c2kernel.persistency.outcome.Schema;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.CastorHashMap;
-import com.c2kernel.utils.LocalObjectLoader;
-import com.c2kernel.utils.Logger;
-
-public class Transition {
-
- int id;
- String name;
-
- int originStateId;
- int targetStateId;
- State originState;
- State targetState;
- String reservation;
-
- String enabledProp; // Boolean property that permits this transition e.g. 'Skippable'
-
- // activation properties
- boolean requiresActive = true; // Whether the activity must be active for this transition to be available
- boolean finishing; // whether the target state is a finishing state;
-
- // permissions
- String roleOverride;
-
- TransitionOutcome outcome;
- TransitionScript script;
-
- public Transition() {
- }
-
-
- public Transition(int id, String name, int originStateId, int targetStateId) {
- super();
- this.id = id;
- this.name = name;
- this.originStateId = originStateId;
- this.targetStateId = targetStateId;
- }
-
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public State getOriginState() {
- return originState;
- }
-
- public void setOriginState(State originState) {
- this.originState = originState;
- }
-
- public State getTargetState() {
- return targetState;
- }
-
- public void setTargetState(State targetState) {
- this.targetState = targetState;
- finishing = targetState.finished;
- }
-
- public String getEnabledProp() {
- return enabledProp;
- }
-
- public void setEnabledProp(String enabledProp) {
- this.enabledProp = enabledProp;
- }
-
- public boolean isRequiresActive() {
- return requiresActive;
- }
-
- public boolean isFinishing() {
- return finishing;
- }
-
- public void setRequiresActive(boolean requiresActive) {
- this.requiresActive = requiresActive;
- }
-
- public String getRoleOverride() {
- return roleOverride;
- }
-
- public void setRoleOverride(String roleOverride) {
- this.roleOverride = roleOverride;
- }
-
- public TransitionOutcome getOutcome() {
- return outcome;
- }
-
- public void setOutcome(TransitionOutcome outcome) {
- this.outcome = outcome;
- }
-
- public TransitionScript getScript() {
- return script;
- }
-
- public void setScript(TransitionScript script) {
- this.script = script;
- }
-
- public String getReservation() {
- return reservation;
- }
-
- public void setReservation(String reservation) {
- this.reservation = reservation;
- }
-
- protected boolean resolveStates(HashMap<Integer, State> states) {
- boolean allFound = true;
- if (states.keySet().contains(originStateId)) {
- originState = states.get(originStateId);
- originState.addPossibleTransition(this);
- }
- else
- allFound = false;
- if (states.keySet().contains(targetStateId))
- targetState = states.get(targetStateId);
- else
- allFound = false;
- return allFound;
- }
-
- public int getOriginStateId() {
- return originStateId;
- }
-
- public void setOriginStateId(int originStateId) {
- this.originStateId = originStateId;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public int getTargetStateId() {
- return targetStateId;
- }
-
- public void setTargetStateId(int targetStateId) {
- this.targetStateId = targetStateId;
- }
-
- public String getPerformingRole(Activity act, AgentPath agent) throws ObjectNotFoundException, AccessRightsException {
-
- // check available
- if (!isEnabled(act.getProperties()))
- throw new AccessRightsException("Transition '"+name+"' is disabled by the '"+enabledProp+"' property.");
-
- // check active
- if (isRequiresActive() && !act.getActive())
- throw new AccessRightsException("Activity must be active to perform this transition");
-
- RolePath role = null;
- String overridingRole = resolveValue(roleOverride, act.getProperties());
- boolean override = overridingRole != null;
- boolean isOwner = false, isOwned = true;
-
- // Check agent name
- String agentName = act.getCurrentAgentName();
- if (agentName != null && agentName.length() >0) {
- if (agent.getAgentName().equals(agentName))
- isOwner = true;
- }
- else isOwned = false;
-
- // determine transition role
- if (override) {
- role = Gateway.getLookup().getRolePath(overridingRole);
- }
- else {
- String actRole = act.getCurrentAgentRole();
- if (actRole != null && actRole.length() > 0)
- role = Gateway.getLookup().getRolePath(actRole);
- }
-
- // Decide the access
- if (isOwned && !override && !isOwner)
- throw new AccessRightsException("Agent '"+agent.getAgentName()
- +"' cannot perform this transition because the activity '"+act.getName()+"' is currently owned by "+agentName);
-
- if (role != null) {
- if (agent.hasRole(role))
- return role.getName();
- else if (agent.hasRole("Admin"))
- return "Admin";
- else
- throw new AccessRightsException("Agent '"+agent.getAgentName()
- +"' does not hold a suitable role '"+role.getName()+"' for the activity "+act.getName());
- }
- else
- return null;
- }
-
- public String getReservation(Activity act, AgentPath agent) {
- if (reservation == null || reservation.length() == 0)
- reservation = targetState.finished?"clear":"set";
-
- String reservedAgent = act.getCurrentAgentName();
- if (reservation.equals("set"))
- reservedAgent = agent.getAgentName();
- else if (reservation.equals("clear"))
- reservedAgent = "";
- return reservedAgent;
-
- }
-
- private static String resolveValue(String key, CastorHashMap props) {
- if (key==null) return null;
- String result = key;
- Pattern propField = Pattern.compile("\\$\\{(.+?)\\}");
- Matcher propMatcher = propField.matcher(result);
- while (propMatcher.find()) {
- String propName = propMatcher.group(1);
- Object propValue = props.get(propName);
- Logger.msg(8, "Replacing Property "+propName+" as "+propValue);
- String propValString = propValue==null?"":propValue.toString();
- result = result.replace("${"+propName+"}", propValString);
- }
- return result;
- }
-
- public boolean isEnabled(CastorHashMap props) {
- if (enabledProp == null)
- return true;
- return (Boolean)props.get(enabledProp);
- }
-
- public boolean hasOutcome(CastorHashMap actProps) {
- if (outcome == null || actProps == null) return false;
- String outcomeName = resolveValue(outcome.schemaName, actProps);
- if (outcomeName == null || outcomeName.length() == 0)
- return false;
- String outcomeVersion = resolveValue(outcome.schemaVersion, actProps);
- if (outcomeVersion == null || outcomeVersion.length() == 0)
- return false;
- return true;
- }
-
- public Schema getSchema(CastorHashMap actProps) throws InvalidDataException, ObjectNotFoundException {
- if (hasOutcome(actProps))
- try {
- return LocalObjectLoader.getSchema(resolveValue(outcome.schemaName, actProps),
- Integer.parseInt(resolveValue(outcome.schemaVersion, actProps)));
- } catch (NumberFormatException ex) {
- throw new InvalidDataException("Bad schema version number: "+outcome.schemaVersion+" ("+resolveValue(outcome.schemaVersion, actProps)+")");
- }
- else
- return null;
- }
-
- public String getScriptName(CastorHashMap actProps) {
- return resolveValue(script.scriptName, actProps);
- }
-
- public int getScriptVersion(CastorHashMap actProps) throws InvalidDataException {
- try {
- return Integer.parseInt(resolveValue(script.scriptVersion, actProps));
- } catch (NumberFormatException ex) {
- throw new InvalidDataException("Bad Script version number: "+script.scriptVersion+" ("+resolveValue(script.scriptVersion, actProps)+")");
- }
- }
-
- public boolean hasScript(CastorHashMap actProps) {
- if (script == null || actProps == null) return false;
- String scriptName = getScriptName(actProps);
- if (scriptName == null || scriptName.length() == 0)
- return false;
- String scriptVersion = resolveValue(script.scriptVersion, actProps);
- if (scriptVersion == null || scriptVersion.length() == 0)
- return false;
- return true;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + id;
- return result;
- }
-
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Transition other = (Transition) obj;
- if (id != other.id)
- return false;
- return true;
- }
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/TransitionOutcome.java b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/TransitionOutcome.java deleted file mode 100644 index ceb667a..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/TransitionOutcome.java +++ /dev/null @@ -1,57 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.stateMachine;
-
-
-public class TransitionOutcome extends TransitionResource {
-
- // schema properties
- String schemaName, schemaVersion; // Name & version of the schema of the data required for this transition.
- boolean required = true; // If true, then the data must be supplied to perform the transition, otherwise it is optional
-
- public TransitionOutcome() {
- }
-
- public String getSchemaName() {
- return schemaName;
- }
-
- public void setSchemaName(String schemaName) {
- this.schemaName = schemaName;
- }
-
- public String getSchemaVersion() {
- return schemaVersion;
- }
-
- public void setSchemaVersion(String schemaVersion) {
- this.schemaVersion = schemaVersion;
- }
-
- public boolean isRequired() {
- return required;
- }
-
- public void setRequired(boolean required) {
- this.required = required;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/TransitionResource.java b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/TransitionResource.java deleted file mode 100644 index 1cf39e0..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/TransitionResource.java +++ /dev/null @@ -1,29 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.stateMachine;
-
-public class TransitionResource {
-
- public TransitionResource() {
- // TODO Auto-generated constructor stub
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/TransitionScript.java b/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/TransitionScript.java deleted file mode 100644 index 6edb611..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/stateMachine/TransitionScript.java +++ /dev/null @@ -1,48 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.instance.stateMachine;
-
-
-public class TransitionScript extends TransitionResource {
-
- // script properties
- String scriptName, scriptVersion; // Name & version of the script to be run by the agent during this transition
-
- public TransitionScript() {
- }
-
- public String getScriptName() {
- return scriptName;
- }
-
- public void setScriptName(String scriptName) {
- this.scriptName = scriptName;
- }
-
- public String getScriptVersion() {
- return scriptVersion;
- }
-
- public void setScriptVersion(String scriptVersion) {
- this.scriptVersion = scriptVersion;
- }
-
-}
diff --git a/src/main/java/com/c2kernel/lifecycle/package-info.java b/src/main/java/com/c2kernel/lifecycle/package-info.java deleted file mode 100644 index c402664..0000000 --- a/src/main/java/com/c2kernel/lifecycle/package-info.java +++ /dev/null @@ -1,30 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-/**
- * The implementation of the Item lifecycle, as composite workflows.
- *
- * <p>This package contains the activity description implementations. The
- * workflow instance is in the {@link com.c2kernel.lifecycle.instance}
- * subpackage, which also contains the predefined steps.
- *
- */
-
-package com.c2kernel.lifecycle;
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java b/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java deleted file mode 100644 index ae86c2a..0000000 --- a/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java +++ /dev/null @@ -1,85 +0,0 @@ -/**
- * This file is part of the CRISTAL-iSE kernel.
- * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * http://www.fsf.org/licensing/licenses/lgpl.html
- */
-package com.c2kernel.lifecycle.routingHelpers;
-
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.proxy.ItemProxy;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.outcome.Outcome;
-import com.c2kernel.persistency.outcome.Viewpoint;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.XmlElementParser;
-
-public class ViewpointDataHelper
-{
- static Object[] errArr = { "" };
- /**
- * Method get.
- * @param value
- * @return String[]
- * @throws Exception
- */
- /**@param value : /UUID (or . if current) /SchemaName/Viewname/Path:XPathInOutcome */
- public static Object [] get(String value) throws Exception
- {
- //Syntax of search : <EntityPath>/<ViewpointPath>:<XPathinOutcome>
- String entityPath;
- String viewpoint;
- String xpath;
- Object[] retArr;
-
- // find syskey, viewname, xpath
- int firstSlash = value.indexOf("/");
- if (firstSlash > 0) {
- entityPath = value.substring(0, firstSlash);
- int startXPath = value.indexOf(":");
- if (startXPath==-1) {
- viewpoint = value.substring(firstSlash + 1);
- xpath = null;
- } else {
- viewpoint = value.substring(firstSlash + 1, startXPath);
- xpath = value.substring(startXPath+1);
- }
- }
- else return errArr;
-
- // find entity
- ItemPath sourcePath = new ItemPath(entityPath);
-
- try {
- // load viewpoint
- ItemProxy dataSource = Gateway.getProxyManager().getProxy(sourcePath);
- Viewpoint view = (Viewpoint)dataSource.getObject(ClusterStorage.VIEWPOINT + "/" + viewpoint);
- Outcome outcome = view.getOutcome();
- if (xpath == null) {
- retArr = new Object[1];
- retArr[0] = outcome;
- }
- else
- retArr = XmlElementParser.parse(outcome.getData(), xpath);
- return retArr;
-
- } catch (ObjectNotFoundException e) {
- return errArr;
- }
- }
-}
|
