diff options
Diffstat (limited to 'src/main/java/com/c2kernel/collection')
15 files changed, 0 insertions, 1534 deletions
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<AggregationMember>
-{
-
- 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<size(); i++)
- {
- AggregationMember element = mMembers.list.get(i);
- if (element.getItemPath().equals(itemPath))
- return true;
- }
- return false;
- }
-
- public AggregationMember getMemberPair(int vertexID)
- {
- for (int i=0; i<size(); i++)
- {
- AggregationMember element = mMembers.list.get(i);
- if (element.getID() == vertexID)
- return element;
- }
- return null;
- }
-
- public AggregationMember addSlot(CastorHashMap props, String classProps, GraphPoint location, int w, int h)
- {
-
- // Default geometry if not present
- if (location == null) location = new GraphPoint(100,100*getCounter());
- if (w<0) w = 20;
- if (h<0) h = 20;
-
- // Create new member object
- AggregationMember aggMem = new AggregationMember();
- aggMem.setProperties(props);
- aggMem.setClassProps(classProps);
- // create vertex
- Vertex vertex = new Vertex();
- vertex.setHeight(h); vertex.setWidth(w);
- mLayout.addVertexAndCreateId(vertex,location);
- aggMem.setCollection(this);
- aggMem.setID(vertex.getID());
- aggMem.setIsLayoutable(true);
-
- mMembers.list.add(aggMem);
- Logger.msg(8, "AggregationDescription::addSlot new slot linked to vertexid " + vertex.getID());
- return aggMem;
- }
-
- public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps, GraphPoint location, int w, int h)
- throws InvalidCollectionModification, ObjectAlreadyExistsException
- {
- AggregationMember aggMem = addSlot(props, classProps, location, w, h);
- if (itemPath != null) { // some clients use this method when not setting a member
- aggMem.assignItem(itemPath);
- aggMem.setIsComposite( getIsComposite(itemPath, getName()) );
- }
- Logger.msg(8, "AggregationDescription::addMember(" + itemPath + ") assigned to new slot " + aggMem.getID());
- return aggMem;
- }
-
-
- @Override
- public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps)
- throws InvalidCollectionModification, ObjectAlreadyExistsException
- {
- return addMember(itemPath, props, classProps, null, -1, -1);
- }
-
-
- public AggregationMember addMember(CastorHashMap props, String classProps, GraphPoint location, int w, int h)
- throws InvalidCollectionModification {
- try {
- return addMember(null, props, classProps, location, w, h);
- } catch (ObjectAlreadyExistsException e) { // not assigning an item so this won't happen
- return null;
- }
- }
-
- public AggregationMember addSlot(CastorHashMap props, String classProps)
- {
- return addSlot(props, classProps, null, -1, -1);
- }
-
- @Override
- public void removeMember(int memberId) throws ObjectNotFoundException {
- for (AggregationMember element : mMembers.list) {
- if (element.getID() == memberId) {
- element.clearItem();
- mLayout.removeVertex(getLayout().getVertexById(memberId));
- return;
- }
- }
- throw new ObjectNotFoundException("Member "+memberId+" not found");
- }
-
- static public boolean getIsComposite(ItemPath itemPath, String name)
- {
- if (itemPath == null) return false;
- try {
- for(String collName: Gateway.getProxyManager().getProxy(itemPath).getContents(ClusterStorage.COLLECTION) )
- if (name == null || name.equals(collName)) return true;
- } catch (ObjectNotFoundException e) {
- return false;
- }
- return false;
- }
-}
diff --git a/src/main/java/com/c2kernel/collection/AggregationDescription.java b/src/main/java/com/c2kernel/collection/AggregationDescription.java deleted file mode 100644 index a1f979d..0000000 --- a/src/main/java/com/c2kernel/collection/AggregationDescription.java +++ /dev/null @@ -1,81 +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;
-
-/**
- * The description of a Collection with a graph layout. Each slot is
- * instantiated empty in the resulting Aggregation, with ClassProps taken from
- * the PropertyDescription outcome of the description slot's referenced Item.
- */
-
-import com.c2kernel.common.InvalidCollectionModification;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.property.PropertyDescriptionList;
-import com.c2kernel.property.PropertyUtility;
-import com.c2kernel.utils.Logger;
-
-public class AggregationDescription extends Aggregation implements CollectionDescription<AggregationMember>
-{
-
- 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; i<size(); i++)
- {
- AggregationMember mem = mMembers.list.get(i);
- //get the propdesc of the member item and look for an explicit version
- String descVer = getDescVer(mem);
- PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath(), descVer);
- if (pdList!=null)
- {
- //create the new props of the member object
- try {
- Vertex v = getLayout().getVertexById(mem.getID());
- newInstance.addMember(null, PropertyUtility.createProperty(pdList), pdList.getClassProps(),v.getCentrePoint(),v.getWidth(),v.getHeight());
- } catch (InvalidCollectionModification e) {
- } catch (ObjectAlreadyExistsException e) { }
- }
- else
- {
- Logger.error("AggregationDescription::newInstance() There is no PropertyDescription. Cannot instantiate. " + mem.getItemPath());
- return null;
- }
-
-
- }
-
- return newInstance;
- }
-}
diff --git a/src/main/java/com/c2kernel/collection/AggregationInstance.java b/src/main/java/com/c2kernel/collection/AggregationInstance.java deleted file mode 100644 index d2dbf7f..0000000 --- a/src/main/java/com/c2kernel/collection/AggregationInstance.java +++ /dev/null @@ -1,68 +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;
-
-/**
- * Instance of an Aggregation. Unlike in the description, Items may only be
- * assigned to one slot.
- */
-
-import com.c2kernel.common.InvalidCollectionModification;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.utils.CastorHashMap;
-
-public class AggregationInstance extends Aggregation
-{
-
- public AggregationInstance()
- {
- setName("AggregationInstance");
- }
-
- public AggregationInstance(String name)
- {
- setName(name);
- }
-
-
- @Override
- public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps)
- throws InvalidCollectionModification, ObjectAlreadyExistsException
- {
- if( itemPath != null && exists(itemPath))
- throw new ObjectAlreadyExistsException(itemPath+" already exists in this collection.");
- else
- return super.addMember(itemPath, props, classProps);
- }
-
- @Override
- public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps, GraphPoint location, int w, int h)
- throws InvalidCollectionModification, ObjectAlreadyExistsException
- {
- if( itemPath != null && exists(itemPath))
- throw new ObjectAlreadyExistsException(itemPath+" already exists in this collection.");
- else
- return super.addMember(itemPath, props, classProps, location, w, h);
- }
-}
-
diff --git a/src/main/java/com/c2kernel/collection/AggregationMember.java b/src/main/java/com/c2kernel/collection/AggregationMember.java deleted file mode 100644 index 903914c..0000000 --- a/src/main/java/com/c2kernel/collection/AggregationMember.java +++ /dev/null @@ -1,169 +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.graph.model.GraphableVertex;
-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.Logger;
-
-/**
-* A CollectionMember, or slot, of an Aggregation instance or description.
-* Verifies type information of Items during assignment based on
-* PropertyDescription information stored in slot properties and listed as
-* ClassProps.
-*/
-
-public class AggregationMember extends GraphableVertex implements CollectionMember
-{
-
- private ItemPath mItemPath = null;
- private ItemProxy mItem = null;
- private Aggregation mCollection = null;
- private String mClassProps = null;
- private String mItemName = null;
-
-
- /**************************************************************************
- *
- **************************************************************************/
- public AggregationMember()
- {
- super();
- }
-
- public void setCollection(Aggregation aggregation)
- {
- mCollection = aggregation;
- }
-
- public void setClassProps(String props)
- {
- mClassProps = props;
- }
-
- @Override
- public ItemPath getItemPath()
- {
- return mItemPath;
- }
-
- public Aggregation getCollection()
- {
- return mCollection;
- }
-
- @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() == null || !ItemProperty.getValue().equalsIgnoreCase(memberValue))
- throw new InvalidCollectionModification("Value of mandatory prop "+aClassProp+" does not match: " + ItemProperty.getValue()+"!="+memberValue);
- }
- catch (InvalidCollectionModification ex) {
- throw ex;
- }
- catch (Exception ex)
- {
- Logger.error(ex);
- throw new InvalidCollectionModification("Error checking properties");
- }
- }
- }
-
- mItemPath = itemPath;
- mItem = null;
- mItemName = null;
- }
-
- @Override
- public void clearItem() {
- mItemPath = null;
- mItem = null;
- mItemName = null;
- }
-
- @Override
- public ItemProxy resolveItem() throws ObjectNotFoundException {
- if (mItem == null && mItemPath != null) {
- mItem = Gateway.getProxyManager().getProxy(mItemPath);
- }
- return mItem;
-
- }
-
- public String getItemName() {
- if (mItemName == null) {
- if (mItemPath != null) {
- try {
- mItemName = resolveItem().getName();
- } catch (ObjectNotFoundException ex) {
- Logger.error(ex);
- mItemName = "Error ("+mItemPath+")";
- }
- }
- else
- mItemName = "Empty";
- }
-
- return mItemName;
- }
-
- public void setChildUUID(String uuid) throws InvalidCollectionModification, InvalidItemPathException {
- mItemPath = new ItemPath(uuid);
- mItemName = null;
- }
-
-
- @Override
- public String getChildUUID() {
- if (getItemPath() == null) return null;
- return getItemPath().getUUID().toString();
- }
-
-}
diff --git a/src/main/java/com/c2kernel/collection/AggregationVertexFactory.java b/src/main/java/com/c2kernel/collection/AggregationVertexFactory.java deleted file mode 100644 index 6fa7014..0000000 --- a/src/main/java/com/c2kernel/collection/AggregationVertexFactory.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 com.c2kernel.graph.model.GraphModelManager;
-import com.c2kernel.graph.model.GraphPoint;
-import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
-import com.c2kernel.graph.model.VertexFactory;
-import com.c2kernel.utils.CastorHashMap;
-
-/**
- * GraphModel vertex factory for AggregationMembers
- *
- */
-public class AggregationVertexFactory implements VertexFactory
-{
- private Aggregation mAggregation = null;
-
-
- @Override
- public void setCreationContext(Object aggregation)
- {
- if (aggregation != null && aggregation instanceof Aggregation)
- mAggregation = (Aggregation)aggregation;
- }
-
-
- @Override
- public void create
- (
- GraphModelManager graphModelManager,
- GraphPoint location,
- TypeNameAndConstructionInfo typeNameAndConstructionInfo
- ) throws Exception
- {
- if (typeNameAndConstructionInfo.mInfo.equals("AggregationMember")) {
- mAggregation.addMember(null, new CastorHashMap(), "",location, 40, 40);
- }
- }
-}
-
diff --git a/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java b/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java deleted file mode 100644 index fbd5434..0000000 --- a/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java +++ /dev/null @@ -1,68 +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.graph.model.GraphPoint;
-import com.c2kernel.graph.model.Vertex;
-import com.c2kernel.graph.model.VertexOutlineCreator;
-
-/**
- * AggregationMember vertex outline creator. Sets up the new dimensions and
- * position on the GraphModel.
- *
- */
-public class AggregationVertexOutlineCreator implements VertexOutlineCreator
-{
- @Override
- public void setOutline(Vertex vertex)
- {
- GraphPoint centre = vertex.getCentrePoint();
- int height = vertex.getHeight();
- int width = vertex.getWidth();
-
-
- if (height==0 || width==0)
- vertex.setOutlinePoints
- (
- new GraphPoint[]
- {
- new GraphPoint(centre.x-20, centre.y-20),
- new GraphPoint(centre.x+20, centre.y-20),
- new GraphPoint(centre.x+20, centre.y+20),
- new GraphPoint(centre.x-20, centre.y+20)
-
- }
- );
- else
-
- vertex.setOutlinePoints
- (
- new GraphPoint[]
- {
- new GraphPoint(centre.x-width/2, centre.y-height/2),
- new GraphPoint(centre.x+width/2, centre.y-height/2),
- new GraphPoint(centre.x+width/2, centre.y+height/2),
- new GraphPoint(centre.x-width/2, centre.y+height/2)
-
- }
- );
- }
-}
diff --git a/src/main/java/com/c2kernel/collection/Collection.java b/src/main/java/com/c2kernel/collection/Collection.java deleted file mode 100644 index 34ec93f..0000000 --- a/src/main/java/com/c2kernel/collection/Collection.java +++ /dev/null @@ -1,261 +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.entity.C2KLocalObject;
-import com.c2kernel.graph.model.GraphModel;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.utils.CastorHashMap;
-
-/**
- * Collections are Item local objects that reference other Items.
- *
- * <p>In 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.
- *
- * <p>Features:
- * <ul>
- * <li><b>Typing</b> - 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.
- *
- * <li><b>Fixed or flexible slots</b> - The CollectionMember objects of a
- * Collection may be empty, individually typed, or created and removed as
- * required, simulating either array, structures or lists.
- *
- * <li><b>Layout</b> - Collections can include a {@link GraphModel} to lay out
- * its slots on a two-dimensional canvas, for modelling real world compositions.
- * </ul>
- *
- * <p>Collections are managed through predefined steps.
- */
-abstract public class Collection<E extends CollectionMember> implements C2KLocalObject
-{
-
- public static final short EMPTY = -1;
- private int mCounter = -1; // Contains next available Member ID
- protected CollectionMemberList<E> mMembers = new CollectionMemberList<E>();
- 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<E> 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<E> 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<Collection<? extends CollectionMember>> {
- public CollectionArrayList()
- {
- super();
- }
-
- public CollectionArrayList(ArrayList<Collection<? extends CollectionMember>> aList)
- {
- super();
- for (Collection<? extends CollectionMember> coll : aList) {
- put(coll);
- }
- }
-
- /** This put method overwrites any collections with the same name already in
- * the list.
- */
- public void put(Collection<? extends CollectionMember> c) {
- for (Collection<? extends CollectionMember> 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<E extends CollectionMember> 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<E> 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 <E> The CollectionMember implementation stored.
- */
-public class CollectionMemberList<E extends CollectionMember> extends CastorArrayList<E>
-{
-
- 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.
- *
- * <p>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:
- *
- * <ul>
- * <li>
- */
-public class Dependency extends Collection<DependencyMember>
-{
-
- 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<DependencyMember>{
-
- public DependencyDescription()
- {
- setName("DependencyDescription");
- }
-
- public DependencyDescription(String name)
- {
- setName(name);
- }
-
- @Override
- public Collection<DependencyMember> 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 |
