From 0ed2c1124cf1b9e49a2ec1fa0126a8df09f9e758 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 7 Oct 2014 09:18:11 +0200 Subject: Repackage to org.cristalise --- .../java/com/c2kernel/entity/imports/Geometry.java | 48 ---- .../com/c2kernel/entity/imports/ImportAgent.java | 117 --------- .../c2kernel/entity/imports/ImportAggregation.java | 90 ------- .../entity/imports/ImportAggregationMember.java | 55 ---- .../c2kernel/entity/imports/ImportDependency.java | 106 -------- .../entity/imports/ImportDependencyMember.java | 48 ---- .../com/c2kernel/entity/imports/ImportItem.java | 280 --------------------- .../com/c2kernel/entity/imports/ImportOutcome.java | 47 ---- .../com/c2kernel/entity/imports/ImportRole.java | 74 ------ 9 files changed, 865 deletions(-) delete mode 100644 src/main/java/com/c2kernel/entity/imports/Geometry.java delete mode 100644 src/main/java/com/c2kernel/entity/imports/ImportAgent.java delete mode 100644 src/main/java/com/c2kernel/entity/imports/ImportAggregation.java delete mode 100644 src/main/java/com/c2kernel/entity/imports/ImportAggregationMember.java delete mode 100644 src/main/java/com/c2kernel/entity/imports/ImportDependency.java delete mode 100644 src/main/java/com/c2kernel/entity/imports/ImportDependencyMember.java delete mode 100644 src/main/java/com/c2kernel/entity/imports/ImportItem.java delete mode 100644 src/main/java/com/c2kernel/entity/imports/ImportOutcome.java delete mode 100644 src/main/java/com/c2kernel/entity/imports/ImportRole.java (limited to 'src/main/java/com/c2kernel/entity/imports') diff --git a/src/main/java/com/c2kernel/entity/imports/Geometry.java b/src/main/java/com/c2kernel/entity/imports/Geometry.java deleted file mode 100644 index 72523bf..0000000 --- a/src/main/java/com/c2kernel/entity/imports/Geometry.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.entity.imports; - - - -public class Geometry { - - - public int x; - - public int y; - - public int width; - - public int height; - - public Geometry() { - super(); - } - - public Geometry(int x, int y, int width, int height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - -} diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java b/src/main/java/com/c2kernel/entity/imports/ImportAgent.java deleted file mode 100644 index 70a5d91..0000000 --- a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java +++ /dev/null @@ -1,117 +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.entity.imports; - -import java.util.ArrayList; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.agent.ActiveEntity; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.lookup.RolePath; -import com.c2kernel.process.Gateway; -import com.c2kernel.process.module.ModuleImport; -import com.c2kernel.property.Property; -import com.c2kernel.property.PropertyArrayList; -import com.c2kernel.utils.Logger; - -public class ImportAgent extends ModuleImport { - - private String password; - private ArrayList properties = new ArrayList(); - private ArrayList roles = new ArrayList(); - - public ImportAgent() { - } - - public ImportAgent(String name, String password) { - this.name = name; - this.password = password; - } - - @Override - public void create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException { - AgentPath newAgent = new AgentPath(getItemPath(), name); - newAgent.setPassword(password); - ActiveEntity newAgentEnt = Gateway.getCorbaServer().createAgent(newAgent); - Gateway.getLookupManager().add(newAgent); - // assemble properties - properties.add(new Property("Name", name, true)); - properties.add(new Property("Type", "Agent", false)); - try { - newAgentEnt.initialise(agentPath.getSystemKey(), Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), null, null); - } catch (Exception ex) { - Logger.error(ex); - throw new CannotManageException("Error initialising new agent"); - } - for (String role : roles) { - RolePath thisRole; - try { - thisRole = Gateway.getLookup().getRolePath(role); - } catch (ObjectNotFoundException ex) { - throw new ObjectNotFoundException("Role "+role+" does not exist."); - } - Gateway.getLookupManager().addRole(newAgent, thisRole); - } - - } - - @Override - public ItemPath getItemPath() { - if (itemPath == null) { // try to find agent if it already exists - try { - AgentPath existAgent = Gateway.getLookup().getAgentPath(name); - itemPath = existAgent; - } catch (ObjectNotFoundException ex) { - itemPath = new AgentPath(new ItemPath(), name); - } - } - return itemPath; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public ArrayList getRoles() { - return roles; - } - - public void setRoles(ArrayList roles) { - this.roles = roles; - } - - public ArrayList getProperties() { - return properties; - } - - public void setProperties(ArrayList properties) { - this.properties = properties; - } - -} diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java b/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java deleted file mode 100644 index cd114ed..0000000 --- a/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java +++ /dev/null @@ -1,90 +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.entity.imports; - -import java.util.ArrayList; - -import com.c2kernel.collection.Aggregation; -import com.c2kernel.collection.AggregationDescription; -import com.c2kernel.collection.AggregationInstance; -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.graph.model.GraphPoint; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.InvalidItemPathException; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.property.PropertyDescription; -import com.c2kernel.property.PropertyDescriptionList; -import com.c2kernel.property.PropertyUtility; - -public class ImportAggregation { - - public boolean isDescription; - public Integer version; - public ArrayList aggregationMemberList = new ArrayList(); - public String name; - - public ImportAggregation() { - super(); - } - - public ImportAggregation(String name, boolean isDescription) { - this(); - this.name = name; - this.isDescription = isDescription; - } - - public com.c2kernel.collection.Aggregation create() throws InvalidCollectionModification, ObjectNotFoundException, ObjectAlreadyExistsException { - Aggregation newAgg = isDescription?new AggregationDescription(name):new AggregationInstance(name); - if (version!= null) newAgg.setVersion(version); - for (ImportAggregationMember thisMem : aggregationMemberList) { - StringBuffer classProps = new StringBuffer(); - if (thisMem.itemDescriptionPath != null && thisMem.itemDescriptionPath.length()>0) { - ItemPath itemPath; - try { - itemPath = new ItemPath(thisMem.itemDescriptionPath); - } catch (InvalidItemPathException ex) { - itemPath = new DomainPath(thisMem.itemDescriptionPath).getItemPath(); - } - - String descVer = thisMem.itemDescriptionVersion==null?"last":thisMem.itemDescriptionVersion; - PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer); - for (PropertyDescription pd : propList.list) { - thisMem.props.put(pd.getName(), pd.getDefaultValue()); - if (pd.getIsClassIdentifier()) - classProps.append((classProps.length()>0?",":"")).append(pd.getName()); - } - } - ItemPath itemPath = null; - if (thisMem.itemPath != null && thisMem.itemPath.length()>0) { - - try { - itemPath = new ItemPath(thisMem.itemPath); - } catch (InvalidItemPathException ex) { - itemPath = new DomainPath(thisMem.itemPath).getItemPath(); - } - } - newAgg.addMember(itemPath, thisMem.props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height); - } - return newAgg; - } -} diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAggregationMember.java b/src/main/java/com/c2kernel/entity/imports/ImportAggregationMember.java deleted file mode 100644 index d336fb4..0000000 --- a/src/main/java/com/c2kernel/entity/imports/ImportAggregationMember.java +++ /dev/null @@ -1,55 +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.entity.imports; - -import com.c2kernel.utils.CastorHashMap; -import com.c2kernel.utils.KeyValuePair; - -public class ImportAggregationMember { - - public int slotNo; - public String itemDescriptionPath; - public String itemDescriptionVersion = null; - public String itemPath; - public Geometry geometry; - public CastorHashMap props = new CastorHashMap(); - - - public ImportAggregationMember() { - super(); - } - - public ImportAggregationMember(int slotNo, String itemDescPath, String itemDescVersion, String itemPath, Geometry geometry) { - this.slotNo = slotNo; - this.itemDescriptionPath = itemDescPath; - this.itemDescriptionVersion = itemDescVersion; - this.itemPath = itemPath; - this.geometry = geometry; - } - - public KeyValuePair[] getKeyValuePairs() { - return props.getKeyValuePairs(); - } - - public void setKeyValuePairs(KeyValuePair[] pairs) { - props.setKeyValuePairs(pairs); - } -} diff --git a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java b/src/main/java/com/c2kernel/entity/imports/ImportDependency.java deleted file mode 100644 index 01900d3..0000000 --- a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java +++ /dev/null @@ -1,106 +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.entity.imports; - -import java.util.ArrayList; - -import com.c2kernel.collection.Dependency; -import com.c2kernel.collection.DependencyDescription; -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.InvalidItemPathException; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.property.PropertyDescription; -import com.c2kernel.property.PropertyDescriptionList; -import com.c2kernel.property.PropertyUtility; -import com.c2kernel.utils.CastorHashMap; -import com.c2kernel.utils.KeyValuePair; - -public class ImportDependency { - - public String name; - public Integer version; - public boolean isDescription; - public String itemDescriptionPath; - public String itemDescriptionVersion = null; - public ArrayList dependencyMemberList = new ArrayList(); - public CastorHashMap props = new CastorHashMap(); - - public ImportDependency() { - super(); - } - - public ImportDependency(String name) { - this(); - this.name = name; - } - - public KeyValuePair[] getKeyValuePairs() { - return props.getKeyValuePairs(); - } - - public void setKeyValuePairs(KeyValuePair[] pairs) { - props.setKeyValuePairs(pairs); - } - - /** - * @return - * @throws ObjectAlreadyExistsException - */ - public com.c2kernel.collection.Dependency create() throws InvalidCollectionModification, ObjectNotFoundException, ObjectAlreadyExistsException { - Dependency newDep = isDescription?new DependencyDescription(name):new Dependency(name); - if (version!= null) newDep.setVersion(version); - if (itemDescriptionPath != null && itemDescriptionPath.length()>0) { - ItemPath itemPath; - try { - itemPath = new ItemPath(itemDescriptionPath); - } catch (InvalidItemPathException ex) { - itemPath = new DomainPath(itemDescriptionPath).getItemPath(); - } - String descVer = itemDescriptionVersion==null?"last":itemDescriptionVersion; - PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer); - StringBuffer classProps = new StringBuffer(); - for (PropertyDescription pd : propList.list) { - props.put(pd.getName(), pd.getDefaultValue()); - if (pd.getIsClassIdentifier()) - classProps.append((classProps.length()>0?",":"")).append(pd.getName()); - } - newDep.setProperties(props); - newDep.setClassProps(classProps.toString()); - } - - for (ImportDependencyMember thisMem : dependencyMemberList) { - ItemPath itemPath; - try { - itemPath = new ItemPath(thisMem.itemPath); - } catch (InvalidItemPathException ex) { - itemPath = new DomainPath(thisMem.itemPath).getItemPath(); - } - - com.c2kernel.collection.DependencyMember newDepMem = newDep.addMember(itemPath); - newDepMem.getProperties().putAll(thisMem.props); - } - return newDep; - } - -} diff --git a/src/main/java/com/c2kernel/entity/imports/ImportDependencyMember.java b/src/main/java/com/c2kernel/entity/imports/ImportDependencyMember.java deleted file mode 100644 index aff5087..0000000 --- a/src/main/java/com/c2kernel/entity/imports/ImportDependencyMember.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.entity.imports; - -import com.c2kernel.utils.CastorHashMap; -import com.c2kernel.utils.KeyValuePair; - -public class ImportDependencyMember { - - - public String itemPath; - public CastorHashMap props = new CastorHashMap(); - - public ImportDependencyMember() { - super(); - } - - public ImportDependencyMember(String itemPath) { - this.itemPath = itemPath; - - } - - public KeyValuePair[] getKeyValuePairs() { - return props.getKeyValuePairs(); - } - - public void setKeyValuePairs(KeyValuePair[] pairs) { - props.setKeyValuePairs(pairs); - } -} diff --git a/src/main/java/com/c2kernel/entity/imports/ImportItem.java b/src/main/java/com/c2kernel/entity/imports/ImportItem.java deleted file mode 100644 index 0e067f8..0000000 --- a/src/main/java/com/c2kernel/entity/imports/ImportItem.java +++ /dev/null @@ -1,280 +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.entity.imports; - - -import java.util.ArrayList; - -import org.custommonkey.xmlunit.Diff; -import org.custommonkey.xmlunit.XMLUnit; - -import com.c2kernel.collection.Aggregation; -import com.c2kernel.collection.CollectionArrayList; -import com.c2kernel.collection.Dependency; -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.common.PersistencyException; -import com.c2kernel.entity.TraceableEntity; -import com.c2kernel.events.Event; -import com.c2kernel.events.History; -import com.c2kernel.lifecycle.CompositeActivityDef; -import com.c2kernel.lifecycle.instance.stateMachine.Transition; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.DomainPath; -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.process.module.ModuleImport; -import com.c2kernel.property.Property; -import com.c2kernel.property.PropertyArrayList; -import com.c2kernel.utils.LocalObjectLoader; -import com.c2kernel.utils.Logger; - -/** - * Complete Structure for new item - * - * @version $Revision: 1.8 $ $Date: 2006/03/03 13:52:21 $ - */ - -public class ImportItem extends ModuleImport { - - protected String initialPath; - protected String workflow; - protected Integer workflowVer; - protected ArrayList properties = new ArrayList(); - protected ArrayList aggregationList = new ArrayList(); - protected ArrayList dependencyList = new ArrayList(); - protected ArrayList outcomes = new ArrayList(); - - public ImportItem() { - } - - public ImportItem(String ns, String name, String initialPath, ItemPath itemPath, String wf, int wfVer) { - this(); - setNamespace(ns); - setName(name); - setItemPath(itemPath); - setInitialPath(initialPath); - setWorkflow(wf); - setWorkflowVer(wfVer); - } - - @Override - public ItemPath getItemPath() { - if (itemPath == null) { // try to find item if it already exists - DomainPath existingItem = new DomainPath(initialPath+"/"+name); - if (existingItem.exists()) { - try { - itemPath = existingItem.getItemPath(); - } catch (ObjectNotFoundException ex) { } - } - } - if (itemPath == null) itemPath = new ItemPath(); - return itemPath; - } - - @Override - public void setNamespace(String ns) { - super.setNamespace(ns); - if (initialPath == null) initialPath = "/desc/"+ns; - } - - @Override - public void setName(String name) { - super.setName(name); - } - - @Override - public void create(AgentPath agentPath, boolean reset) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException, InvalidCollectionModification { - DomainPath domPath = new DomainPath(new DomainPath(initialPath), name); - if (domPath.exists()) { - ItemPath domItem = domPath.getItemPath(); - if (!getItemPath().equals(domItem)) - throw new CannotManageException("Item "+domPath+" was found with the wrong itemPath ("+domPath.getItemPath()+" vs "+getItemPath()+")"); - } - - TraceableEntity newItem; - if (getItemPath().exists()) { - Logger.msg(1, "ImportItem.create() - Verifying module item "+getItemPath()+" at "+domPath); - newItem = Gateway.getCorbaServer().getItem(getItemPath()); - } - else { - Logger.msg(1, "ImportItem.create() - Creating module item "+getItemPath()+" at "+domPath); - newItem = Gateway.getCorbaServer().createItem(getItemPath()); - Gateway.getLookupManager().add(getItemPath()); - } - - // set the name property - properties.add(new Property("Name", name, true)); - - // find workflow def - CompositeActivityDef compact; - // default workflow version is 0 if not given - int usedWfVer; - if (workflowVer == null) usedWfVer = 0; - else usedWfVer = workflowVer.intValue(); - try { - compact = (CompositeActivityDef)LocalObjectLoader.getActDef(workflow, usedWfVer); - } catch (ObjectNotFoundException ex) { - throw new CannotManageException("Could not find workflow "+workflow+"v"+usedWfVer+" for item "+domPath); - } catch (InvalidDataException e) { - throw new CannotManageException("Workflow def "+workflow+" v"+usedWfVer+" for item "+domPath+" was not valid"); - } - - // create collections - CollectionArrayList colls = new CollectionArrayList(); - for (ImportDependency element: dependencyList) { - Dependency newDep = element.create(); - colls.put(newDep); - } - - for (ImportAggregation element : aggregationList) { - Aggregation newAgg = element.create(); - colls.put(newAgg); - } - - // (re)initialise the new item with properties, workflow and collections - try { - newItem.initialise( - agentPath.getSystemKey(), - Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), - Gateway.getMarshaller().marshall(compact.instantiate()), - Gateway.getMarshaller().marshall(colls)); - } catch (Exception ex) { - Logger.error("Error initialising new item "+name ); - Logger.error(ex); - throw new CannotManageException("Problem initialising new item. See server log."); - } - - // import outcomes - XMLUnit.setIgnoreWhitespace(true); - XMLUnit.setIgnoreComments(true); - History hist = new History(getItemPath(), null); - for (ImportOutcome thisOutcome : outcomes) { - Outcome newOutcome = new Outcome(-1, thisOutcome.getData(ns), thisOutcome.schema, thisOutcome.version); - Viewpoint impView; - try { - impView = (Viewpoint)Gateway.getStorage().get(getItemPath(), ClusterStorage.VIEWPOINT+"/"+thisOutcome.schema+"/"+thisOutcome.viewname, null); - - Diff xmlDiff = new Diff(newOutcome.getDOM(), impView.getOutcome().getDOM()); - if (xmlDiff.identical()) { - Logger.msg(5, "NewItem.create() - View "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name+" identical, no update required"); - continue; - } - else { - Logger.msg("NewItem.create() - Difference found in view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name+": "+xmlDiff.toString()); - if (!reset && !impView.getEvent().getStepPath().equals("Import")) { - Logger.msg("Last edit was not done by import, and reset not requested. Not overwriting."); - continue; - } - } - } catch (ObjectNotFoundException ex) { - Logger.msg(3, "View "+thisOutcome.schema+"/"+thisOutcome.viewname+" not found in "+name+". Creating."); - impView = new Viewpoint(getItemPath(), thisOutcome.schema, thisOutcome.viewname, thisOutcome.version, -1); - } catch (PersistencyException e) { - throw new ObjectCannotBeUpdated("Could not check data for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name); - } catch (InvalidDataException e) { - throw new ObjectCannotBeUpdated("Could not check previous event for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name); - } - - // write new view/outcome/event - Transition predefDone = new Transition(0, "Done", 0, 0); - Event newEvent = hist.addEvent(agentPath, "Admin", "Import", "Import", "Import", thisOutcome.schema, thisOutcome.version, "PredefinedStep", 0, predefDone, thisOutcome.viewname); - newOutcome.setID(newEvent.getID()); - impView.setEventId(newEvent.getID()); - try { - Gateway.getStorage().put(getItemPath(), newOutcome, null); - Gateway.getStorage().put(getItemPath(), impView, null); - } catch (PersistencyException e) { - throw new ObjectCannotBeUpdated("Could not store data for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name); - } - } - - // register domain path (before collections in case of recursive collections) - if (!domPath.exists()) { - domPath.setItemPath(getItemPath()); - Gateway.getLookupManager().add(domPath); - } - } - - public String getInitialPath() { - return initialPath; - } - - public void setInitialPath(String initialPath) { - this.initialPath = initialPath; - } - - public String getWorkflow() { - return workflow; - } - - public void setWorkflow(String workflow) { - this.workflow = workflow; - } - - public Integer getWorkflowVer() { - return workflowVer; - } - - public void setWorkflowVer(Integer workflowVer) { - this.workflowVer = workflowVer; - } - - public ArrayList getProperties() { - return properties; - } - - public void setProperties(ArrayList properties) { - this.properties = properties; - } - - public ArrayList getAggregationList() { - return aggregationList; - } - - public void setAggregationList(ArrayList aggregationList) { - this.aggregationList = aggregationList; - } - - public ArrayList getDependencyList() { - return dependencyList; - } - - public void setDependencyList(ArrayList dependencyList) { - this.dependencyList = dependencyList; - } - - public ArrayList getOutcomes() { - return outcomes; - } - - public void setOutcomes(ArrayList outcomes) { - this.outcomes = outcomes; - } - -} diff --git a/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java b/src/main/java/com/c2kernel/entity/imports/ImportOutcome.java deleted file mode 100644 index 60279dc..0000000 --- a/src/main/java/com/c2kernel/entity/imports/ImportOutcome.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.entity.imports; - -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.process.Gateway; - -public class ImportOutcome { - public String schema, viewname, path, data; - public int version; - - public ImportOutcome() { - } - - public ImportOutcome(String schema, int version, String viewname, String path) { - super(); - this.schema = schema; - this.version = version; - this.viewname = viewname; - this.path = path; - } - - public String getData(String ns) throws ObjectNotFoundException { - if (data == null) - data = Gateway.getResource().getTextResource(ns, path); - return data; - } - -} diff --git a/src/main/java/com/c2kernel/entity/imports/ImportRole.java b/src/main/java/com/c2kernel/entity/imports/ImportRole.java deleted file mode 100644 index 3583b0b..0000000 --- a/src/main/java/com/c2kernel/entity/imports/ImportRole.java +++ /dev/null @@ -1,74 +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.entity.imports; - -import java.util.Iterator; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.Path; -import com.c2kernel.lookup.RolePath; -import com.c2kernel.process.Gateway; -import com.c2kernel.process.module.ModuleImport; - -public class ImportRole extends ModuleImport { - - private boolean jobList; - - public ImportRole() { - } - - @Override - public void create(AgentPath agentPath, boolean reset) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException { - RolePath parent = new RolePath(); - if (name.indexOf('/') > -1) { - String[] roleComp = name.split("/"); - for (int i=0; i childIter = parent.getChildren(); - boolean found = false; - while (childIter.hasNext()) { - RolePath childRole = (RolePath)childIter.next(); - if (childRole.getName().equals(roleComp[i])) { - parent = childRole; - found = true; - break; - } - } - if (!found) throw new ObjectNotFoundException("Parent role "+roleComp[i]+" was not found"); - } - name = roleComp[roleComp.length-1]; - } - RolePath newRole = new RolePath(parent, name, jobList); - if (!newRole.exists()) Gateway.getLookupManager().createRole(newRole); - } - - public boolean hasJobList() { - return jobList; - } - - public void setJobList(boolean jobList) { - this.jobList = jobList; - } - -} -- cgit v1.2.3