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/collection/Aggregation.java | 177 -------------- .../collection/AggregationDescription.java | 81 ------- .../c2kernel/collection/AggregationInstance.java | 68 ------ .../com/c2kernel/collection/AggregationMember.java | 169 ------------- .../collection/AggregationVertexFactory.java | 59 ----- .../AggregationVertexOutlineCreator.java | 68 ------ .../java/com/c2kernel/collection/Collection.java | 261 --------------------- .../c2kernel/collection/CollectionArrayList.java | 59 ----- .../c2kernel/collection/CollectionDescription.java | 40 ---- .../com/c2kernel/collection/CollectionMember.java | 98 -------- .../c2kernel/collection/CollectionMemberList.java | 39 --- .../java/com/c2kernel/collection/Dependency.java | 146 ------------ .../c2kernel/collection/DependencyDescription.java | 78 ------ .../com/c2kernel/collection/DependencyMember.java | 164 ------------- .../java/com/c2kernel/collection/package-info.java | 27 --- 15 files changed, 1534 deletions(-) delete mode 100644 src/main/java/com/c2kernel/collection/Aggregation.java delete mode 100644 src/main/java/com/c2kernel/collection/AggregationDescription.java delete mode 100644 src/main/java/com/c2kernel/collection/AggregationInstance.java delete mode 100644 src/main/java/com/c2kernel/collection/AggregationMember.java delete mode 100644 src/main/java/com/c2kernel/collection/AggregationVertexFactory.java delete mode 100644 src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java delete mode 100644 src/main/java/com/c2kernel/collection/Collection.java delete mode 100644 src/main/java/com/c2kernel/collection/CollectionArrayList.java delete mode 100644 src/main/java/com/c2kernel/collection/CollectionDescription.java delete mode 100644 src/main/java/com/c2kernel/collection/CollectionMember.java delete mode 100644 src/main/java/com/c2kernel/collection/CollectionMemberList.java delete mode 100644 src/main/java/com/c2kernel/collection/Dependency.java delete mode 100644 src/main/java/com/c2kernel/collection/DependencyDescription.java delete mode 100644 src/main/java/com/c2kernel/collection/DependencyMember.java delete mode 100644 src/main/java/com/c2kernel/collection/package-info.java (limited to 'src/main/java/com/c2kernel/collection') diff --git a/src/main/java/com/c2kernel/collection/Aggregation.java b/src/main/java/com/c2kernel/collection/Aggregation.java deleted file mode 100644 index 68b52cf..0000000 --- a/src/main/java/com/c2kernel/collection/Aggregation.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.collection; - -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.graph.model.GraphModel; -import com.c2kernel.graph.model.GraphPoint; -import com.c2kernel.graph.model.TypeNameAndConstructionInfo; -import com.c2kernel.graph.model.Vertex; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.CastorHashMap; -import com.c2kernel.utils.Language; -import com.c2kernel.utils.Logger; - -/** - * A Collection with a graph layout - */ - -abstract public class Aggregation extends Collection -{ - - protected GraphModel mLayout = new GraphModel(new AggregationVertexOutlineCreator()); - - private final TypeNameAndConstructionInfo[] mVertexTypeNameAndConstructionInfo = { - new TypeNameAndConstructionInfo(Language.translate("Slot"), "AggregationMember") - }; - - public Aggregation() - { - setName("Aggregation"); - } - - - public GraphModel getLayout() - { - return mLayout; - } - - public void setLayout(GraphModel layout) - { - mLayout = layout; - layout.setVertexOutlineCreator(new AggregationVertexOutlineCreator()); - } - - public TypeNameAndConstructionInfo[] getVertexTypeNameAndConstructionInfo() - { - return mVertexTypeNameAndConstructionInfo; - } - - public boolean exists(ItemPath itemPath) - { - for (int i=0; i -{ - - public AggregationDescription() - { - setName("AggregationDescription"); - } - - public AggregationDescription(String name) - { - setName(name); - } - - @Override - public Aggregation newInstance() throws ObjectNotFoundException - { - AggregationInstance newInstance = new AggregationInstance(getName()); - //for each desc member - for (int i=0; iIn parallel with the OO meta-model, Items can be linked to other Items in - * different ways. These links are modelled with Collections, which are local - * objects stored in an Item which reference a number of other Items in the same - * server. The Collections holds a CollectionMember, sometimes known as a slot, - * to reference each Item and store additional information about the link. - * - *

Features: - *

    - *
  • Typing - Collections can restrict membership of based on type - * information derived from Item, Property and Collection descriptions. This - * restriction may be per-slot or apply to the whole Collection. - * - *
  • Fixed or flexible slots - The CollectionMember objects of a - * Collection may be empty, individually typed, or created and removed as - * required, simulating either array, structures or lists. - * - *
  • Layout - Collections can include a {@link GraphModel} to lay out - * its slots on a two-dimensional canvas, for modelling real world compositions. - *
- * - *

Collections are managed through predefined steps. - */ -abstract public class Collection implements C2KLocalObject -{ - - public static final short EMPTY = -1; - private int mCounter = -1; // Contains next available Member ID - protected CollectionMemberList mMembers = new CollectionMemberList(); - protected String mName = ""; // Not checked for uniqueness - protected Integer mVersion = null; - - /** - * Fetch the current highest member ID of the collection. This is found by - * scanning all the current members and kept in the mCounter field, but is - * not persistent. - * @return the current highest member ID - */ - public int getCounter() - { - if (mCounter == -1) - for (E element : mMembers.list) { - if (mCounter < element.getID()) - mCounter = element.getID(); - } - return ++mCounter; - } - - /** - * @return The total number of slots in this collection, including empty - * ones - */ - public int size() - { - return mMembers.list.size(); - } - - /** - * Sets the collection name - */ - @Override - public void setName(String name) - { - mName = name; - } - - /** - * @return The collection's name - */ - @Override - public String getName() - { - return mName; - } - - /** - * Get the collection version. Null if not set, and will be stored as 'last' - * @return Integer version - */ - public Integer getVersion() { - return mVersion; - } - - /** - * Set a named version for this collection. Must be an integer or null. - * Named versions will be stored separately to the current version ('last') - * and should not change once saved. - * - * @param Integer version - */ - public void setVersion(Integer mVersion) { - this.mVersion = mVersion; - } - - /** - * Get the version name for storage, which is 'last' unless the version - * number is set. - * - * @return - */ - public String getVersionName() { - return mVersion==null?"last":String.valueOf(mVersion); - } - - @Override - public String getClusterType() - { - return ClusterStorage.COLLECTION; - } - - public void setMembers(CollectionMemberList newMembers) - { - mMembers = newMembers; - } - - public boolean contains(ItemPath itemPath) { - for (E element : mMembers.list) { - if (element.getItemPath().equals(itemPath)) - return true; - } - return false; - } - - /** - * Gets the description version referenced by the given collection member. - * Assumes 'last' if version not given. - * - * @param mem The member in question - * @return String version tag - */ - public String getDescVer(E mem) { - String descVer = "last"; - Object descVerObj = mem.getProperties().get("Version"); - if (descVerObj != null) descVer = descVerObj.toString(); - return descVer; - } - - /** - * Check if all slots have an assigned Item - * @return boolean - */ - public boolean isFull() - { - for (E element : mMembers.list) { - if (element.getItemPath() == null) - return false; - } - return true; - } - - /** - * Find collection member by integer ID - * @param memberId to find - * @return the CollectionMember with that ID - * @throws ObjectNotFoundException when the ID wasn't found - */ - public E getMember(int memberId) throws ObjectNotFoundException { - for (E element : mMembers.list) { - if (element.getID() == memberId) - return element; - } - throw new ObjectNotFoundException("Member "+memberId+" not found in "+mName); - } - - public CollectionMemberList getMembers() - { - return mMembers; - } - - /** - * Add a member to this collection, with the given property and class properties - * and optionally an Item to assign, which may be null if the collection allows - * empty slots. - * - * @param itemPath the Item to assign to the new slot. Optional for collections - * that allow empty slots - * @param props the Properties of the new member - * @param classProps the names of the properties that dictate the type of - * assigned Items. - * @return the new CollectionMember instance - * @throws InvalidCollectionModification when the assignment was invalid because - * of collection constraints, such as global type constraints, or not allowing - * empty slots. - * @throws ObjectAlreadyExistsException some collections don't allow multiple - * slots assigned to the same Item, and throw this Exception if it is attempted - */ - public abstract E addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws InvalidCollectionModification, ObjectAlreadyExistsException; - - /** - * Removes the slot with the given ID from the collection. - * - * @param memberId to remove - * @throws ObjectNotFoundException when there was no slot with this ID found. - */ - public abstract void removeMember(int memberId) throws ObjectNotFoundException; - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((mMembers == null) ? 0 : mMembers.hashCode()); - result = prime * result + ((mName == null) ? 0 : mName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Collection other = (Collection) obj; - if (mMembers == null) { - if (other.mMembers != null) - return false; - } else if (!mMembers.equals(other.mMembers)) - return false; - if (mName == null) { - if (other.mName != null) - return false; - } else if (!mName.equals(other.mName)) - return false; - return true; - } -} diff --git a/src/main/java/com/c2kernel/collection/CollectionArrayList.java b/src/main/java/com/c2kernel/collection/CollectionArrayList.java deleted file mode 100644 index 2c96170..0000000 --- a/src/main/java/com/c2kernel/collection/CollectionArrayList.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.collection; - -import java.util.ArrayList; - -import com.c2kernel.utils.CastorArrayList; - -/** - * A bundle of Collections. Used for storage and export/import using XML - * persistency via Castor, and to set up an Item's initial collections during - * initialization. - * - */ -public class CollectionArrayList extends CastorArrayList> { - public CollectionArrayList() - { - super(); - } - - public CollectionArrayList(ArrayList> aList) - { - super(); - for (Collection coll : aList) { - put(coll); - } - } - - /** This put method overwrites any collections with the same name already in - * the list. - */ - public void put(Collection c) { - for (Collection thisColl : list) { - if (thisColl.getName().equals(c.getName())) { - list.remove(thisColl); - break; - } - } - list.add(c); - } -} diff --git a/src/main/java/com/c2kernel/collection/CollectionDescription.java b/src/main/java/com/c2kernel/collection/CollectionDescription.java deleted file mode 100644 index 6f64abf..0000000 --- a/src/main/java/com/c2kernel/collection/CollectionDescription.java +++ /dev/null @@ -1,40 +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.collection; - -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.C2KLocalObject; - -/** - * A collection that can be instantiated. Collection descriptions link Item - * descriptions together, which constrains membership of their instance. - * - */ -public interface CollectionDescription extends C2KLocalObject { - - /** - * Create a new instance of this collection. - * @return a new collection instance - * @throws ObjectNotFoundException When an essential piece of description - * data, such as a child Item PropertyDescription outcome, doesn't exist. - */ - public Collection newInstance() throws ObjectNotFoundException; -} diff --git a/src/main/java/com/c2kernel/collection/CollectionMember.java b/src/main/java/com/c2kernel/collection/CollectionMember.java deleted file mode 100644 index 3925435..0000000 --- a/src/main/java/com/c2kernel/collection/CollectionMember.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.collection; - -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.proxy.ItemProxy; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.utils.CastorHashMap; - -/** - * CollectionMembers are pointers to individual Items in a collection. Under - * certain circumstances they may be empty, or they can be created and destroyed - * as required. They can hold properties containing annotations about the link, - * including information on the typing of the Item they should point to. - * Properties that dictate type information are specified in the ClassProps, and - * assignment of an Item will fail if those member properties do not match the - * Property values of the Item attempting to be assigned, throwing a - * {@link MembershipException} detailing the mismatches. - * - */ - -public interface CollectionMember { - - /** - * Returns the current assigned ItemPath - * @return the ItemPath, null if empty - */ - public ItemPath getItemPath(); - - /** - * Returns the UUID of the currently assigned Item - * @return - */ - public String getChildUUID(); - - /** - * Assign the given item to the slot, if it fits - * - * @param itemPath The item to assign - * @throws MembershipException When the Item Properties don't match the - * typing specification in ClassProps and Properties - * @throws InvalidCollectionModification - */ - public void assignItem(ItemPath itemPath) throws InvalidCollectionModification; - - /** - * De-assign the slot, leaving it empty. - */ - public void clearItem(); - - /** - * Resolve the Item currently assigned - * @return the ItemProxy of the assigned Item - * @throws ObjectNotFoundException When empty - */ - public ItemProxy resolveItem() throws ObjectNotFoundException; - - /** - * Get the integer slot ID, as generated by the parent Collection - * @return ID - */ - public int getID(); - - /** - * Gets the member properties. - * @return CastorHashMap - */ - public CastorHashMap getProperties(); - - /** - * Gets the class properties, which specify type information in child Items. - * On instantiation from a CollectionDescription, the ClassProps are - * generated from the PropertyDescriptions which have the isClassIdentifier - * boolean set to true. - * - * @return Comma-separated list of property names that relate to Item type - */ - public String getClassProps(); -} diff --git a/src/main/java/com/c2kernel/collection/CollectionMemberList.java b/src/main/java/com/c2kernel/collection/CollectionMemberList.java deleted file mode 100644 index 49096e0..0000000 --- a/src/main/java/com/c2kernel/collection/CollectionMemberList.java +++ /dev/null @@ -1,39 +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.collection; - -import com.c2kernel.utils.CastorArrayList; - -/** - * A list of CollectionMembers, used internally in the Collection for XML - * marshalling convenience. - * * - * @param The CollectionMember implementation stored. - */ -public class CollectionMemberList extends CastorArrayList -{ - - public CollectionMemberList() - { - super(); - } - -} diff --git a/src/main/java/com/c2kernel/collection/Dependency.java b/src/main/java/com/c2kernel/collection/Dependency.java deleted file mode 100644 index 1dd777c..0000000 --- a/src/main/java/com/c2kernel/collection/Dependency.java +++ /dev/null @@ -1,146 +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.collection; - - -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.utils.CastorHashMap; -import com.c2kernel.utils.KeyValuePair; -import com.c2kernel.utils.Logger; - -/** - * A Collection implementation that contains a variable number of members of the - * same type, like a variable-length array. CollectionMembers are created and - * destroyed as needed. A Dependency never contains empty slots, nor duplicated - * members. - * - *

ClassProps are stored at the collection level and duplicated in each slot. - * Slots may still have their own individual properties annotating their link. - * - * Predefined steps managing Dependencies: - * - *

    - *
  • - */ -public class Dependency extends Collection -{ - - protected CastorHashMap mProperties = new CastorHashMap(); - protected String mClassProps = ""; - - public Dependency() - { - setName("Dependency"); - } - - public Dependency(String name) - { - setName(name); - } - - public CastorHashMap getProperties() { - return mProperties; - } - - public void setProperties(CastorHashMap props) { - mProperties = props; - } - - public KeyValuePair[] getKeyValuePairs() - { - return mProperties.getKeyValuePairs(); - } - public void setKeyValuePairs(KeyValuePair[] pairs) - { - mProperties.setKeyValuePairs(pairs); - } - - public void setClassProps(String classProps) { - this.mClassProps = classProps; - } - - public String getClassProps() { - return mClassProps; - } - - public DependencyMember addMember(ItemPath itemPath) throws InvalidCollectionModification, ObjectAlreadyExistsException { - if (contains(itemPath)) throw new ObjectAlreadyExistsException("Item "+itemPath+" already exists in Dependency "+getName()); - // create member object - DependencyMember depMember = new DependencyMember(); - depMember.setID(getCounter()); - depMember.setProperties((CastorHashMap)mProperties.clone()); - depMember.setClassProps(mClassProps); - - // assign entity - depMember.assignItem(itemPath); - mMembers.list.add(depMember); - Logger.msg(8, "Dependency::addMember(" + itemPath + ") added to children."); - return depMember; - } - - @Override - public DependencyMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) - throws InvalidCollectionModification, ObjectAlreadyExistsException - { - if (contains(itemPath)) throw new ObjectAlreadyExistsException("Item "+itemPath+" already exists in Dependency "+getName()); - if (classProps != null && !classProps.equals(mClassProps)) - throw new InvalidCollectionModification("Cannot change classProps in dependency member"); - DependencyMember depMember = new DependencyMember(); - depMember.setID(getCounter()); - - // merge props - CastorHashMap newProps = new CastorHashMap(); - for (Object name : props.keySet()) { - String key = (String)name; - newProps.put(key, props.get(key)); - - } - // class props override local - for (Object name : mProperties.keySet()) { - String key = (String)name; - newProps.put(key, mProperties.get(key)); - - } - depMember.setProperties(newProps); - depMember.setClassProps(mClassProps); - - // assign entity - depMember.assignItem(itemPath); - mMembers.list.add(depMember); - Logger.msg(8, "Dependency::addMember(" + itemPath + ") added to children."); - return depMember; - } - - @Override - public void removeMember(int memberId) throws ObjectNotFoundException { - for (DependencyMember element : mMembers.list) { - if (element.getID() == memberId) { - mMembers.list.remove(element); - return; - } - } - throw new ObjectNotFoundException("Member "+memberId+" not found"); - } - -} diff --git a/src/main/java/com/c2kernel/collection/DependencyDescription.java b/src/main/java/com/c2kernel/collection/DependencyDescription.java deleted file mode 100644 index d49b505..0000000 --- a/src/main/java/com/c2kernel/collection/DependencyDescription.java +++ /dev/null @@ -1,78 +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.collection; - -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.property.PropertyDescriptionList; -import com.c2kernel.property.PropertyUtility; -import com.c2kernel.utils.CastorHashMap; - -public class DependencyDescription extends Dependency implements CollectionDescription{ - - public DependencyDescription() - { - setName("DependencyDescription"); - } - - public DependencyDescription(String name) - { - setName(name); - } - - @Override - public Collection newInstance() throws ObjectNotFoundException{ - String depName = getName().replaceFirst("\'$", ""); // HACK: Knock the special 'prime' off the end for the case of descriptions of descriptions - Dependency newDep = new Dependency(depName); - if (mMembers.list.size() == 1) { // constrain the members based on the property description - DependencyMember mem = mMembers.list.get(0); - String descVer = getDescVer(mem); - PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath(), descVer); - if (pdList!=null) { - newDep.setProperties(PropertyUtility.createProperty(pdList)); - newDep.setClassProps(pdList.getClassProps()); - } - } - return newDep; - } - - - @Override - public DependencyMember addMember(ItemPath itemPath) throws InvalidCollectionModification, ObjectAlreadyExistsException { - checkMembership(); - return super.addMember(itemPath); - } - - @Override - public DependencyMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) - throws InvalidCollectionModification, ObjectAlreadyExistsException { - checkMembership(); - return super.addMember(itemPath, props, classProps); - } - - public void checkMembership() throws InvalidCollectionModification { - if (mMembers.list.size() > 0) - throw new InvalidCollectionModification("Dependency descriptions may not have more than one member."); - } - -} diff --git a/src/main/java/com/c2kernel/collection/DependencyMember.java b/src/main/java/com/c2kernel/collection/DependencyMember.java deleted file mode 100644 index dbb79e3..0000000 --- a/src/main/java/com/c2kernel/collection/DependencyMember.java +++ /dev/null @@ -1,164 +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.collection; - -import java.util.StringTokenizer; - -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.proxy.ItemProxy; -import com.c2kernel.lookup.InvalidItemPathException; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.property.Property; -import com.c2kernel.utils.CastorHashMap; -import com.c2kernel.utils.KeyValuePair; -import com.c2kernel.utils.Logger; - - -/** -* @version $Revision: 1.10 $ $Date: 2004/10/21 08:02:23 $ -* @author $Author: abranson $ -*/ - - -public class DependencyMember implements CollectionMember -{ - - private ItemPath mItemPath = null; - private ItemProxy mItem = null; - private int mId = -1; - private CastorHashMap mProperties = null; - private String mClassProps; - - - /************************************************************************** - * - **************************************************************************/ - public DependencyMember() - { - mProperties = new CastorHashMap(); - } - - @Override - public ItemPath getItemPath() - { - return mItemPath; - } - - public void setProperties(CastorHashMap props) - { - mProperties = props; - } - - @Override - public CastorHashMap getProperties() - { - return mProperties; - } - - public KeyValuePair[] getKeyValuePairs() - { - return mProperties.getKeyValuePairs(); - } - public void setKeyValuePairs(KeyValuePair[] pairs) - { - mProperties.setKeyValuePairs(pairs); - } - - @Override - public int getID() { - return mId; - } - - public void setID(int id) { - mId = id; - } - - public void setClassProps(String props) - { - mClassProps = props; - } - - @Override - public String getClassProps() - { - return mClassProps; - } - - @Override - public void assignItem(ItemPath itemPath) throws InvalidCollectionModification - { - if (itemPath != null) { - if (mClassProps == null || getProperties() == null) - throw new InvalidCollectionModification("ClassProps not yet set. Cannot check membership validity."); - - //for each mandatory prop check if its in the member property and has the matching value - StringTokenizer sub = new StringTokenizer(mClassProps, ","); - while (sub.hasMoreTokens()) - { - String aClassProp = sub.nextToken(); - try { - String memberValue = (String)getProperties().get(aClassProp); - Property ItemProperty = (Property)Gateway.getStorage().get(itemPath, ClusterStorage.PROPERTY+"/"+aClassProp, null); - if (ItemProperty == null) - throw new InvalidCollectionModification("Property "+aClassProp+ " does not exist for item " + itemPath ); - if (!ItemProperty.getValue().equalsIgnoreCase(memberValue)) - throw new InvalidCollectionModification("DependencyMember::checkProperty() Values of mandatory prop "+aClassProp+" do not match " + ItemProperty.getValue()+"!="+memberValue); - } - catch (Exception ex) - { - Logger.error(ex); - throw new InvalidCollectionModification("Error checking properties"); - } - } - } - - mItemPath = itemPath; - mItem = null; - } - - @Override - public void clearItem() { - mItemPath = null; - mItem = null; - } - - @Override - public ItemProxy resolveItem() throws ObjectNotFoundException { - if (mItem == null && mItemPath != null) - mItem = Gateway.getProxyManager().getProxy(mItemPath); - return mItem; - } - - public void setChildUUID(String uuid) throws InvalidCollectionModification, InvalidItemPathException { - mItemPath = new ItemPath(uuid); - } - - - @Override - public String getChildUUID() { - return mItemPath.getUUID().toString(); - } - - -} diff --git a/src/main/java/com/c2kernel/collection/package-info.java b/src/main/java/com/c2kernel/collection/package-info.java deleted file mode 100644 index 96bd022..0000000 --- a/src/main/java/com/c2kernel/collection/package-info.java +++ /dev/null @@ -1,27 +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 - */ -/** - * Collections are Item local objects that reference other Items. - * - * @see Collection - */ - -package com.c2kernel.collection; \ No newline at end of file -- cgit v1.2.3