Simexplorer-si-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
March 2008
- 2 participants
- 198 discussions
r1313 - trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:45:57 +0000 (Sat, 08 Mar 2008)
New Revision: 1313
Modified:
trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java
Log:
Deprecated
Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-03-08 00:45:12 UTC (rev 1312)
+++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-03-08 00:45:57 UTC (rev 1313)
@@ -35,6 +35,7 @@
*
* @author chemit
*/
+ at Deprecated
public class MockStorageServiceImpl implements StorageService {
protected MockDatabase base;
1
0
r1312 - trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:45:12 +0000 (Sat, 08 Mar 2008)
New Revision: 1312
Modified:
trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java
Log:
Obsolet class
Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java 2008-03-08 00:44:48 UTC (rev 1311)
+++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java 2008-03-08 00:45:12 UTC (rev 1312)
@@ -43,6 +43,7 @@
*
* @author chemit
*/
+ at Deprecated
public class MockDatabase {
static final int SIZE = 10;
1
0
r1311 - trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:44:48 +0000 (Sat, 08 Mar 2008)
New Revision: 1311
Modified:
trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java
Log:
Obsolet class
Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java 2008-03-08 00:37:54 UTC (rev 1310)
+++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java 2008-03-08 00:44:48 UTC (rev 1311)
@@ -144,10 +144,12 @@
protected void registerLoggableElement(String uuid, LoggableElement... loggableElements) throws Exception {
if (loggableElements.length == 1) {
+ /*
// generate versions for the unique LE given
LoggableElement loggableElement = loggableElements[0];
loggableElement.getMetaData().setLatest(false);
String name =loggableElement.getMetaData().getName();
+
List<? extends LoggableElement> sons = elementGenerator.generateArray(loggableElement.getClass());
int nbSons = 1 + sons.size();
Version[] versions = versionGenerator.generateVersions(nbSons + 1);
@@ -162,6 +164,7 @@
listSons.add(sonEA);
}
loggableElements = listSons.toArray(new LoggableElement[listSons.size()]);
+ */
}
this.loggableElements.put(uuid, loggableElements);
List<MetaData> datas = new ArrayList<MetaData>();
1
0
r1310 - trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:37:54 +0000 (Sat, 08 Mar 2008)
New Revision: 1310
Modified:
trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/ElementGenerator.java
Log:
"Simplified"
Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/ElementGenerator.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/ElementGenerator.java 2008-03-08 00:28:59 UTC (rev 1309)
+++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/ElementGenerator.java 2008-03-08 00:37:54 UTC (rev 1310)
@@ -29,8 +29,16 @@
import org.codelutin.util.MD5;
import fr.cemagref.simexplorer.is.entities.Entity;
-import fr.cemagref.simexplorer.is.entities.SimpleComposite;
import fr.cemagref.simexplorer.is.entities.attachment.Attachment;
+import fr.cemagref.simexplorer.is.entities.composite.Codes;
+import fr.cemagref.simexplorer.is.entities.composite.Components;
+import fr.cemagref.simexplorer.is.entities.composite.ConstantValues;
+import fr.cemagref.simexplorer.is.entities.composite.Constants;
+import fr.cemagref.simexplorer.is.entities.composite.Descriptors;
+import fr.cemagref.simexplorer.is.entities.composite.ExplorationDatas;
+import fr.cemagref.simexplorer.is.entities.composite.Libraries;
+import fr.cemagref.simexplorer.is.entities.composite.SimpleComposite;
+import fr.cemagref.simexplorer.is.entities.composite.Structures;
import fr.cemagref.simexplorer.is.entities.data.Code;
import fr.cemagref.simexplorer.is.entities.data.Component;
import fr.cemagref.simexplorer.is.entities.data.Constant;
@@ -101,7 +109,7 @@
/** The cs. */
private static int cs;
-
+
private static int counter = 0;
/** The randomstrings. */
@@ -186,7 +194,7 @@
metaData.setHash(shortString());
metaData.setLatest(true);
- List<Descriptor> descriptors = new ArrayList<Descriptor>();
+ Descriptors descriptors = new Descriptors();
for (int i = 0, max = 1 + r.nextInt(12); i < max; i++) {
descriptors.add(new Descriptor(shortString(), shortString()));
}
@@ -202,22 +210,12 @@
element.setMetaData(metaData);
}
- /**
- * Generate array.
- *
- * @param <T> Class in array
- *
- * @param clazz the clazz
- *
- * @return the set< t>
- *
- * @throws Exception the exception
- */
- public <T extends Entity> List<T> generateArray(Class<T> clazz) throws Exception {
- List<T> elements = new ArrayList<T>();
+ public <SC extends SimpleComposite<T>, T extends Entity> SC generateComposite(Class<SC> compositeClass,
+ Class<T> elementClass) throws Exception {
+ SC elements = compositeClass.newInstance();
int i = 3 + r.nextInt(2);
for (int j = 0; j < i; j++) {
- T element = clazz.newInstance();
+ T element = elementClass.newInstance();
if (element instanceof LoggableElement) {
update((LoggableElement) element);
}
@@ -236,16 +234,18 @@
public ExplorationApplication generateRandomEA() throws Exception {
ExplorationApplication ea = new ExplorationApplication();
update(ea);
- List<ExplorationData> datas = generateArray(ExplorationData.class);
- for (ExplorationData object : datas) {
+
+ ExplorationDatas explorationDatas = generateComposite(ExplorationDatas.class, ExplorationData.class);
+ for (ExplorationData object : explorationDatas) {
processExplorationData(object);
}
- ea.setExplorations(SimpleComposite.castList(datas));
- List<Component> components = generateArray(Component.class);
+ ea.setExplorations(explorationDatas);
+
+ Components components = generateComposite(Components.class, Component.class);
for (Component object : components) {
processComponent(object);
}
- ea.setComponents(SimpleComposite.castList(components));
+ ea.setComponents(components);
return ea;
}
@@ -257,21 +257,21 @@
* @throws Exception the exception
*/
private void processComponent(Component component) throws Exception {
- List<Constant> constants = generateArray(Constant.class);
+ Constants constants = generateComposite(Constants.class, Constant.class);
for (Constant constant : constants) {
processConstant(constant);
}
component.setConstants(constants);
- component.setStructures(new ArrayList<Structure>());
+ component.setStructures(new Structures());
- List<Code> codes = generateArray(Code.class);
+ Codes codes = generateComposite(Codes.class, Code.class);
for (Code code : codes) {
processCode(code);
}
component.setCodes(codes);
- List<Library> libraries = generateArray(Library.class);
+ Libraries libraries = generateComposite(Libraries.class, Library.class);
for (Library library : libraries) {
processLibrary(library);
}
@@ -337,11 +337,11 @@
explorationData.setResult(result);
// explorationData.getMetaData().getAttachments().add(generateAttachment());
- List<ConstantValue> constantValues = generateArray(ConstantValue.class);
+ ConstantValues constantValues = generateComposite(ConstantValues.class, ConstantValue.class);
for (ConstantValue constantValue : constantValues) {
processConstantValue(constantValue);
}
- explorationData.setConstantValues(SimpleComposite.castList(constantValues));
+ explorationData.setConstantValues(constantValues);
}
1
0
r1309 - in trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web: pages tools
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:28:59 +0000 (Sat, 08 Mar 2008)
New Revision: 1309
Added:
trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/WebEntityVisitor.java
Modified:
trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java
trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDownload.java
Log:
Using visitors
Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-03-08 00:28:20 UTC (rev 1308)
+++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-03-08 00:28:59 UTC (rev 1309)
@@ -22,14 +22,7 @@
import org.codelutin.tapestry.beans.TreeNode;
-import fr.cemagref.simexplorer.is.entities.data.Code;
-import fr.cemagref.simexplorer.is.entities.data.Component;
-import fr.cemagref.simexplorer.is.entities.data.Constant;
-import fr.cemagref.simexplorer.is.entities.data.ConstantValue;
-import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication;
-import fr.cemagref.simexplorer.is.entities.data.ExplorationData;
-import fr.cemagref.simexplorer.is.entities.data.Library;
-import fr.cemagref.simexplorer.is.entities.data.Structure;
+import fr.cemagref.simexplorer.is.ui.web.tools.WebEntityVisitor;
/**
* The Class ElementDetail.
@@ -65,333 +58,310 @@
*/
public List<TreeNode> getNodes() {
List<TreeNode> nodes = new ArrayList<TreeNode>();
- // FIXME use visitors
- nodes.add(generateElement());
+ WebEntityVisitor webEntityVisitor = new WebEntityVisitor();
+ nodes.add(webEntityVisitor.treeNodeVisit(getElement()));
return nodes;
}
- /**
- * Generate element.
- *
- * @return the tree node
- */
- private TreeNode generateElement() {
- TreeNode node = null;
- if (getElement() instanceof ExplorationApplication) {
- node = generateExplorationApplication();
- }
- if (getElement() instanceof ExplorationData) {
- node = generateExplorationData((ExplorationData) getElement());
- }
- if (getElement() instanceof Component) {
- node = generateComponent((Component) getElement());
- }
- if (getElement() instanceof Library) {
- node = generateLibrary((Library) getElement());
- }
+// /**
+// * Generate header.
+// *
+// * @param caption the caption
+// *
+// * @return the string
+// */
+// private String generateHeader(String caption) {
+// StringBuilder sb = new StringBuilder();
+// sb.append("<b>");
+// sb.append(caption);
+// sb.append("</b>");
+// return sb.toString();
+// }
+//
+// /**
+// * Generate exploration application.
+// *
+// * @return the tree node
+// */
+// private TreeNode generateExplorationApplication() {
+// TreeNode node;
+// node = new TreeNode();
+//
+// node.setType(TreeNode.TYPE_FOLDER);
+//
+// node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.applicationexploration"),
+// getMetadata().getName(), getElement().getMetaData().getVersion().toString(), getElement()
+// .getMetaData(), true, "metadata", "export", "history", "delete"));
+//
+// List<TreeNode> children = new ArrayList<TreeNode>();
+// TreeNode node1 = new TreeNode();
+// node1.setType(TreeNode.TYPE_FOLDER);
+// node1.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.components"), "", ""));
+// node1.setChildren(generateComponents((ExplorationApplication) getElement()));
+// children.add(node1);
+//
+// TreeNode node2 = new TreeNode();
+// node2.setType(TreeNode.TYPE_FOLDER);
+// node2.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.explorations"), "", ""));
+// node2.setChildren(generateExplorations((ExplorationApplication) getElement()));
+// children.add(node2);
+//
+// node.setChildren(children);
+// return node;
+// }
+//
+// /**
+// * Generate explorations.
+// *
+// * @param explorationApplication the exploration application
+// *
+// * @return the list< tree node>
+// */
+// private List<TreeNode> generateExplorations(ExplorationApplication explorationApplication) {
+// List<TreeNode> res = new ArrayList<TreeNode>();
+// for (ExplorationData data : explorationApplication.getExplorations().getElements()) {
+// res.add(generateExplorationData(data));
+// }
+// return res;
+// }
+//
+// /**
+// * Generate exploration data.
+// *
+// * @param explorationData the exploration data
+// *
+// * @return the tree node
+// */
+// private TreeNode generateExplorationData(ExplorationData explorationData) {
+// TreeNode explorationDataNode = new TreeNode();
+// explorationDataNode.setType(TreeNode.TYPE_FOLDER);
+//
+// explorationDataNode.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.explorationdata"),
+// explorationData.getMetaData().getName(), explorationData.getMetaData().getVersion().toString(),
+// explorationData.getMetaData(), true, "metadata", "history", "delete"));
+//
+// List<TreeNode> children = new ArrayList<TreeNode>();
+//
+// children.add(generateResult(explorationData));
+//
+// TreeNode node1 = new TreeNode();
+// node1.setType(TreeNode.TYPE_FOLDER);
+// node1.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.values"),
+// generateHeader(getMessages().get("simexplorer.ui.web.type")), generateHeader(getMessages().get(
+// "simexplorer.ui.web.value"))));
+// node1.setChildren(generateValues(explorationData));
+// children.add(node1);
+//
+// explorationDataNode.setChildren(children);
+// return explorationDataNode;
+// }
+//
+// /**
+// * Generate values.
+// *
+// * @param explorationData the exploration data
+// *
+// * @return the list< tree node>
+// */
+// private List<TreeNode> generateValues(ExplorationData explorationData) {
+// List<ConstantValue> values = explorationData.getConstantValues().getElements();
+// List<TreeNode> res = new ArrayList<TreeNode>();
+// for (ConstantValue value : values) {
+// TreeNode node = new TreeNode();
+// node.setType(TreeNode.TYPE_DOCUMENT);
+// node.setColumns(generateStringArray(value.getConstant().getName(), value.getConstant().getType()
+// .getSimpleName(), value.getValue()));
+// res.add(node);
+// }
+//
+// return res;
+// }
+//
+// /**
+// * Generate result.
+// *
+// * @param explorationData the exploration data
+// *
+// * @return the tree node
+// */
+// private TreeNode generateResult(ExplorationData explorationData) {
+// TreeNode res = new TreeNode();
+// res.setType(TreeNode.TYPE_DOCUMENT);
+//
+// res.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.result"), "", "", explorationData
+// .getMetaData(), false, "export"));
+// return res;
+// }
+//
+// /**
+// * Generate components.
+// *
+// * @param explorationApplication the exploration application
+// *
+// * @return the list< tree node>
+// */
+// private List<TreeNode> generateComponents(ExplorationApplication explorationApplication) {
+// List<Component> components = explorationApplication.getComponents().getElements();
+// List<TreeNode> res = new ArrayList<TreeNode>();
+//
+// for (Component component : components) {
+// res.add(generateComponent(component));
+// }
+//
+// return res;
+// }
+//
+// /**
+// * Inits the node.
+// *
+// * @return the tree node
+// */
+// private TreeNode initNode() {
+// TreeNode node = new TreeNode();
+// node.setType(TreeNode.TYPE_FOLDER);
+// return node;
+// }
+//
+// /**
+// * Generate component.
+// *
+// * @param component the component
+// *
+// * @return the tree node
+// */
+// private TreeNode generateComponent(Component component) {
+// TreeNode componentNode = new TreeNode();
+// componentNode.setType(TreeNode.TYPE_FOLDER);
+//
+// componentNode.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.component"), component
+// .getMetaData().getName(), component.getMetaData().getVersion().toString(), component
+// .getMetaData(), true, "metadata", "history", "delete"));
+//
+// List<TreeNode> children = new ArrayList<TreeNode>();
+//
+// TreeNode node;
+//
+// node = initNode();
+// node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.constant"),
+// generateHeader(getMessages().get("simexplorer.ui.web.name")), generateHeader(getMessages().get(
+// "simexplorer.ui.web.type"))));
+// node.setChildren(generateConstants(component.getConstants()));
+//
+// children.add(node);
+// node = initNode();
+//
+// node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.structures"), "", ""));
+// node.setChildren(generateStructures(component.getStructures()));
+//
+// children.add(node);
+// node = initNode();
+//
+// node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.codes"), generateHeader(getMessages()
+// .get("simexplorer.ui.web.language")), generateHeader(getMessages().get("simexplorer.ui.web.code"))));
+// node.setChildren(generateCodes(component.getCodes()));
+//
+// children.add(node);
+// node = initNode();
+//
+// node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.libraries"), "", ""));
+// node.setChildren(generateLibraries(component));
+//
+// children.add(node);
+//
+// componentNode.setChildren(children);
+// return componentNode;
+// }
+//
+// /**
+// * Generate libraries.
+// *
+// * @param component the component
+// *
+// * @return the list< tree node>
+// */
+// private List<TreeNode> generateLibraries(Component component) {
+// List<Library> libraries = component.getLibraries();
+//
+// List<TreeNode> res = new ArrayList<TreeNode>();
+// for (Library library : libraries) {
+// TreeNode node = generateLibrary(library);
+//
+// res.add(node);
+// }
+// return res;
+// }
+//
+// /**
+// * Generate library.
+// *
+// * @param library the library
+// *
+// * @return the tree node
+// */
+// private TreeNode generateLibrary(Library library) {
+// TreeNode node = new TreeNode();
+// node.setType(TreeNode.TYPE_DOCUMENT);
+// node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.library"), library.getMetaData()
+// .getName(), library.getMetaData().getVersion().toString(), library.getMetaData(), true, "metadata",
+// "export"));
+// return node;
+// }
+//
+// /**
+// * Generate codes.
+// *
+// * @param codes the codes
+// *
+// * @return the list< tree node>
+// */
+// private List<TreeNode> generateCodes(List<Code> codes) {
+// List<TreeNode> res = new ArrayList<TreeNode>();
+// for (Code code : codes) {
+// TreeNode node = new TreeNode();
+// node.setType(TreeNode.TYPE_DOCUMENT);
+// node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.code"), code.getLanguage(), code
+// .getCode()));
+// res.add(node);
+// }
+// return res;
+// }
+//
+// /**
+// * Generate structures.
+// *
+// * @param structures the structures
+// *
+// * @return the list< tree node>
+// */
+// @SuppressWarnings("unused")
+// private List<TreeNode> generateStructures(List<Structure> structures) {
+// List<TreeNode> res = new ArrayList<TreeNode>();
+// for (Structure structure : structures) {
+// TreeNode node = new TreeNode();
+// node.setType(TreeNode.TYPE_DOCUMENT);
+// node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.structure"), "", ""));
+// res.add(node);
+// }
+// return res;
+// }
+//
+// /**
+// * Generate constants.
+// *
+// * @param constants the constants
+// *
+// * @return the list< tree node>
+// */
+// private List<TreeNode> generateConstants(List<Constant> constants) {
+// List<TreeNode> res = new ArrayList<TreeNode>();
+// for (Constant constant : constants) {
+// TreeNode node = new TreeNode();
+// node.setType(TreeNode.TYPE_DOCUMENT);
+// node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.constant"), constant.getName(),
+// constant.getType().getSimpleName()));
+// res.add(node);
+// }
+// return res;
+// }
- return node;
- }
-
- /**
- * Generate header.
- *
- * @param caption the caption
- *
- * @return the string
- */
- private String generateHeader(String caption) {
- StringBuilder sb = new StringBuilder();
- sb.append("<b>");
- sb.append(caption);
- sb.append("</b>");
- return sb.toString();
- }
-
- /**
- * Generate exploration application.
- *
- * @return the tree node
- */
- private TreeNode generateExplorationApplication() {
- TreeNode node;
- node = new TreeNode();
-
- node.setType(TreeNode.TYPE_FOLDER);
-
- node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.applicationexploration"),
- getMetadata().getName(), getElement().getMetaData().getVersion().toString(), getElement()
- .getMetaData(), true, "metadata", "export", "history", "delete"));
-
- List<TreeNode> children = new ArrayList<TreeNode>();
- TreeNode node1 = new TreeNode();
- node1.setType(TreeNode.TYPE_FOLDER);
- node1.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.components"), "", ""));
- node1.setChildren(generateComponents((ExplorationApplication) getElement()));
- children.add(node1);
-
- TreeNode node2 = new TreeNode();
- node2.setType(TreeNode.TYPE_FOLDER);
- node2.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.explorations"), "", ""));
- node2.setChildren(generateExplorations((ExplorationApplication) getElement()));
- children.add(node2);
-
- node.setChildren(children);
- return node;
- }
-
- /**
- * Generate explorations.
- *
- * @param explorationApplication the exploration application
- *
- * @return the list< tree node>
- */
- private List<TreeNode> generateExplorations(ExplorationApplication explorationApplication) {
- List<TreeNode> res = new ArrayList<TreeNode>();
- for (ExplorationData data : explorationApplication.getExplorations().getElements()) {
- res.add(generateExplorationData(data));
- }
- return res;
- }
-
- /**
- * Generate exploration data.
- *
- * @param explorationData the exploration data
- *
- * @return the tree node
- */
- private TreeNode generateExplorationData(ExplorationData explorationData) {
- TreeNode explorationDataNode = new TreeNode();
- explorationDataNode.setType(TreeNode.TYPE_FOLDER);
-
- explorationDataNode.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.explorationdata"),
- explorationData.getMetaData().getName(), explorationData.getMetaData().getVersion().toString(),
- explorationData.getMetaData(), true, "metadata", "history", "delete"));
-
- List<TreeNode> children = new ArrayList<TreeNode>();
-
- children.add(generateResult(explorationData));
-
- TreeNode node1 = new TreeNode();
- node1.setType(TreeNode.TYPE_FOLDER);
- node1.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.values"),
- generateHeader(getMessages().get("simexplorer.ui.web.type")), generateHeader(getMessages().get(
- "simexplorer.ui.web.value"))));
- node1.setChildren(generateValues(explorationData));
- children.add(node1);
-
- explorationDataNode.setChildren(children);
- return explorationDataNode;
- }
-
- /**
- * Generate values.
- *
- * @param explorationData the exploration data
- *
- * @return the list< tree node>
- */
- private List<TreeNode> generateValues(ExplorationData explorationData) {
- List<ConstantValue> values = explorationData.getConstantValues().getElements();
- List<TreeNode> res = new ArrayList<TreeNode>();
- for (ConstantValue value : values) {
- TreeNode node = new TreeNode();
- node.setType(TreeNode.TYPE_DOCUMENT);
- node.setColumns(generateStringArray(value.getConstant().getName(), value.getConstant().getType()
- .getSimpleName(), value.getValue()));
- res.add(node);
- }
-
- return res;
- }
-
- /**
- * Generate result.
- *
- * @param explorationData the exploration data
- *
- * @return the tree node
- */
- private TreeNode generateResult(ExplorationData explorationData) {
- TreeNode res = new TreeNode();
- res.setType(TreeNode.TYPE_DOCUMENT);
-
- res.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.result"), "", "", explorationData
- .getMetaData(), false, "export"));
- return res;
- }
-
- /**
- * Generate components.
- *
- * @param explorationApplication the exploration application
- *
- * @return the list< tree node>
- */
- private List<TreeNode> generateComponents(ExplorationApplication explorationApplication) {
- List<Component> components = explorationApplication.getComponents().getElements();
- List<TreeNode> res = new ArrayList<TreeNode>();
-
- for (Component component : components) {
- res.add(generateComponent(component));
- }
-
- return res;
- }
-
- /**
- * Inits the node.
- *
- * @return the tree node
- */
- private TreeNode initNode() {
- TreeNode node = new TreeNode();
- node.setType(TreeNode.TYPE_FOLDER);
- return node;
- }
-
- /**
- * Generate component.
- *
- * @param component the component
- *
- * @return the tree node
- */
- private TreeNode generateComponent(Component component) {
- TreeNode componentNode = new TreeNode();
- componentNode.setType(TreeNode.TYPE_FOLDER);
-
- componentNode.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.component"), component
- .getMetaData().getName(), component.getMetaData().getVersion().toString(), component
- .getMetaData(), true, "metadata", "history", "delete"));
-
- List<TreeNode> children = new ArrayList<TreeNode>();
-
- TreeNode node;
-
- node = initNode();
- node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.constant"),
- generateHeader(getMessages().get("simexplorer.ui.web.name")), generateHeader(getMessages().get(
- "simexplorer.ui.web.type"))));
- node.setChildren(generateConstants(component.getConstants()));
-
- children.add(node);
- node = initNode();
-
- node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.structures"), "", ""));
- node.setChildren(generateStructures(component.getStructures()));
-
- children.add(node);
- node = initNode();
-
- node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.codes"), generateHeader(getMessages()
- .get("simexplorer.ui.web.language")), generateHeader(getMessages().get("simexplorer.ui.web.code"))));
- node.setChildren(generateCodes(component.getCodes()));
-
- children.add(node);
- node = initNode();
-
- node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.libraries"), "", ""));
- node.setChildren(generateLibraries(component));
-
- children.add(node);
-
- componentNode.setChildren(children);
- return componentNode;
- }
-
- /**
- * Generate libraries.
- *
- * @param component the component
- *
- * @return the list< tree node>
- */
- private List<TreeNode> generateLibraries(Component component) {
- List<Library> libraries = component.getLibraries();
-
- List<TreeNode> res = new ArrayList<TreeNode>();
- for (Library library : libraries) {
- TreeNode node = generateLibrary(library);
-
- res.add(node);
- }
- return res;
- }
-
- /**
- * Generate library.
- *
- * @param library the library
- *
- * @return the tree node
- */
- private TreeNode generateLibrary(Library library) {
- TreeNode node = new TreeNode();
- node.setType(TreeNode.TYPE_DOCUMENT);
- node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.library"), library.getMetaData()
- .getName(), library.getMetaData().getVersion().toString(), library.getMetaData(), true, "metadata",
- "export"));
- return node;
- }
-
- /**
- * Generate codes.
- *
- * @param codes the codes
- *
- * @return the list< tree node>
- */
- private List<TreeNode> generateCodes(List<Code> codes) {
- List<TreeNode> res = new ArrayList<TreeNode>();
- for (Code code : codes) {
- TreeNode node = new TreeNode();
- node.setType(TreeNode.TYPE_DOCUMENT);
- node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.code"), code.getLanguage(), code
- .getCode()));
- res.add(node);
- }
- return res;
- }
-
- /**
- * Generate structures.
- *
- * @param structures the structures
- *
- * @return the list< tree node>
- */
- @SuppressWarnings("unused")
- private List<TreeNode> generateStructures(List<Structure> structures) {
- List<TreeNode> res = new ArrayList<TreeNode>();
- for (Structure structure : structures) {
- TreeNode node = new TreeNode();
- node.setType(TreeNode.TYPE_DOCUMENT);
- node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.structure"), "", ""));
- res.add(node);
- }
- return res;
- }
-
- /**
- * Generate constants.
- *
- * @param constants the constants
- *
- * @return the list< tree node>
- */
- private List<TreeNode> generateConstants(List<Constant> constants) {
- List<TreeNode> res = new ArrayList<TreeNode>();
- for (Constant constant : constants) {
- TreeNode node = new TreeNode();
- node.setType(TreeNode.TYPE_DOCUMENT);
- node.setColumns(generateStringArray(getMessages().get("simexplorer.ui.web.constant"), constant.getName(),
- constant.getType().getSimpleName()));
- res.add(node);
- }
- return res;
- }
-
}
Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDownload.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDownload.java 2008-03-08 00:28:20 UTC (rev 1308)
+++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDownload.java 2008-03-08 00:28:59 UTC (rev 1309)
@@ -26,15 +26,12 @@
import org.codelutin.tapestry.beans.TreeNode;
import fr.cemagref.simexplorer.is.entities.attachment.Attachment;
-import fr.cemagref.simexplorer.is.entities.data.Component;
-import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication;
-import fr.cemagref.simexplorer.is.entities.data.ExplorationData;
-import fr.cemagref.simexplorer.is.entities.data.Library;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import fr.cemagref.simexplorer.is.exceptions.SimExplorerException;
import fr.cemagref.simexplorer.is.service.remote.RemoteStorageService;
import fr.cemagref.simexplorer.is.ui.web.tools.AttachmentStreamResponse;
+import fr.cemagref.simexplorer.is.ui.web.tools.WebEntityVisitor;
import fr.cemagref.simexplorer.is.ui.web.tools.XMLAttachment;
import fr.cemagref.simexplorer.is.ui.web.tools.ZipAttachment;
@@ -141,207 +138,207 @@
*/
public List<TreeNode> getNodes() {
List<TreeNode> nodes = new ArrayList<TreeNode>();
- // FIXME use visitors
- nodes.add(generateNodes());
+ WebEntityVisitor webEntityVisitor = new WebEntityVisitor();
+ nodes.add(webEntityVisitor.treeNodeVisit(getElement()));
return nodes;
}
- /**
- * Generate nodes.
- *
- * @return the tree node
- */
- private TreeNode generateNodes() {
- TreeNode node = null;
- if (getElement() instanceof ExplorationApplication) {
- node = generateExplorationApplication();
- }
- if (getElement() instanceof ExplorationData) {
- node = generateExplorationData((ExplorationData) getElement());
- }
- if (getElement() instanceof Component) {
- node = generateComponent((Component) getElement());
- }
- if (getElement() instanceof Library) {
- node = generateLibrary((Library) getElement());
- }
- return node;
- }
+// /**
+// * Generate nodes.
+// *
+// * @return the tree node
+// */
+// private TreeNode generateNodes() {
+// TreeNode node = null;
+// if (getElement() instanceof ExplorationApplication) {
+// node = generateExplorationApplication();
+// }
+// if (getElement() instanceof ExplorationData) {
+// node = generateExplorationData((ExplorationData) getElement());
+// }
+// if (getElement() instanceof Component) {
+// node = generateComponent((Component) getElement());
+// }
+// if (getElement() instanceof Library) {
+// node = generateLibrary((Library) getElement());
+// }
+// return node;
+// }
+//
+// /**
+// * Generate exploration application.
+// *
+// * @return the tree node
+// */
+// private TreeNode generateExplorationApplication() {
+// TreeNode node;
+// node = new TreeNode();
+//
+// node.setType(TreeNode.TYPE_FOLDER);
+//
+// node.setColumns(generateStringArray("Application exploration", getMetadata().getName()));
+//
+// List<TreeNode> children = new ArrayList<TreeNode>();
+// TreeNode node1 = new TreeNode();
+// node1.setType(TreeNode.TYPE_FOLDER);
+// node1.setColumns(generateStringArray("Components"));
+// node1.setChildren(generateComponents((ExplorationApplication) getElement()));
+// children.add(node1);
+//
+// TreeNode node2 = new TreeNode();
+// node2.setType(TreeNode.TYPE_FOLDER);
+// node2.setColumns(generateStringArray("Explorations"));
+// node2.setChildren(generateExplorations((ExplorationApplication) getElement()));
+// children.add(node2);
+//
+// node.setChildren(children);
+// return node;
+// }
+//
+// /**
+// * Generate explorations.
+// *
+// * @param explorationApplication the exploration application
+// *
+// * @return the list< tree node>
+// */
+// private List<TreeNode> generateExplorations(ExplorationApplication explorationApplication) {
+// List<TreeNode> res = new ArrayList<TreeNode>();
+// for (ExplorationData explorationData : explorationApplication.getExplorations().getElements()) {
+// res.add(generateExplorationData(explorationData));
+// }
+// return res;
+// }
+//
+// /**
+// * Generate exploration data.
+// *
+// * @param explorationData the exploration data
+// *
+// * @return the tree node
+// */
+// private TreeNode generateExplorationData(ExplorationData explorationData) {
+// TreeNode explorationDataNode = new TreeNode();
+// explorationDataNode.setType(TreeNode.TYPE_FOLDER);
+//
+// explorationDataNode
+// .setColumns(generateStringArray("Exploration data", explorationData.getMetaData().getName()));
+//
+// List<TreeNode> children = new ArrayList<TreeNode>();
+//
+// List<Attachment> attachments = explorationData.getAttachments();
+//
+// for (Attachment attachment : attachments) {
+// children.add(generateDownload(explorationData, attachment));
+// }
+// explorationDataNode.setChildren(children);
+//
+// return explorationDataNode;
+// }
+//
+// /**
+// * Generate components.
+// *
+// * @param explorationApplication the exploration application
+// *
+// * @return the list< tree node>
+// */
+// private List<TreeNode> generateComponents(ExplorationApplication explorationApplication) {
+// List<Component> components = explorationApplication.getComponents().getElements();
+// List<TreeNode> res = new ArrayList<TreeNode>();
+//
+// for (Component component : components) {
+// res.add(generateComponent(component));
+// }
+//
+// return res;
+// }
+//
+// /**
+// * Generate component.
+// *
+// * @param component the component
+// *
+// * @return the tree node
+// */
+// private TreeNode generateComponent(Component component) {
+// TreeNode componentNode = new TreeNode();
+// componentNode.setType(TreeNode.TYPE_FOLDER);
+//
+// componentNode.setColumns(generateStringArray("Component", component.getMetaData().getName()));
+//
+// List<TreeNode> children = new ArrayList<TreeNode>();
+//
+// TreeNode node;
+//
+// node = new TreeNode();
+// node.setType(TreeNode.TYPE_FOLDER);
+//
+// node.setColumns(generateStringArray("Libraries"));
+// node.setChildren(generateLibraries(component.getLibraries()));
+//
+// children.add(node);
+//
+// componentNode.setChildren(children);
+// return componentNode;
+// }
+//
+// /**
+// * Generate libraries.
+// *
+// * @param libraries the libraries
+// *
+// * @return the list< tree node>
+// */
+// private List<TreeNode> generateLibraries(List<Library> libraries) {
+// List<TreeNode> res = new ArrayList<TreeNode>();
+// for (Library library : libraries) {
+// TreeNode node = generateLibrary(library);
+// res.add(node);
+// }
+// return res;
+// }
+//
+// /**
+// * Generate library.
+// *
+// * @param library the library
+// *
+// * @return the tree node
+// */
+// private TreeNode generateLibrary(Library library) {
+// TreeNode node = new TreeNode();
+// node.setType(TreeNode.TYPE_FOLDER);
+//
+// List<Attachment> attachments = library.getAttachments();
+// List<TreeNode> children = new ArrayList<TreeNode>();
+// for (Attachment attachment : attachments) {
+// children.add(generateDownload(library, attachment));
+// }
+// node.setChildren(children);
+//
+// node.setColumns(generateStringArray("Library", library.getMetaData().getName()));
+// return node;
+// }
+//
+// /**
+// * Generate download.
+// *
+// * @param explorationData the exploration data
+// * @param attachment the attachment
+// *
+// * @return the tree node
+// */
+// private TreeNode generateDownload(LoggableElement explorationData, Attachment attachment) {
+// TreeNode node = new TreeNode();
+// node.setType(TreeNode.TYPE_DOCUMENT);
+//
+// String context = explorationData.getMetaData().getUuid() + "," + explorationData.getMetaData().getVersion()
+// + "," + attachment.getUniqueId();
+//
+// node.setColumns(generateStringArray(attachment.getContentType().getDescription(), attachment.getDataHash(),
+// generateString(attachment.getFileName(), "downloadFile", context)));
+// return node;
+// }
- /**
- * Generate exploration application.
- *
- * @return the tree node
- */
- private TreeNode generateExplorationApplication() {
- TreeNode node;
- node = new TreeNode();
-
- node.setType(TreeNode.TYPE_FOLDER);
-
- node.setColumns(generateStringArray("Application exploration", getMetadata().getName()));
-
- List<TreeNode> children = new ArrayList<TreeNode>();
- TreeNode node1 = new TreeNode();
- node1.setType(TreeNode.TYPE_FOLDER);
- node1.setColumns(generateStringArray("Components"));
- node1.setChildren(generateComponents((ExplorationApplication) getElement()));
- children.add(node1);
-
- TreeNode node2 = new TreeNode();
- node2.setType(TreeNode.TYPE_FOLDER);
- node2.setColumns(generateStringArray("Explorations"));
- node2.setChildren(generateExplorations((ExplorationApplication) getElement()));
- children.add(node2);
-
- node.setChildren(children);
- return node;
- }
-
- /**
- * Generate explorations.
- *
- * @param explorationApplication the exploration application
- *
- * @return the list< tree node>
- */
- private List<TreeNode> generateExplorations(ExplorationApplication explorationApplication) {
- List<TreeNode> res = new ArrayList<TreeNode>();
- for (ExplorationData explorationData : explorationApplication.getExplorations().getElements()) {
- res.add(generateExplorationData(explorationData));
- }
- return res;
- }
-
- /**
- * Generate exploration data.
- *
- * @param explorationData the exploration data
- *
- * @return the tree node
- */
- private TreeNode generateExplorationData(ExplorationData explorationData) {
- TreeNode explorationDataNode = new TreeNode();
- explorationDataNode.setType(TreeNode.TYPE_FOLDER);
-
- explorationDataNode
- .setColumns(generateStringArray("Exploration data", explorationData.getMetaData().getName()));
-
- List<TreeNode> children = new ArrayList<TreeNode>();
-
- List<Attachment> attachments = explorationData.getAttachments();
-
- for (Attachment attachment : attachments) {
- children.add(generateDownload(explorationData, attachment));
- }
- explorationDataNode.setChildren(children);
-
- return explorationDataNode;
- }
-
- /**
- * Generate components.
- *
- * @param explorationApplication the exploration application
- *
- * @return the list< tree node>
- */
- private List<TreeNode> generateComponents(ExplorationApplication explorationApplication) {
- List<Component> components = explorationApplication.getComponents().getElements();
- List<TreeNode> res = new ArrayList<TreeNode>();
-
- for (Component component : components) {
- res.add(generateComponent(component));
- }
-
- return res;
- }
-
- /**
- * Generate component.
- *
- * @param component the component
- *
- * @return the tree node
- */
- private TreeNode generateComponent(Component component) {
- TreeNode componentNode = new TreeNode();
- componentNode.setType(TreeNode.TYPE_FOLDER);
-
- componentNode.setColumns(generateStringArray("Component", component.getMetaData().getName()));
-
- List<TreeNode> children = new ArrayList<TreeNode>();
-
- TreeNode node;
-
- node = new TreeNode();
- node.setType(TreeNode.TYPE_FOLDER);
-
- node.setColumns(generateStringArray("Libraries"));
- node.setChildren(generateLibraries(component.getLibraries()));
-
- children.add(node);
-
- componentNode.setChildren(children);
- return componentNode;
- }
-
- /**
- * Generate libraries.
- *
- * @param libraries the libraries
- *
- * @return the list< tree node>
- */
- private List<TreeNode> generateLibraries(List<Library> libraries) {
- List<TreeNode> res = new ArrayList<TreeNode>();
- for (Library library : libraries) {
- TreeNode node = generateLibrary(library);
- res.add(node);
- }
- return res;
- }
-
- /**
- * Generate library.
- *
- * @param library the library
- *
- * @return the tree node
- */
- private TreeNode generateLibrary(Library library) {
- TreeNode node = new TreeNode();
- node.setType(TreeNode.TYPE_FOLDER);
-
- List<Attachment> attachments = library.getAttachments();
- List<TreeNode> children = new ArrayList<TreeNode>();
- for (Attachment attachment : attachments) {
- children.add(generateDownload(library, attachment));
- }
- node.setChildren(children);
-
- node.setColumns(generateStringArray("Library", library.getMetaData().getName()));
- return node;
- }
-
- /**
- * Generate download.
- *
- * @param explorationData the exploration data
- * @param attachment the attachment
- *
- * @return the tree node
- */
- private TreeNode generateDownload(LoggableElement explorationData, Attachment attachment) {
- TreeNode node = new TreeNode();
- node.setType(TreeNode.TYPE_DOCUMENT);
-
- String context = explorationData.getMetaData().getUuid() + "," + explorationData.getMetaData().getVersion()
- + "," + attachment.getUniqueId();
-
- node.setColumns(generateStringArray(attachment.getContentType().getDescription(), attachment.getDataHash(),
- generateString(attachment.getFileName(), "downloadFile", context)));
- return node;
- }
-
}
Added: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/WebEntityVisitor.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/WebEntityVisitor.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/WebEntityVisitor.java 2008-03-08 00:28:59 UTC (rev 1309)
@@ -0,0 +1,47 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.ui.web.tools;
+
+import java.util.ArrayList;
+
+import org.codelutin.tapestry.beans.TreeNode;
+
+import fr.cemagref.simexplorer.is.entities.Entity;
+import fr.cemagref.simexplorer.is.entities.EntityVisitorTreeNode;
+
+public class WebEntityVisitor extends EntityVisitorTreeNode<TreeNode> {
+
+ protected TreeNode createNode(Entity v, boolean allowedChildren) {
+ TreeNode treeNode = new TreeNode();
+ treeNode.setChildren(new ArrayList<TreeNode>());
+
+ if (allowedChildren) {
+ treeNode.setType(TreeNode.TYPE_FOLDER);
+ } else {
+ treeNode.setType(TreeNode.TYPE_DOCUMENT);
+ }
+
+ treeNode.setColumns(new String[] { v.toString() });
+ if (getCurrentParent() != null) {
+ getCurrentParent().getChildren().add(treeNode);
+ }
+
+ return treeNode;
+ }
+
+}
1
0
r1308 - trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:28:20 +0000 (Sat, 08 Mar 2008)
New Revision: 1308
Modified:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/EntityTreeNodeHelper.java
Log:
Simplified
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/EntityTreeNodeHelper.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/EntityTreeNodeHelper.java 2008-03-08 00:27:50 UTC (rev 1307)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ui/EntityTreeNodeHelper.java 2008-03-08 00:28:20 UTC (rev 1308)
@@ -33,6 +33,7 @@
import fr.cemagref.simexplorer.is.entities.Entity;
import fr.cemagref.simexplorer.is.entities.EntityVisitable;
import fr.cemagref.simexplorer.is.entities.EntityVisitor;
+import fr.cemagref.simexplorer.is.entities.EntityVisitorTreeNode;
import fr.cemagref.simexplorer.is.entities.Leaf;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode;
@@ -48,14 +49,6 @@
protected static Log log = LogFactory.getLog(EntityTreeNodeHelper.class);
- /** L'instance cachée de builder par Thread. */
- protected static final ThreadLocal<EntityVisitorBuilder> builder = new ThreadLocal<EntityVisitorBuilder>() {
- @Override
- protected EntityVisitorBuilder initialValue() {
- return new EntityVisitorBuilder();
- }
- };
-
/**
* Construit un arbre de navigation à partir d'un {@link LoggableElement}.
*
@@ -64,14 +57,11 @@
* @return le noeud parent de l'arbre de nivation construit.
*/
public static EntityTreeNode build(LoggableElement v, boolean remote) {
- EntityVisitorBuilder instance;
- synchronized (instance = EntityTreeNodeHelper.builder.get()) {
- EntityTreeNode result;
- // walk
- result = instance.visit(v, remote);
- log.info(v + " (" + remote + ") ");
- return result;
- }
+ EntityVisitorBuilder instance = new EntityVisitorBuilder(remote);
+ // walk
+ EntityTreeNode result = instance.treeNodeVisit(v);
+ log.info(v + " (" + remote + ") ");
+ return result;
}
public static LoggableElement getSelectedLoggableElement(TreeSelectionEvent e) {
@@ -141,114 +131,130 @@
protected EntityTreeNodeHelper() {
// no instance
}
+
+ public static class EntityVisitorBuilder extends EntityVisitorTreeNode<EntityTreeNode> {
- /**
- * Implantation de {@link SimpleEntityVisitor} pour construire l'arbre de navigation d'un {@link LoggableElement}.
- * <p/> Cette classe est stateless, tous ces états internes doivent être nettoyé après une visite, en utilisant la
- * méthode {@link #reset()}. <p/>
- */
- public static class EntityVisitorBuilder implements EntityVisitor {
-
- /**
- * le noeud parent de tous les autres. <p/> Ce noeud est positionné par la méthode
- * {@link #markRootNode(EntityTreeNode)}.
- */
- protected EntityTreeNode rootNode;
+ private boolean remote;
- /** The node stack. */
- protected Deque<EntityTreeNode> nodeStack;
-
- /**
- * flag qui indique si on travaille sur des objet locaux ou distants. <p/> Cette information est conservé dans
- * les nodes pour permettre de gérer de manière transparent des objet locaux ou distants.
- */
- protected Boolean remote;
-
- /**
- * Visite un element visitable.
- *
- * @param v the v
- * @param remote the remote
- *
- * @return the entity tree node
- */
- public EntityTreeNode visit(EntityVisitable v, boolean remote) {
- reset();
- try {
- this.remote = remote;
- visit(v);
- EntityTreeNode result;
- result = this.rootNode;
- return result;
- } finally {
- reset();
- }
+ public EntityVisitorBuilder(boolean remote) {
+ super();
+ this.remote = remote;
}
@Override
- public void enterComposite(Composite v) {
- EntityTreeNode newNode;
- newNode = createNode(v, true);
- nodeStack.addFirst(newNode);
- markRootNode(newNode);
+ protected EntityTreeNode createNode(Entity v, boolean allowedChildren) {
+ return new EntityTreeNode(getCurrentParent(), v, remote, allowedChildren);
}
- /**
- * Creates the node.
- *
- * @param e the e
- * @param allowedChildren the allowed children
- *
- * @return the entity tree node
- */
- private EntityTreeNode createNode(Entity e, boolean allowedChildren) {
- EntityTreeNode newNode = new EntityTreeNode(nodeStack.peekFirst(), e, remote, allowedChildren);
- return newNode;
- }
+ }
- @Override
- public void exitComposite(Composite v) {
- nodeStack.removeFirst();
- }
-
- @Override
- public void visit(EntityVisitable v) {
- if (v != null) {
- // on lance la visite
- v.accept(this);
- }
- }
-
- @Override
- public void visitComposite(Composite v) {
- createNode(v, false);
- }
-
- @Override
- public void visitLeaf(Leaf v) {
- createNode(v, false);
- }
-
- /**
- * Tente de marquerle node donné comme noeud ancêtre de tous les autres. <p/> Le positionnement n'a lieu que si
- * on a pas encore de rootNode.
- *
- * @param node le node a positionner comme rootNode (si nessecaire)
- */
- protected void markRootNode(EntityTreeNode node) {
- if (rootNode == null) {
- rootNode = node;
- }
- }
-
- /**
- * La méthode pour réinitialiser les états interne de la classe. <p/> Cette méthode doit être appeler après
- * chaque visite, afin d'assurer la propriété stateless de la classe.
- */
- protected void reset() {
- nodeStack = new ArrayDeque<EntityTreeNode>();
- remote = null;
- }
-
- }
+// /**
+// * Implantation de {@link SimpleEntityVisitor} pour construire l'arbre de navigation d'un {@link LoggableElement}.
+// * <p/> Cette classe est stateless, tous ces états internes doivent être nettoyé après une visite, en utilisant la
+// * méthode {@link #reset()}. <p/>
+// */
+// public static class EntityVisitorBuilder implements EntityVisitor {
+//
+// /**
+// * le noeud parent de tous les autres. <p/> Ce noeud est positionné par la méthode
+// * {@link #markRootNode(EntityTreeNode)}.
+// */
+// protected EntityTreeNode rootNode;
+//
+// /** The node stack. */
+// protected Deque<EntityTreeNode> nodeStack;
+//
+// /**
+// * flag qui indique si on travaille sur des objet locaux ou distants. <p/> Cette information est conservé dans
+// * les nodes pour permettre de gérer de manière transparent des objet locaux ou distants.
+// */
+// protected Boolean remote;
+//
+// /**
+// * Visite un element visitable.
+// *
+// * @param v the v
+// * @param remote the remote
+// *
+// * @return the entity tree node
+// */
+// public EntityTreeNode visit(EntityVisitable v, boolean remote) {
+// reset();
+// try {
+// this.remote = remote;
+// visit(v);
+// EntityTreeNode result;
+// result = this.rootNode;
+// return result;
+// } finally {
+// reset();
+// }
+// }
+//
+// @Override
+// public void enterComposite(Composite v) {
+// EntityTreeNode newNode;
+// newNode = createNode(v, true);
+// nodeStack.addFirst(newNode);
+// markRootNode(newNode);
+// }
+//
+// /**
+// * Creates the node.
+// *
+// * @param e the e
+// * @param allowedChildren the allowed children
+// *
+// * @return the entity tree node
+// */
+// private EntityTreeNode createNode(Entity e, boolean allowedChildren) {
+// EntityTreeNode newNode = new EntityTreeNode(nodeStack.peekFirst(), e, remote, allowedChildren);
+// return newNode;
+// }
+//
+// @Override
+// public void exitComposite(Composite v) {
+// nodeStack.removeFirst();
+// }
+//
+// @Override
+// public void visit(EntityVisitable v) {
+// if (v != null) {
+// // on lance la visite
+// v.accept(this);
+// }
+// }
+//
+// @Override
+// public void visitComposite(Composite v) {
+// createNode(v, false);
+// }
+//
+// @Override
+// public void visitLeaf(Leaf v) {
+// createNode(v, false);
+// }
+//
+// /**
+// * Tente de marquerle node donné comme noeud ancêtre de tous les autres. <p/> Le positionnement n'a lieu que si
+// * on a pas encore de rootNode.
+// *
+// * @param node le node a positionner comme rootNode (si nessecaire)
+// */
+// protected void markRootNode(EntityTreeNode node) {
+// if (rootNode == null) {
+// rootNode = node;
+// }
+// }
+//
+// /**
+// * La méthode pour réinitialiser les états interne de la classe. <p/> Cette méthode doit être appeler après
+// * chaque visite, afin d'assurer la propriété stateless de la classe.
+// */
+// protected void reset() {
+// nodeStack = new ArrayDeque<EntityTreeNode>();
+// remote = null;
+// }
+//
+// }
}
1
0
r1307 - trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:27:50 +0000 (Sat, 08 Mar 2008)
New Revision: 1307
Modified:
trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java
trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceGenerator.java
Log:
Use List interface
Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java 2008-03-08 00:27:21 UTC (rev 1306)
+++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockDatabase.java 2008-03-08 00:27:50 UTC (rev 1307)
@@ -130,13 +130,13 @@
this.eas.put(uuid, eas);
registerLoggableElement(uuid, eas);
for (ExplorationApplication ea : eas) {
- for (Component component : ea.getComponents().getElements()) {
+ for (Component component : ea.getComponents()) {
registerLoggableElement(component.getMetaData().getUuid(), component);
for (Library library : component.getLibraries()) {
registerLoggableElement(library.getMetaData().getUuid(), library);
}
}
- for (ExplorationData explorationData : ea.getExplorations().getElements()) {
+ for (ExplorationData explorationData : ea.getExplorations()) {
registerLoggableElement(explorationData.getMetaData().getUuid(), explorationData);
}
}
Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceGenerator.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceGenerator.java 2008-03-08 00:27:21 UTC (rev 1306)
+++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceGenerator.java 2008-03-08 00:27:50 UTC (rev 1307)
@@ -123,7 +123,7 @@
ea.getMetaData().setVersion(secondVersion);
if (different) {
- Component component = ea.getComponents().getElements().iterator().next();
+ Component component = ea.getComponents().iterator().next();
Code code = new Code();
code.setCode("regreg");
code.setLanguage("regreg");
1
0
r1306 - trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:27:21 +0000 (Sat, 08 Mar 2008)
New Revision: 1306
Modified:
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Component.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationApplication.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationData.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Library.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/LoggableElement.java
Log:
Using composite types
Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Component.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Component.java 2008-03-08 00:27:01 UTC (rev 1305)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Component.java 2008-03-08 00:27:21 UTC (rev 1306)
@@ -17,12 +17,14 @@
* ##% */
package fr.cemagref.simexplorer.is.entities.data;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import fr.cemagref.simexplorer.is.entities.Entity;
-import fr.cemagref.simexplorer.is.entities.EntityVisitor;
+import fr.cemagref.simexplorer.is.entities.composite.Codes;
+import fr.cemagref.simexplorer.is.entities.composite.Constants;
+import fr.cemagref.simexplorer.is.entities.composite.Libraries;
+import fr.cemagref.simexplorer.is.entities.composite.Structures;
/**
* The Class Component.
@@ -33,23 +35,23 @@
private static final long serialVersionUID = -1759921918565071510L;
/** The constants. */
- List<Constant> constants;
+ Constants constants;
/** The structures. */
- List<Structure> structures;
+ Structures structures;
/** The codes. */
- List<Code> codes;
+ Codes codes;
/** The libraries. */
- List<Library> libraries;
+ Libraries libraries;
/**
* Gets the constants.
*
* @return the constants
*/
- public List<Constant> getConstants() {
+ public Constants getConstants() {
return constants;
}
@@ -58,7 +60,7 @@
*
* @param constants the new constants
*/
- public void setConstants(List<Constant> constants) {
+ public void setConstants(Constants constants) {
this.constants = constants;
}
@@ -67,7 +69,7 @@
*
* @return the structures
*/
- public List<Structure> getStructures() {
+ public Structures getStructures() {
return structures;
}
@@ -76,7 +78,7 @@
*
* @param structures the new structures
*/
- public void setStructures(List<Structure> structures) {
+ public void setStructures(Structures structures) {
this.structures = structures;
}
@@ -85,7 +87,7 @@
*
* @return the codes
*/
- public List<Code> getCodes() {
+ public Codes getCodes() {
return codes;
}
@@ -94,7 +96,7 @@
*
* @param codes the new codes
*/
- public void setCodes(List<Code> codes) {
+ public void setCodes(Codes codes) {
this.codes = codes;
}
@@ -103,7 +105,7 @@
*
* @return the libraries
*/
- public List<Library> getLibraries() {
+ public Libraries getLibraries() {
return libraries;
}
@@ -112,7 +114,7 @@
*
* @param libraries the new libraries
*/
- public void setLibraries(List<Library> libraries) {
+ public void setLibraries(Libraries libraries) {
this.libraries = libraries;
}
@@ -122,7 +124,10 @@
@Override
public List<Entity> getChildren() {
List<Entity> directChildren = new ArrayList<Entity>();
- directChildren.addAll(libraries);
+ directChildren.add(constants);
+ directChildren.add(structures);
+ directChildren.add(codes);
+ directChildren.add(libraries);
return directChildren;
}
Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationApplication.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationApplication.java 2008-03-08 00:27:01 UTC (rev 1305)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationApplication.java 2008-03-08 00:27:21 UTC (rev 1306)
@@ -22,7 +22,9 @@
import java.util.List;
import fr.cemagref.simexplorer.is.entities.Entity;
-import fr.cemagref.simexplorer.is.entities.SimpleComposite;
+import fr.cemagref.simexplorer.is.entities.composite.Components;
+import fr.cemagref.simexplorer.is.entities.composite.ExplorationDatas;
+import fr.cemagref.simexplorer.is.entities.composite.SimpleComposite;
/**
* The Class ExplorationApplication.
@@ -33,17 +35,17 @@
private static final long serialVersionUID = 122049347724394193L;
/** The explorations. */
- private SimpleComposite<ExplorationData> explorations;
+ private ExplorationDatas explorations;
/** The components. */
- private SimpleComposite<Component> components;
+ private Components components;
/**
* Gets the explorations.
*
* @return the explorations
*/
- public SimpleComposite<ExplorationData> getExplorations() {
+ public ExplorationDatas getExplorations() {
return explorations;
}
@@ -52,7 +54,7 @@
*
* @param explorations the new explorations
*/
- public void setExplorations(SimpleComposite<ExplorationData> explorations) {
+ public void setExplorations(ExplorationDatas explorations) {
this.explorations = explorations;
}
@@ -61,7 +63,7 @@
*
* @return the components
*/
- public SimpleComposite<Component> getComponents() {
+ public Components getComponents() {
return components;
}
@@ -70,7 +72,7 @@
*
* @param components the new components
*/
- public void setComponents(SimpleComposite<Component> components) {
+ public void setComponents(Components components) {
this.components = components;
}
Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationData.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationData.java 2008-03-08 00:27:01 UTC (rev 1305)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationData.java 2008-03-08 00:27:21 UTC (rev 1306)
@@ -22,7 +22,7 @@
import java.util.List;
import fr.cemagref.simexplorer.is.entities.Entity;
-import fr.cemagref.simexplorer.is.entities.SimpleComposite;
+import fr.cemagref.simexplorer.is.entities.composite.ConstantValues;
/**
* The Class ExplorationData.
@@ -33,7 +33,7 @@
private static final long serialVersionUID = -6439801837608358754L;
/** The values map. */
- private SimpleComposite<ConstantValue> constantValues;
+ private ConstantValues constantValues;
/** The result. */
private Result result;
@@ -46,7 +46,7 @@
* @return the constant value
*/
private ConstantValue findConstantValue(Constant c) {
- for (ConstantValue constantValue : constantValues.getElements()) {
+ for (ConstantValue constantValue : constantValues) {
if (c.equals(constantValue.getConstant())) {
return constantValue;
}
@@ -65,7 +65,7 @@
if (constantValue == null) {
constantValue = new ConstantValue();
constantValue.setConstant(c);
- constantValues.getElements().add(constantValue);
+ constantValues.add(constantValue);
}
constantValue.setValue(value);
}
@@ -108,7 +108,7 @@
*
* @return the values map
*/
- public SimpleComposite<ConstantValue> getConstantValues() {
+ public ConstantValues getConstantValues() {
return constantValues;
}
@@ -117,7 +117,7 @@
*
* @param constantValues the new values map
*/
- public void setConstantValues(SimpleComposite<ConstantValue> constantValues) {
+ public void setConstantValues(ConstantValues constantValues) {
this.constantValues = constantValues;
}
Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Library.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Library.java 2008-03-08 00:27:01 UTC (rev 1305)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Library.java 2008-03-08 00:27:21 UTC (rev 1306)
@@ -21,7 +21,6 @@
import java.util.List;
import fr.cemagref.simexplorer.is.entities.Entity;
-import fr.cemagref.simexplorer.is.entities.EntityVisitor;
/** The Class Library. */
public class Library extends LoggableElement {
@@ -59,7 +58,7 @@
@Override
public List<Entity> getChildren() {
List<Entity> children = new ArrayList<Entity>();
- children.addAll(getAttachments());
+ children.add(getAttachments());
return children;
}
Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/LoggableElement.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/LoggableElement.java 2008-03-08 00:27:01 UTC (rev 1305)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/LoggableElement.java 2008-03-08 00:27:21 UTC (rev 1306)
@@ -22,8 +22,10 @@
import fr.cemagref.simexplorer.is.entities.Composite;
import fr.cemagref.simexplorer.is.entities.Entity;
-import fr.cemagref.simexplorer.is.entities.EntityVisitor;
import fr.cemagref.simexplorer.is.entities.attachment.Attachment;
+import fr.cemagref.simexplorer.is.entities.composite.Attachments;
+import fr.cemagref.simexplorer.is.entities.composite.Descriptors;
+import fr.cemagref.simexplorer.is.entities.composite.SimpleComposite;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
/**
@@ -38,10 +40,10 @@
private String description;
/** The descriptors. */
- private List<Descriptor> descriptors;
+ private Descriptors descriptors;
/** The attachments. */
- private List<Attachment> attachments;
+ private Attachments attachments;
/** The metadata IS, managed only by SimExplorer-IS. */
private MetaData metadataIS;
@@ -57,7 +59,6 @@
return getName();
}
-
/**
* Gets all children of LoggableElement type.
*
@@ -74,7 +75,7 @@
getLEChildren(child, list);
}
}
-
+
/**
* Gets all children of LoggableElement type.
*
@@ -127,7 +128,7 @@
*
* @return the descriptors
*/
- public List<Descriptor> getDescriptors() {
+ public Descriptors getDescriptors() {
return descriptors;
}
@@ -136,7 +137,7 @@
*
* @param descriptors the descriptors to set
*/
- public void setDescriptors(List<Descriptor> descriptors) {
+ public void setDescriptors(Descriptors descriptors) {
this.descriptors = descriptors;
}
@@ -145,9 +146,9 @@
*
* @return the attachments
*/
- public List<Attachment> getAttachments() {
+ public Attachments getAttachments() {
if (attachments == null) {
- attachments = new ArrayList<Attachment>();
+ attachments = new Attachments();
}
return attachments;
}
@@ -190,7 +191,7 @@
*
* @param attachments the attachments to set
*/
- public void setAttachments(List<Attachment> attachments) {
+ public void setAttachments(Attachments attachments) {
this.attachments = attachments;
}
1
0
r1305 - in trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities: . composite
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:27:01 +0000 (Sat, 08 Mar 2008)
New Revision: 1305
Added:
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Attachments.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Codes.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Components.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/ConstantValues.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Constants.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Descriptors.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/ExplorationDatas.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Libraries.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/SimpleComposite.java
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Structures.java
Removed:
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/SimpleComposite.java
Log:
SimpleComposite is now abstract, allowing retrieving children class type
SimpleComposite implements List interface
Subclasses are final
See http://serdom.szn.pl/ser/2007/03/25/java-generics-instantiating-objects-of-…
Deleted: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/SimpleComposite.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/SimpleComposite.java 2008-03-08 00:25:39 UTC (rev 1304)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/SimpleComposite.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -1,119 +0,0 @@
-/*
-* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package fr.cemagref.simexplorer.is.entities;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The Class SimpleComposite.
- */
-public class SimpleComposite<E extends Entity> extends Composite {
-
- /** The Constant serialVersionUID. */
- private static final long serialVersionUID = -2085840703844194573L;
-
- /** The children. */
- private List<E> elements;
-
- /**
- * Cast list.
- *
- * @param list the list
- *
- * @return the simple composite< t>
- */
- public static <T extends Entity> SimpleComposite<T> castList(List<T> list) {
- SimpleComposite<T> result = new SimpleComposite<T>();
- result.setElements(list);
- return result;
- }
-
- /* (non-Javadoc)
- * @see fr.cemagref.simexplorer.is.entities.Composite#visitEnter(fr.cemagref.simexplorer.is.entities.EntityVisitor)
- */
- @Override
- protected boolean visitEnter(EntityVisitor v) {
- v.enterComposite(this);
- return true;
- }
-
- /* (non-Javadoc)
- * @see fr.cemagref.simexplorer.is.entities.Composite#visitLeave(fr.cemagref.simexplorer.is.entities.EntityVisitor)
- */
- @Override
- protected void visitLeave(EntityVisitor v) {
- v.exitComposite(this);
- }
-
- /* (non-Javadoc)
- * @see fr.cemagref.simexplorer.is.entities.Entity#getChildren()
- */
- @Override
- public List<Entity> getChildren() {
- List<Entity> entities = new ArrayList<Entity>();
- entities.addAll(elements);
- return entities;
- }
-
- /**
- * Gets the elements.
- *
- * @return the elements
- */
- public List<E> getElements() {
- return elements;
- }
-
- /**
- * Sets the elements.
- *
- * @param elements the new elements
- */
- public void setElements(List<E> elements) {
- this.elements = elements;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((elements == null) ? 0 : elements.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;
- final SimpleComposite other = (SimpleComposite) obj;
- if (elements == null) {
- if (other.elements != null)
- return false;
- } else if (!elements.equals(other.elements))
- return false;
- return true;
- }
-
-
-
-}
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Attachments.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Attachments.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Attachments.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,24 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import fr.cemagref.simexplorer.is.entities.attachment.Attachment;
+
+public final class Attachments extends SimpleComposite<Attachment> {
+
+}
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Codes.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Codes.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Codes.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,24 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import fr.cemagref.simexplorer.is.entities.data.Code;
+
+public final class Codes extends SimpleComposite<Code> {
+
+}
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Components.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Components.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Components.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,24 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import fr.cemagref.simexplorer.is.entities.data.Component;
+
+public final class Components extends SimpleComposite<Component> {
+
+}
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/ConstantValues.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/ConstantValues.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/ConstantValues.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,24 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import fr.cemagref.simexplorer.is.entities.data.ConstantValue;
+
+public final class ConstantValues extends SimpleComposite<ConstantValue> {
+
+}
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Constants.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Constants.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Constants.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,24 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import fr.cemagref.simexplorer.is.entities.data.Constant;
+
+public final class Constants extends SimpleComposite<Constant> {
+
+}
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Descriptors.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Descriptors.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Descriptors.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,24 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import fr.cemagref.simexplorer.is.entities.data.Descriptor;
+
+public final class Descriptors extends SimpleComposite<Descriptor> {
+
+}
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/ExplorationDatas.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/ExplorationDatas.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/ExplorationDatas.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,24 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import fr.cemagref.simexplorer.is.entities.data.ExplorationData;
+
+public final class ExplorationDatas extends SimpleComposite<ExplorationData> {
+
+}
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Libraries.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Libraries.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Libraries.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,24 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import fr.cemagref.simexplorer.is.entities.data.Library;
+
+public final class Libraries extends SimpleComposite<Library> {
+
+}
Copied: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/SimpleComposite.java (from rev 1303, trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/SimpleComposite.java)
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/SimpleComposite.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/SimpleComposite.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,241 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import fr.cemagref.simexplorer.is.entities.Composite;
+import fr.cemagref.simexplorer.is.entities.Entity;
+import fr.cemagref.simexplorer.is.entities.EntityTypeEnum;
+
+/**
+ * The Class SimpleComposite.
+ */
+public abstract class SimpleComposite<E extends Entity> extends Composite implements List<E> {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = -2085840703844194573L;
+
+ /** The children. */
+ private List<E> elements;
+
+ /**
+ * Instantiates a new simple composite.
+ */
+ public SimpleComposite() {
+ super();
+ this.elements = new ArrayList<E>();
+ }
+
+ /**
+ * Instantiates a new simple composite.
+ *
+ * @param elements the elements
+ */
+ public SimpleComposite(List<E> elements) {
+ super();
+ this.elements = elements;
+ }
+
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.entities.Entity#getChildren()
+ */
+ @Override
+ public List<Entity> getChildren() {
+ List<Entity> entities = new ArrayList<Entity>();
+ entities.addAll(elements);
+ return entities;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((elements == null) ? 0 : elements.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;
+ final SimpleComposite other = (SimpleComposite) obj;
+ if (elements == null) {
+ if (other.elements != null)
+ return false;
+ } else if (!elements.equals(other.elements))
+ return false;
+ return true;
+ }
+
+ public Class<E> getChildrenClass() {
+ Class<E> eClass = null;
+
+ Type type = getClass().getGenericSuperclass();
+ if (type instanceof ParameterizedType) {
+ ParameterizedType paramType = (ParameterizedType) type;
+ eClass = (Class<E>) paramType.getActualTypeArguments()[0];
+ return eClass;
+ }
+
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ Class<E> eClass = getChildrenClass();
+
+ if (eClass != null) {
+ EntityTypeEnum entityType = EntityTypeEnum.getEntityType(eClass);
+ if (entityType != null) {
+ return entityType.getLibelles();
+ }
+ }
+ return super.toString();
+ }
+
+ /**
+ * Delegate List methods
+ */
+
+ @Override
+ public boolean add(E e) {
+ return elements.add(e);
+ }
+
+ @Override
+ public void add(int index, E element) {
+ elements.add(index, element);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends E> c) {
+ return elements.addAll(c);
+ }
+
+ @Override
+ public boolean addAll(int index, Collection<? extends E> c) {
+ return elements.addAll(index, c);
+ }
+
+ @Override
+ public void clear() {
+ elements.clear();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return elements.contains(o);
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> c) {
+ return elements.containsAll(c);
+ }
+
+ @Override
+ public E get(int index) {
+ return elements.get(index);
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ return elements.indexOf(o);
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return elements.isEmpty();
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return elements.iterator();
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ return elements.lastIndexOf(o);
+ }
+
+ @Override
+ public ListIterator<E> listIterator() {
+ return elements.listIterator();
+ }
+
+ @Override
+ public ListIterator<E> listIterator(int index) {
+ return elements.listIterator(index);
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ return elements.remove(o);
+ }
+
+ @Override
+ public E remove(int index) {
+ return elements.remove(index);
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ return elements.removeAll(c);
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ return elements.retainAll(c);
+ }
+
+ @Override
+ public E set(int index, E element) {
+ return elements.set(index, element);
+ }
+
+ @Override
+ public int size() {
+ return elements.size();
+ }
+
+ @Override
+ public List<E> subList(int fromIndex, int toIndex) {
+ return elements.subList(fromIndex, toIndex);
+ }
+
+ @Override
+ public Object[] toArray() {
+ return elements.toArray();
+ }
+
+ @Override
+ public <T> T[] toArray(T[] a) {
+ return elements.toArray(a);
+ }
+
+}
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Structures.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Structures.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/composite/Structures.java 2008-03-08 00:27:01 UTC (rev 1305)
@@ -0,0 +1,24 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities.composite;
+
+import fr.cemagref.simexplorer.is.entities.data.Structure;
+
+public final class Structures extends SimpleComposite<Structure> {
+
+}
1
0
r1304 - trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities
by glandais@users.labs.libre-entreprise.org 08 Mar '08
by glandais@users.labs.libre-entreprise.org 08 Mar '08
08 Mar '08
Author: glandais
Date: 2008-03-08 00:25:39 +0000 (Sat, 08 Mar 2008)
New Revision: 1304
Added:
trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/EntityVisitorTreeNode.java
Log:
Share UI node build
Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/EntityVisitorTreeNode.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/EntityVisitorTreeNode.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/EntityVisitorTreeNode.java 2008-03-08 00:25:39 UTC (rev 1304)
@@ -0,0 +1,77 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.entities;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+
+public abstract class EntityVisitorTreeNode<TN extends Object> implements EntityVisitor {
+
+ protected abstract TN createNode(Entity v, boolean allowedChildren);
+
+ private TN rootNode;
+
+ /** The node stack. */
+ private Deque<TN> nodeStack;
+
+ public TN treeNodeVisit(LoggableElement v) {
+ nodeStack = new ArrayDeque<TN>();
+ visit(v);
+ return rootNode;
+ }
+
+ protected TN getCurrentParent() {
+ return nodeStack.peekFirst();
+ }
+
+ @Override
+ public void enterComposite(Composite v) {
+ TN newNode;
+ newNode = createNode(v, true);
+ if (rootNode == null) {
+ rootNode = newNode;
+ }
+ nodeStack.addFirst(newNode);
+ }
+
+ @Override
+ public void exitComposite(Composite v) {
+ nodeStack.removeFirst();
+ }
+
+ @Override
+ public void visit(EntityVisitable v) {
+ if (v != null) {
+ // on lance la visite
+ v.accept(this);
+ }
+ }
+
+ @Override
+ public void visitComposite(Composite v) {
+ createNode(v, true);
+ }
+
+ @Override
+ public void visitLeaf(Leaf v) {
+ createNode(v, false);
+ }
+
+}
1
0