diff --git a/ICE Build - Clean and Install.launch b/ICE Build - Clean and Install.launch index b263c8e2d..41b15973e 100644 --- a/ICE Build - Clean and Install.launch +++ b/ICE Build - Clean and Install.launch @@ -15,7 +15,7 @@ - + diff --git a/ICE Build - Initial Install.launch b/ICE Build - Initial Install.launch index a1742053a..2c7efda86 100644 --- a/ICE Build - Initial Install.launch +++ b/ICE Build - Initial Install.launch @@ -10,7 +10,7 @@ - + diff --git a/org.eclipse.ice.client.test/src/org/eclipse/ice/client/test/ClientTester.java b/org.eclipse.ice.client.test/src/org/eclipse/ice/client/test/ClientTester.java index 093268a62..e4fe13669 100644 --- a/org.eclipse.ice.client.test/src/org/eclipse/ice/client/test/ClientTester.java +++ b/org.eclipse.ice.client.test/src/org/eclipse/ice/client/test/ClientTester.java @@ -37,11 +37,9 @@ import org.eclipse.core.resources.IResourceVisitor; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourceAttributes; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.content.IContentDescription; import org.eclipse.core.runtime.jobs.ISchedulingRule; @@ -53,7 +51,6 @@ import org.eclipse.ice.iclient.uiwidgets.IFormWidget; import org.junit.Before; import org.junit.Test; -import org.omg.CORBA.ORB; /** * ClientTester checks the behavior and functionality of Client. It checks for diff --git a/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/MOOSEFormEditor.java b/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/MOOSEFormEditor.java index 3f2ecc2a8..9869a5288 100644 --- a/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/MOOSEFormEditor.java +++ b/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/MOOSEFormEditor.java @@ -63,6 +63,7 @@ import org.eclipse.ui.forms.widgets.Section; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; + import com.jme3.math.Vector3f; /** diff --git a/org.eclipse.ice.client.widgets.rcp.test/src/org/eclipse/ice/client/widgets/geometry/test/GeometryViewLauncher.java b/org.eclipse.ice.client.widgets.rcp.test/src/org/eclipse/ice/client/widgets/geometry/test/GeometryViewLauncher.java index da2ea527c..b1916fcd3 100644 --- a/org.eclipse.ice.client.widgets.rcp.test/src/org/eclipse/ice/client/widgets/geometry/test/GeometryViewLauncher.java +++ b/org.eclipse.ice.client.widgets.rcp.test/src/org/eclipse/ice/client/widgets/geometry/test/GeometryViewLauncher.java @@ -12,6 +12,7 @@ package org.eclipse.ice.client.widgets.geometry.test; import org.eclipse.ice.viz.service.jme3.application.MasterApplication; +import org.eclipse.ice.viz.service.jme3.application.ViewAppState; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; diff --git a/org.eclipse.ice.client.widgets.rcp.test/src/org/eclipse/ice/client/widgets/reactoreditor/plant/test/PlantViewLauncher.java b/org.eclipse.ice.client.widgets.rcp.test/src/org/eclipse/ice/client/widgets/reactoreditor/plant/test/PlantViewLauncher.java index ff36563a8..218784287 100644 --- a/org.eclipse.ice.client.widgets.rcp.test/src/org/eclipse/ice/client/widgets/reactoreditor/plant/test/PlantViewLauncher.java +++ b/org.eclipse.ice.client.widgets.rcp.test/src/org/eclipse/ice/client/widgets/reactoreditor/plant/test/PlantViewLauncher.java @@ -21,6 +21,7 @@ import org.eclipse.ice.reactor.plant.PlantComposite; import org.eclipse.ice.reactor.plant.Reactor; import org.eclipse.ice.viz.service.jme3.application.MasterApplication; +import org.eclipse.ice.viz.service.jme3.application.ViewAppState; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; diff --git a/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/jme/ViewFactory.java b/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/jme/ViewFactory.java index f0a5f79c5..4c5c8d82a 100644 --- a/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/jme/ViewFactory.java +++ b/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/jme/ViewFactory.java @@ -13,7 +13,6 @@ package org.eclipse.ice.client.widgets.jme; import org.eclipse.ice.client.widgets.reactoreditor.plant.PlantAppState; -import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.reactor.plant.PlantComposite; import org.eclipse.ice.viz.service.jme3.application.MasterApplication; import org.eclipse.ice.viz.service.jme3.application.ViewAppState; diff --git a/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/reactoreditor/plant/PipeController.java b/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/reactoreditor/plant/PipeController.java index 647d84d77..f868e0235 100644 --- a/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/reactoreditor/plant/PipeController.java +++ b/org.eclipse.ice.client.widgets.rcp/src/org/eclipse/ice/client/widgets/reactoreditor/plant/PipeController.java @@ -18,6 +18,7 @@ import org.eclipse.ice.datastructures.ICEObject.IUpdateable; import org.eclipse.ice.reactor.plant.Pipe; +import org.eclipse.ice.viz.service.geometry.shapes.Tube; import org.eclipse.ice.viz.service.jme3.application.IRenderQueue; import com.jme3.bounding.BoundingBox; diff --git a/org.eclipse.ice.client.widgets.reactoreditor.lwr/META-INF/MANIFEST.MF b/org.eclipse.ice.client.widgets.reactoreditor.lwr/META-INF/MANIFEST.MF index 176cc2c9b..0f713668f 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor.lwr/META-INF/MANIFEST.MF +++ b/org.eclipse.ice.client.widgets.reactoreditor.lwr/META-INF/MANIFEST.MF @@ -14,8 +14,8 @@ Require-Bundle: org.eclipse.gef;bundle-version="3.9.0", Import-Package: org.eclipse.core.runtime;version="3.4.0", org.eclipse.ice.analysistool, org.eclipse.ice.client.common, + org.eclipse.ice.client.widgets.analysis, org.eclipse.ice.client.widgets.jme, - org.eclipse.ice.client.widgets.reactoreditor, org.eclipse.ice.client.widgets.reactoreditor.grid, org.eclipse.ice.client.widgets.reactoreditor.plant, org.eclipse.ice.client.widgets.reactoreditor.properties, diff --git a/org.eclipse.ice.client.widgets.reactoreditor.lwr/src/org/eclipse/ice/client/widgets/reactoreditor/lwr/PlantAnalysisView.java b/org.eclipse.ice.client.widgets.reactoreditor.lwr/src/org/eclipse/ice/client/widgets/reactoreditor/lwr/PlantAnalysisView.java index 7a26cd694..31f3f4320 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor.lwr/src/org/eclipse/ice/client/widgets/reactoreditor/lwr/PlantAnalysisView.java +++ b/org.eclipse.ice.client.widgets.reactoreditor.lwr/src/org/eclipse/ice/client/widgets/reactoreditor/lwr/PlantAnalysisView.java @@ -18,7 +18,6 @@ import org.eclipse.ice.client.widgets.reactoreditor.DataSource; import org.eclipse.ice.client.widgets.reactoreditor.plant.PlantAppState; import org.eclipse.ice.reactor.plant.PlantComposite; -import org.eclipse.ice.viz.service.jme3.application.ViewAppState; import org.eclipse.jface.action.Action; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; diff --git a/org.eclipse.ice.client.widgets.reactoreditor.lwr/src/org/eclipse/ice/client/widgets/reactoreditor/lwr/PlotAnalysisView.java b/org.eclipse.ice.client.widgets.reactoreditor.lwr/src/org/eclipse/ice/client/widgets/reactoreditor/lwr/PlotAnalysisView.java index b65622751..11dde2064 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor.lwr/src/org/eclipse/ice/client/widgets/reactoreditor/lwr/PlotAnalysisView.java +++ b/org.eclipse.ice.client.widgets.reactoreditor.lwr/src/org/eclipse/ice/client/widgets/reactoreditor/lwr/PlotAnalysisView.java @@ -24,9 +24,9 @@ import org.eclipse.ice.analysistool.IDataProvider; import org.eclipse.ice.client.common.ActionTree; import org.eclipse.ice.client.widgets.reactoreditor.AnalysisView; -import org.eclipse.ice.client.widgets.reactoreditor.PaletteColorFactory; import org.eclipse.ice.client.widgets.reactoreditor.DataSource; import org.eclipse.ice.client.widgets.reactoreditor.IAnalysisView; +import org.eclipse.ice.client.widgets.reactoreditor.PaletteColorFactory; import org.eclipse.ice.client.widgets.reactoreditor.grid.Cell.State; import org.eclipse.ice.client.widgets.reactoreditor.grid.GridEditorInput; import org.eclipse.ice.reactor.AssemblyType; diff --git a/org.eclipse.ice.client.widgets.reactoreditor.sfr.test/src/org/eclipse/ice/client/widgets/reactoreditor/sfr/properties/test/PropertySourceFactoryTester.java b/org.eclipse.ice.client.widgets.reactoreditor.sfr.test/src/org/eclipse/ice/client/widgets/reactoreditor/sfr/properties/test/PropertySourceFactoryTester.java index 8864d5d19..6dc5b827d 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor.sfr.test/src/org/eclipse/ice/client/widgets/reactoreditor/sfr/properties/test/PropertySourceFactoryTester.java +++ b/org.eclipse.ice.client.widgets.reactoreditor.sfr.test/src/org/eclipse/ice/client/widgets/reactoreditor/sfr/properties/test/PropertySourceFactoryTester.java @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.List; -import org.eclipse.ice.client.widgets.reactoreditor.properties.SimpleProperty; +import org.eclipse.ice.client.widgets.analysis.properties.SimpleProperty; import org.eclipse.ice.client.widgets.reactoreditor.sfr.properties.PropertySourceFactory; import org.eclipse.ice.reactor.sfr.base.SFRComponent; import org.eclipse.ice.reactor.sfr.core.Material; diff --git a/org.eclipse.ice.client.widgets.reactoreditor.sfr/META-INF/MANIFEST.MF b/org.eclipse.ice.client.widgets.reactoreditor.sfr/META-INF/MANIFEST.MF index 2a12924e5..7807253d9 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor.sfr/META-INF/MANIFEST.MF +++ b/org.eclipse.ice.client.widgets.reactoreditor.sfr/META-INF/MANIFEST.MF @@ -7,7 +7,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Import-Package: org.eclipse.core.runtime;version="3.4.0", org.eclipse.ice.analysistool, org.eclipse.ice.client.common, - org.eclipse.ice.client.widgets.reactoreditor, + org.eclipse.ice.client.widgets.analysis, org.eclipse.ice.client.widgets.reactoreditor.grid, org.eclipse.ice.client.widgets.reactoreditor.properties, org.eclipse.ice.reactor.sfr.base, diff --git a/org.eclipse.ice.client.widgets.reactoreditor.test/src/org/eclipse/ice/client/widgets/reactoreditor/test/LinearColorFactoryTester.java b/org.eclipse.ice.client.widgets.reactoreditor.test/src/org/eclipse/ice/client/widgets/reactoreditor/test/LinearColorFactoryTester.java index 48ae5d2b5..35cbf5165 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor.test/src/org/eclipse/ice/client/widgets/reactoreditor/test/LinearColorFactoryTester.java +++ b/org.eclipse.ice.client.widgets.reactoreditor.test/src/org/eclipse/ice/client/widgets/reactoreditor/test/LinearColorFactoryTester.java @@ -11,7 +11,7 @@ *******************************************************************************/ package org.eclipse.ice.client.widgets.reactoreditor.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.List; diff --git a/org.eclipse.ice.client.widgets.reactoreditor.test/src/org/eclipse/ice/client/widgets/reactoreditor/test/PaletteColorFactoryTester.java b/org.eclipse.ice.client.widgets.reactoreditor.test/src/org/eclipse/ice/client/widgets/reactoreditor/test/PaletteColorFactoryTester.java index ce41e88fd..3c2644629 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor.test/src/org/eclipse/ice/client/widgets/reactoreditor/test/PaletteColorFactoryTester.java +++ b/org.eclipse.ice.client.widgets.reactoreditor.test/src/org/eclipse/ice/client/widgets/reactoreditor/test/PaletteColorFactoryTester.java @@ -11,7 +11,8 @@ *******************************************************************************/ package org.eclipse.ice.client.widgets.reactoreditor.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; import java.util.ArrayList; import java.util.List; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/.classpath b/org.eclipse.ice.client.widgets.reactoreditor/.classpath deleted file mode 100644 index ad32c83a7..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.client.widgets.reactoreditor/.gitignore b/org.eclipse.ice.client.widgets.reactoreditor/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.client.widgets.reactoreditor/.project b/org.eclipse.ice.client.widgets.reactoreditor/.project deleted file mode 100644 index eebc690ed..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - org.eclipse.ice.client.widgets.reactoreditor - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.client.widgets.reactoreditor/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.client.widgets.reactoreditor/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index a7f2ff1bb..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Mon Feb 04 07:56:18 EST 2013 -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/org.eclipse.ice.client.widgets.reactoreditor/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.client.widgets.reactoreditor/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 081d0c039..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Feb 04 07:56:18 EST 2013 -eclipse.preferences.version=1 -resolve.requirebundle=false -pluginProject.extensions=false diff --git a/org.eclipse.ice.client.widgets.reactoreditor/META-INF/MANIFEST.MF b/org.eclipse.ice.client.widgets.reactoreditor/META-INF/MANIFEST.MF deleted file mode 100644 index 4f79cefe8..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/META-INF/MANIFEST.MF +++ /dev/null @@ -1,34 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: ReactorEditor -Bundle-SymbolicName: org.eclipse.ice.client.widgets.reactoreditor;singleton:=true -Bundle-Version: 2.1.8 -Import-Package: org.eclipse.core.runtime;version="3.4.0", - org.eclipse.ice.client.common, - org.eclipse.ice.client.widgets, - org.eclipse.ice.iclient.uiwidgets, - org.eclipse.ice.io.hdf, - org.eclipse.ice.item, - org.eclipse.ice.reactor, - org.eclipse.ice.reactor.bwr, - org.eclipse.ice.reactor.pwr, - org.eclipse.ice.reactorAnalyzer, - org.eclipse.ice.viz.service.datastructures, - org.eclipse.ice.viz.service.mesh.datastructures, - org.eclipse.osgi.framework.console;version="1.0.0", - org.osgi.framework;version="1.3.0", - org.osgi.util.tracker;version="1.3.1", - org.slf4j;version="1.7.2" -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Service-Component: OSGI-INF/*.xml -Require-Bundle: org.eclipse.ice.client.compatibility;bundle-version="2.0.0", - org.eclipse.ice.analysistool;bundle-version="2.0.0", - org.eclipse.draw2d;bundle-version="3.9.0", - org.eclipse.gef;bundle-version="3.9.0", - org.eclipse.ice.datastructures, - org.eclipse.nebula.visualization.widgets;bundle-version="1.0.0", - org.eclipse.nebula.visualization.xygraph;bundle-version="1.0.0" -Export-Package: org.eclipse.ice.client.widgets.reactoreditor, - org.eclipse.ice.client.widgets.reactoreditor.properties -Bundle-ClassPath: . -Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.client.widgets.reactoreditor/OSGI-INF/AnalysisWidgetRegistry.xml b/org.eclipse.ice.client.widgets.reactoreditor/OSGI-INF/AnalysisWidgetRegistry.xml deleted file mode 100644 index 697d53b88..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/OSGI-INF/AnalysisWidgetRegistry.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/org.eclipse.ice.client.widgets.reactoreditor/OSGI-INF/ReactorEditorComponent.xml b/org.eclipse.ice.client.widgets.reactoreditor/OSGI-INF/ReactorEditorComponent.xml deleted file mode 100644 index 7dd00db91..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/OSGI-INF/ReactorEditorComponent.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/org.eclipse.ice.client.widgets.reactoreditor/about.html b/org.eclipse.ice.client.widgets.reactoreditor/about.html deleted file mode 100644 index c258ef55d..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

June 5, 2006

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/org.eclipse.ice.client.widgets.reactoreditor/build.properties b/org.eclipse.ice.client.widgets.reactoreditor/build.properties deleted file mode 100644 index ff2afb3f0..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/build.properties +++ /dev/null @@ -1,9 +0,0 @@ -bin.includes = META-INF/,\ - build.properties,\ - .,\ - pom.xml,\ - schema/,\ - plugin.xml,\ - OSGI-INF/ -output.. = bin/ -source.. = src/ diff --git a/org.eclipse.ice.client.widgets.reactoreditor/plugin.xml b/org.eclipse.ice.client.widgets.reactoreditor/plugin.xml deleted file mode 100644 index 84943bad0..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/plugin.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/org.eclipse.ice.client.widgets.reactoreditor/pom.xml b/org.eclipse.ice.client.widgets.reactoreditor/pom.xml deleted file mode 100644 index 908a8729c..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.client.widgets.reactoreditor - eclipse-plugin - \ No newline at end of file diff --git a/org.eclipse.ice.client.widgets.reactoreditor/schema/org.eclipse.ice.client.widgets.reactoreditor.ireactoreditorregistry.exsd b/org.eclipse.ice.client.widgets.reactoreditor/schema/org.eclipse.ice.client.widgets.reactoreditor.ireactoreditorregistry.exsd deleted file mode 100644 index 4d70c2ac9..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/schema/org.eclipse.ice.client.widgets.reactoreditor.ireactoreditorregistry.exsd +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisDataReader.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisDataReader.java deleted file mode 100644 index d09ea45cb..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisDataReader.java +++ /dev/null @@ -1,368 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class should read in data into data structures used by the - * ReactorEditor. Ideally, the files read in by this class should be - * standardized in some way. This class should read the files into a array (an - * "assembly") of data providers. - * - * @author Jordan H. Deyton - * - */ -public class AnalysisDataReader { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(AnalysisDataReader.class); - - // NOTES - // 1) Currently, we have a Map of supported features. The map tells us if - // we need to look for axial levels. - // 2) readFeature expects the data to be in order from lowest-indexed to - // highest in all cases. Axial data ordering may prove a problem if we - // need to handle disordered feature data. - // 3) Reading in the data should probably be handled by the specific - // strategy that output the file in the first place. - - // FIXME - We may want to move this to the lwr package. - - /** - * A map of features supported by this reader and whether or not they use - * axial levels. - */ - private Map supportedFeatures; - /** - * The arrays of data providers. The first index is the assembly, and the - * second is the rod data provider. - */ - private List> fuelAssemblies; - /** - * The number of rows in each assembly. - */ - private int assemblyRows; - /** - * The number of columns in each assembly. - */ - private int assemblyCols; - /** - * The number of axial levels for data that uses axial levels. - */ - private int axialLevels; - - /** - * This is used to check the lines of input that contain the data. Since it - * is required in a few methods, we make it an instance variable. - */ - private String dataRowRegex; - - /** - * The default constructor. Standard procedure requires a call to readData() - * to actually read in the data. - */ - public AnalysisDataReader() { - // Build the currently supported features (computed by the - // GodfreyStrategy). - supportedFeatures = new HashMap(4); - supportedFeatures.put("Fuel Pin Difference", true); - supportedFeatures.put("Fuel Pin Powers Uncertainties", true); - supportedFeatures.put("Radial Power", false); - supportedFeatures.put("Radial Power Difference", false); - } - - /** - * Reads in data from a provided file. Data will be stored within this - * instance and should be queried through other functions. - * - * @param uri - * The URI of the data file to read from. - */ - public void readData(URI uri) { - - // Get a File object from the URI and get its name. - File file = new File(uri.getPath()); - String fileName = file.getName(); - - // Make sure the file exists. - if (!file.exists()) { - System.err.println("Invalid file " + fileName + ". Cannot read data."); - return; - } - - // Read in the data. - try { - // Create a BufferedReader from the file. - BufferedReader reader = new BufferedReader(new InputStreamReader( - new FileInputStream(file))); - - // Get the number of assemblies. - int assemblies = Integer.parseInt(reader.readLine().split(":")[1] - .trim()); - // Get the number of axial levels. - axialLevels = Integer.parseInt(reader.readLine().split(":")[1] - .trim()); - // Get the number of rows in each assembly. - assemblyRows = Integer.parseInt(reader.readLine().split(":")[1] - .trim()); - // Get the number of columns in each assembly. - assemblyCols = Integer.parseInt(reader.readLine().split(":")[1] - .trim()); - - // Set up the regular expressions used to check the lines of data. - // dlbRegex is the regular expression for a double with the logic: - // 1-or-more digits, maybe followed by a period and - // 1-or-more-digits. - String dblRegex = "-?\\d+(\\.\\d+)?"; - // dataRowRegex makes sure that the number of doubles on a line is - // exactly the same as the number of columns in an assembly. The - // logic here is: - // Start of line (^), 0-or-more whitespace (\\s*), a double followed - // by 1-or-more whitespace (dblRegex + \\s+) exactly assemblyCols-1 - // times ({assemblyCols - 1}), a double (dblRegex), 0-or-more - // whitespace (\\s*), end of line ($). - dataRowRegex = "^\\s*(" + dblRegex + "\\s+){" + (assemblyCols - 1) - + "}" + dblRegex + "\\s*$"; - - // Initialize the array of fuel assemblies. - fuelAssemblies = new ArrayList>(assemblies); - - // Each fuel assembly is an array of rod data providers. - List fuelAssembly; - - // Build the array of fuel assemblies. - for (int i = 0; i < assemblies; i++) { - fuelAssembly = new ArrayList(); - for (int j = 0; j < assemblyRows * assemblyCols; j++) { - fuelAssembly.add(new LWRDataProvider()); - } - fuelAssemblies.add(fuelAssembly); - } - - // Read in the data file one feature at a time. - String feature; - while ((feature = nextLine(reader)) != null) { - if (supportedFeatures.containsKey(feature)) { - readFeature(reader, feature, supportedFeatures.get(feature)); - } - // If the line does not match any feature, this should just read - // the next line until a feature is read. - } - - // Close the reader. - reader.close(); - } catch (IOException e) { - // Handle IOExceptions. - System.err.println("IOException while reading " + fileName - + ". Cannot read data."); - logger.error(getClass().getName() + " Exception!",e); - } catch (NumberFormatException e) { - // Handle NumberFormatExceptions. These are thrown when dataRowRegex - // is not matched. - System.err.println("NumberFormatException while reading " + fileName - + ". Invalid number."); - logger.error(getClass().getName() + " Exception!",e); - } - ; - } - - /** - * Get the number of rows in each assembly. - * - * @return The number of rows in each assembly. - */ - public int getAssemblyRows() { - return assemblyRows; - } - - /** - * Get the number of columns in each assembly. - * - * @return The number of columns in each assembly. - */ - public int getAssemblyColumns() { - return assemblyCols; - } - - /** - * Get the number of axial levels used for the assembly data. - * - * @return The number of axial levels used for the assembly data. - */ - public int getAxialLevels() { - return axialLevels; - } - - /** - * Get the number of assemblies read in from the provided data. - * - * @return Returns the number of assemblies read in or 0 if no data has been - * read in. - */ - public int getNumberOfAssemblies() { - int count = 0; - if (fuelAssemblies != null) { - count = fuelAssemblies.size(); - } - return count; - } - - /** - * Get an array of LWRDataProviders for a particular fuel assembly. Each - * LWRDataProvider provides data for a single rod and multiple features. - * - * @param assembly - * The index of the assembly. - * @return An ArrayList of LWRDataProviders, or null if assembly is an - * invalid index or the data has not been read in. - */ - public List getAssemblyDataProviders(int assembly) { - List fuelAssembly = null; - if ((fuelAssemblies != null) && (assembly >= 0) - && (assembly < fuelAssemblies.size())) { - fuelAssembly = fuelAssemblies.get(assembly); - } - return fuelAssembly; - } - - /** - * This function gets the next non-empty line from a BufferedReader. Empty - * lines may include whitespace. - * - * @param reader - * The BufferedReader from which to read. - * @return The next non-empty line or null (if reader.readLine() == null). - * @throws IOException - * IOExceptions from reading need to be handled by the caller. - */ - private String nextLine(BufferedReader reader) throws IOException { - String line = null; - while ((line = reader.readLine()) != null) { - // If the line is not empty, break from the loop. - if (!(line.trim().isEmpty())) { - break; - } - } - return line; - } - - /** - * Gets the next non-empty line of text from the reader if it matches it - * with a regular expression. - * - * @param reader - * The BufferedReader from which to read. - * @param expected - * The regular expression to match against. - * @return Returns the next line from the reader if it matches with the - * regular expression. - * @throws IOException - * Throws an IOException either from reading or if the pattern - * is not matched. - */ - private String nextLine(BufferedReader reader, String expected) - throws IOException { - String line = null; - while ((line = reader.readLine()) != null) { - // If the line is not empty, break from the loop. - if (!(line.trim().isEmpty())) { - break; - } - } - // Compare the line against the regular expression. - if (!line.matches(expected)) { - System.err.println("Expected string of form \"" + expected - + "\" but got \"" + line + "\""); - throw new IOException(); - } - return line; - } - - /** - * Reads in a feature from the text file. This means grabbing data for each - * rod in each assembly at all possible axial levels. - * - * @param reader - * The BufferedReader used to read the file. - * @param feature - * The feature to read in. - * @param useAxialLevels - * Whether or not to look for axial levels in the data. - * @throws IOException - * The caller needs to handle reading IO exceptions. - * @throws NumberFormatException - * The caller needs to handle invalid doubles. - */ - private void readFeature(BufferedReader reader, String feature, - boolean useAxialLevels) throws IOException, NumberFormatException { - - // Try to read in the feature data for each fuel assembly. - for (int assembly = 0; assembly < fuelAssemblies.size(); assembly++) { - // Expected "Assembly #" - String line = nextLine(reader, "^Assembly\\s" + assembly + "\\s*$"); - - // Get the current fuel assembly. - List fuelAssembly = fuelAssemblies.get(assembly); - - // See if we need to iterate over axial levels. - int iterations = 1; - if (useAxialLevels) { - iterations = axialLevels; - } - - // Loop over the axial levels (if applicable). - for (int i = 0; i < iterations; i++) { - // Expected "Axial Level #" (if axial levels are used with this - // feature). - if (useAxialLevels) { - line = nextLine(reader, "^Axial Level\\s" + i + "\\s*$"); - } - // Loop over the rows of the assembly data. Each line at this - // point should be lines of doubles matching the dataRowRegex. - for (int row = 0; row < assemblyRows; row++) { - line = nextLine(reader, dataRowRegex); - // Expected assemblyCols numbers. - String[] splitLine = line.trim().split("\\s+"); - - // Loop over each value in the row. - for (int col = 0; col < assemblyCols; col++) { - // Store the feature/value pair in the data provider. - LWRData data = new LWRData(feature); - data.setValue(Double.parseDouble(splitLine[col])); - fuelAssembly.get(row * assemblyCols + col).addData( - data, 0); - } - } - } - } - } - -} diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IReactorEditorRegistry.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IReactorEditorRegistry.java deleted file mode 100644 index e66feb917..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IReactorEditorRegistry.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; - -/** - * An IReactorEditorRegistry maintains a group of {@link ReactorFormEditor}s. - * Implementations may expand the behavior to include additional features like - * setting the {@link ReactorFormInput} for one of the editors. - * - * @author Jordan - * - */ -public interface IReactorEditorRegistry { - - /** - * Adds a {@link ReactorFormEditor} to the registry with the specified ID. - * The ID is the same as the associated Item or Form. - * - * @param editor - * The ReactorFormEditor that has been created. - * @param id - * The ID of the editor. This should be the same as its - * associated Item or Form. - */ - public void addReactorEditor(ReactorFormEditor editor, int id); - - /** - * Removes a {@link ReactorFormEditor} from the registry. - * - * @param id - * The ID of the editor. This should be the same as its - * associated Item or Form. - */ - public void removeReactorEditor(int id); - -} diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorEclipseFormWidget.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorEclipseFormWidget.java deleted file mode 100644 index 38e8eb5e2..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorEclipseFormWidget.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; - -import org.eclipse.ice.client.widgets.EclipseFormWidget; -import org.eclipse.ice.client.widgets.ICEFormEditor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -/** - * This class extends the EclipseFormWidget and opens the ReactorFormEditor - * instead of the ICEFormEditor. - * - * @author Jay Jay Billings - * - */ -public class ReactorEclipseFormWidget extends EclipseFormWidget { - - /** - * The current registry used to generate analysis widgets for customized - * analysis views. - */ - private final IAnalysisWidgetRegistry widgetRegistry; - - /** - * The current registry of ReactorFormEditors. - */ - private final IReactorEditorRegistry editorRegistry; - - /** - * The default constructor. - * - * @param widgetRegistry - * The {@link IAnalysisWidgetRegistry} used to pull tailored - * analysis views. - * @param editorRegistry - * The {@link IReactorEditorRegistry} used to store references to - * open reactor editors. - */ - public ReactorEclipseFormWidget(IAnalysisWidgetRegistry widgetRegistry, - IReactorEditorRegistry editorRegistry) { - - // Set the registry. - this.widgetRegistry = widgetRegistry; - this.editorRegistry = editorRegistry; - - return; - } - - /** - * This operation displays the ReactorFormEditor. - */ - @Override - public void display() { - - // Local Declarations - IWorkbenchPage page = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - - // If the Form has been set, load the widget - if (widgetForm != null) { - - // Setup the Input. We need to pass the registry to the - // ReactorFormEditor through the input. - ReactorFormInputFactory factory = new ReactorFormInputFactory(); - ICEFormInput = factory.createInput(widgetForm, widgetRegistry); - - // Open the page - try { - IEditorPart formEditor = page.openEditor(ICEFormInput, - ReactorFormEditor.ID); - // Set this editor reference so that listeners can be registered - // later. - ICEFormEditor = (ICEFormEditor) formEditor; - - // Add the ReactorFormEditor to the registry. - editorRegistry.addReactorEditor((ReactorFormEditor) formEditor, - ICEFormInput.getForm().getId()); - - } catch (PartInitException e) { - // Dump the stacktrace if something happens. - logger.error(getClass().getName() + " Exception!",e); - } - - } - - return; - } - -} diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormEditor.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormEditor.java deleted file mode 100644 index 53b44a002..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormEditor.java +++ /dev/null @@ -1,328 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ice.client.widgets.ICEFormEditor; -import org.eclipse.ice.client.widgets.ICEFormPage; -import org.eclipse.ice.client.widgets.ICEMasterDetailsPage; -import org.eclipse.ice.client.widgets.ICEResourcePage; -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.form.MasterDetailsComponent; -import org.eclipse.ice.datastructures.form.ResourceComponent; -import org.eclipse.ice.reactorAnalyzer.ReactorAnalyzer; -import org.eclipse.ice.reactorAnalyzer.ReactorComposite; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.forms.IFormPart; -import org.eclipse.ui.forms.IManagedForm; - -/** - * This class extends the default ICEFormEditor to enable it to draw data from - * the ReactorAnalyzer better. - * - * @author Jay Jay Billings - * - */ -public class ReactorFormEditor extends ICEFormEditor { - - /** - * ID for Eclipse - */ - public static final String ID = "org.eclipse.ice.client.widgets.reactor.editor"; - - /** - * The ReactorPage displayed by this ReactorFormEditor. There is only one - * AnalysisToolComposite for displaying reactor information. - */ - private ReactorPage reactorPage; - - /** - * The input to this form editor. It contains useful information, like the - * {@link IAnalysisWidgetRegistry} used to generate {@link IAnalysisView}s. - */ - private ReactorFormInput input; - - /** - * This operation overrides init so that the ICE Form, passed as an - * IEditorInput, can be stored. Furthermore, it gathers any input that is - * specifically associated with a ReactorFormEditor. - */ - @Override - public void init(IEditorSite site, IEditorInput input) { - - // Check the input. We *must* have a ReactorFormInput. - if (!(input instanceof ReactorFormInput)) { - throw new RuntimeException( - "Input passed to ReactorFormEditor.init()" - + " is not of type ReactorFormInput."); - } - // Store a reference to the form input. - this.input = (ReactorFormInput) input; - - // Continue with the super-class' init() behavior. - super.init(site, input); - - // Register with the Form shared with the ReactorAnalyzer Item. This is - // so we can receive notifications when new components are added. - iceDataForm.register(this); - - return; - } - - /** - * This operation overrides the default drawing routines of ICE's Form - * Editor to load the custom analysis widgets for nuclear reactors. - */ - @Override - protected void addPages() { - - // Local Declaration - ArrayList formPages = new ArrayList(); - ResourceComponent resourceComponent; - ArrayList components; - - // Loop over the DataComponents and get them into the map - for (Component i : iceDataForm.getComponents()) { - logger.info("ReactorFormEditor Message: " - + "Adding component " + i.getName() + " " + i.getId()); - i.accept(this); - } - - // ---- Create the ReactorPage. ---- // - - // Get the reactor Components. If the IReactorEditor initialized - // properly, there should be an input and reference reactor component. - components = componentMap.get("reactor"); - if (!(components.isEmpty())) { - // Get the ReactorComposite. It should be the only IReactorComponent - // held by the form. - ReactorComposite reactorComposite = (ReactorComposite) components - .get(0); - - // Create the SelectionProvider used to feed the current selection - // from all the AnalysisViews to the Editor's IWorkbenchPartSite. - // FIXME - I'm not sure how this will work with multiple reactor - // editors open! - SelectionProvider provider = new SelectionProvider(); - getSite().setSelectionProvider(provider); - - // Create the page itself. - reactorPage = new ReactorPage(this, "Reactor", "Reactor Page"); - - // Set the registry, broker, selection provider, and reactor - // composite for the ReactorPage. - reactorPage.setAnalysisWidgetRegistry(input.getRegistry()); - reactorPage.setStateBroker(input.getStateBroker()); - reactorPage.setSelectionProvider(provider); - reactorPage.setReactorComposite(reactorComposite); - - // Add the resource component for comparison data. - reactorPage.addComponent((componentMap - .get("output").get(0))); - - // Add the data Components (input and reference loaders) to the - // first page only. - components = componentMap.get("data"); - if (!(components.isEmpty())) { - // Add the data Components to the page. - for (Component comp : components) { - reactorPage.addComponent(comp); - } - } - // Add the ReactorPages to the Editor's FormPages. - formPages.add(reactorPage); - } else { - logger.info("ReactorFormEditor Message: " - + "No IReactorEditor present. IReactorComponents will not " - + "be rendered."); - } - /* ---------------------------------- */ - - /* ---- Create the Analysis Configuration page. ---- */ - // This page allows the user to configure KDD strategies and run them. - - // Create pages for the MasterDetailsComponents - if (!(componentMap.get("masterDetails").isEmpty())) { - // Local Declarations - MasterDetailsComponent masterDetailsComponent = null; - - // Get the MasterDetailsComponent and create the MasterDetails page. - if (!(componentMap.get("masterDetails").isEmpty())) { - masterDetailsComponent = (MasterDetailsComponent) (componentMap - .get("masterDetails").get(0)); - if (masterDetailsComponent != null) { - // Get the name - String name = masterDetailsComponent.getName(); - // Make the page - ICEMasterDetailsPage iCEMasterDetailsPage = new ICEMasterDetailsPage( - this, "MDPid", name); - - // Set the MasterDetailsComponent - iCEMasterDetailsPage - .setMasterDetailsComponent(masterDetailsComponent); - - formPages.add(iCEMasterDetailsPage); - } - } - } - /* ------------------------------------------------- */ - - /* ---- Create the Analysis Artifacts page. ---- */ - // This page allows the user to view resources (results) from the KDD - // strategies on the previous page. - - // Create the page for ResourceComponents - if (!(componentMap.get("output").isEmpty())) { - resourceComponent = (ResourceComponent) (componentMap.get("output") - .get(0)); - if (resourceComponent != null) { - // Make the page - resourceComponentPage = new ICEResourcePage(this, - resourceComponent.getName(), - resourceComponent.getName()); - // Set the ResourceComponent - resourceComponentPage.setResourceComponent(resourceComponent); - } - formPages.add(resourceComponentPage); - } - /* --------------------------------------------- */ - - // Add the pages created above to the ReactorFormEditor. - try { - for (ICEFormPage i : formPages) { - addPage(i); - } - } catch (PartInitException e) { - logger.error(getClass().getName() + " Exception!",e); - } - - return; - } - - /** - * Overrides the doSave() behavior from ICEFormEditor to ensure that all - * ReactorSectionParts (AnalysisToolComposites) in rendered ReactorPages - * refresh with the new data. - */ - @Override - public void doSave(IProgressMonitor monitor) { - // Perform the standard doSave behavior. - super.doSave(monitor); - - // We need to refresh the other reactor pages, too! Otherwise, if they - // have been rendered, they will not refresh their data immediately. - - // Get the currently-selected page. - ICEFormPage selectedPage = (ICEFormPage) this.getSelectedPage(); - // For the other ReactorPages, refresh all of their parts. - if (reactorPage != null && reactorPage != selectedPage) { - // Check to make sure the ReactorPage has been rendered. - IManagedForm managedForm = reactorPage.getManagedForm(); - if (managedForm != null) { - for (IFormPart part : managedForm.getParts()) { - part.refresh(); - } - - } - } - - /* - * To re-create the bug that necessitates this override, comment out the - * above code (except for the super call). Open a new Reactor Analyzer - * in ICE. Briefly open the second Reactor Page (Fuel Assembly/Pin), - * then go back to the first page (Reactor/Fuel Assembly). - * - * Now, load an SFReactor file. The ICEFormEditor.doSave() method calls - * refresh on the currently-opened ReactorPage. However, the second - * ReactorPage will only be updated when the reactor SFRComponent - * notifies its listeners, which does not happen until another SFR file - * is loaded. - * - * What this means is that the second page will still display an LWR - * grid until you load a second SFR file! - * - * The third page is OK, because it's not been rendered yet. - */ - } - - @Override - public void setInput(IEditorInput editorInput) { - // // Get the old ReactorFormInput if possible. - - super.setInput(editorInput); - - // Update the form with any new input/reference components and pass on - // any new information required by the ReactorPage. - if (editorInput instanceof ReactorFormInput) { - // Get the ReactorFormInput and the Form associated with this - // editor/Reactor Analyzer. - ReactorFormInput formInput = (ReactorFormInput) editorInput; - Form form = formInput.getForm(); - - // Get the ReactorComposite from the form. - ReactorComposite reactorComposite = (ReactorComposite) form - .getComponent(ReactorAnalyzer.reactorCompositeId); - - // If necessary, update the input reactor component in the form. - IReactorComponent input = formInput.getInputReactorComponent(); - if (input != null) { - - // Get the ID used for the input reactor component. - int id = ReactorAnalyzer.inputReactorComponentId; - - // If the component is different from the previous one, we need - // to update the form. - IReactorComponent oldInput = reactorComposite - .getReactorComponent(id); - if (input != oldInput) { - // Update the ReactorComposite. - reactorComposite.setComponent(id, input); - } - } - - IReactorComponent reference = formInput - .getReferenceReactorComponent(); - if (reference != null) { - - // Get the ID used for the reference reactor component. - int id = ReactorAnalyzer.referenceReactorComponentId; - - // If the component is different from the previous one, we need - // to update the form. - IReactorComponent oldReference = reactorComposite - .getReactorComponent(id); - if (reference != oldReference) { - // Update the ReactorComposite. - reactorComposite.setComponent(id, reference); - } - } - - // Set the reactor page's StateBroker if the page has been created. - StateBroker newBroker = formInput.getStateBroker(); - if (reactorPage != null) { - reactorPage.setStateBroker(newBroker); - } - // Tell the core that the form has been updated. - notifyUpdateListeners(); - } - - return; - } - -} diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormInput.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormInput.java deleted file mode 100644 index a39c8940d..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormInput.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; - -import org.eclipse.ice.client.widgets.ICEFormInput; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.ice.reactorAnalyzer.ReactorAnalyzer; - -/** - * This class provides input for {@link ReactorFormEditor}s. It requires both an - * {@link IAnalysisWidgetRegistry} and a {@link StateBroker}. All - * ReactorFormEditors share the same analysis widget registry, but they do not - * necessarily share the same StateBroker. Two editors can be linked together by - * making them share the same StateBroker. - * - * @author Jordan H. Deyton - * - */ -public class ReactorFormInput extends ICEFormInput { - - /** - * The registry that provides the available {@link IAnalysisView}s to the - * reactor editor. - */ - private final IAnalysisWidgetRegistry registry; - - /** - * The StateBroker that manages selections in the reactor editor. - */ - private final StateBroker broker; - - /** - * The input reactor component. - */ - private IReactorComponent inputReactor; - /** - * The source file for {@link #inputReactor}. - */ - private ICEResource inputSource; - - /** - * The reference reactor component. - */ - private IReactorComponent referenceReactor; - /** - * The source file for {@link #referenceReactor}. - */ - private ICEResource referenceSource; - - /** - * The default constructor. This creates input for a - * {@link ReactorFormEditor} and creates a new StateBroker for the editor. - * - * @param inputForm - * The form associated with the Reactor Analyzer item. - * @param registry - * The registry that provides the available {@link IAnalysisView} - * s to the reactor editors. - */ - public ReactorFormInput(Form inputForm, IAnalysisWidgetRegistry registry) { - this(inputForm, registry, new StateBroker()); - } - - /** - * This constructor provides the specified StateBroker for the - * {@link ReactorFormEditor}. - * - * @param inputForm - * The form associated with the Reactor Analyzer item. - * @param registry - * The registry that provides the available {@link IAnalysisView} - * s to the reactor editors. - * @param broker - * The StateBroker that manages selections in the reactor editor. - */ - public ReactorFormInput(Form inputForm, IAnalysisWidgetRegistry registry, - StateBroker broker) { - super(inputForm); - - this.registry = registry; - this.broker = broker; - - return; - } - - /** - * Gets the registry that provides the available {@link IAnalysisView}s to - * the reactor editors. - * - * @return The input's IAnalysisWidgetRegistry. - */ - public IAnalysisWidgetRegistry getRegistry() { - return registry; - } - - /** - * Gets the StateBroker that manages selections in the reactor editor. - * - * @return The input's StateBroker. - */ - public StateBroker getStateBroker() { - return broker; - } - - /** - * Sets the input reactor component used by the {@link ReactorAnalyzer}. - * - * @param input - * The new input reactor component. - * @param source - * The source file for the input reactor component. - */ - public void setInputReactorComponent(IReactorComponent input, - ICEResource source) { - - if (input != null && source != null) { - inputReactor = input; - inputSource = source; - } - - return; - } - - /** - * Gets the input IReactorComponent. This will be used to update the form - * for the {@link ReactorFormEditor}. - * - * @return The new input reactor component. - */ - public IReactorComponent getInputReactorComponent() { - return inputReactor; - } - - /** - * Gets the ICEResource for the file that contains the input - * IReactorComponent. - * - * @return The source file for the input reactor component. - */ - public ICEResource getInputReactorComponentSource() { - return inputSource; - } - - /** - * Sets the reference reactor component used by the {@link ReactorAnalyzer}. - * This updates the underlying form! - * - * @param reference - * The new reference reactor component. - * @param source - * The source file for the reference reactor component. - */ - public void setReferenceReactorComponent(IReactorComponent reference, - ICEResource source) { - - if (reference != null && source != null) { - referenceReactor = reference; - referenceSource = source; - } - - return; - } - - /** - * Gets the reference IReactorComponent. This will be used to update the - * form for the {@link ReactorFormEditor}. - * - * @return The new reference reactor component. - */ - public IReactorComponent getReferenceReactorComponent() { - return referenceReactor; - } - - /** - * Gets the ICEResource for the file that contains the reference - * IReactorComponent. - * - * @return The source file for the reference reactor component. - */ - public ICEResource getReferenceReactorComponentSource() { - return referenceSource; - } - -} diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormInputFactory.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormInputFactory.java deleted file mode 100644 index b4ae98073..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormInputFactory.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; - -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.jface.viewers.ITreeSelection; -import org.eclipse.jface.viewers.TreePath; - -/** - * This factory is used to help construct {@link ReactorFormInput} for a - * {@link ReactorFormEditor}. - * - * @author Jordan H. Deyton - * - */ -public class ReactorFormInputFactory { - - /** - * The default method for creating {@link ReactorFormInput}. - * - * @param inputForm - * The form associated with the Reactor Analyzer item. - * @param registry - * The registry that provides the available {@link IAnalysisView} - * s to the reactor editor. - * @return A new ReactorFormInput if the parameters are not null, null - * otherwise. - */ - public ReactorFormInput createInput(Form inputForm, - IAnalysisWidgetRegistry registry) { - - ReactorFormInput input = null; - - if (inputForm != null && registry != null) { - input = new ReactorFormInput(inputForm, registry); - } - - return input; - } - - /** - * This method creates a {@link ReactorFormInput} based on previous input - * and a new {@link StateBroker}. - * - * @param oldInput - * The previous input for the Reactor Analyzer. - * @param broker - * The new StateBroker that should be used to manage selections - * in the reactor editor. - * @return A new ReactorFormInput if the parameters are not null, null - * otherwise. - */ - public ReactorFormInput createInput(ReactorFormInput oldInput, - StateBroker broker) { - - ReactorFormInput input = null; - - if (oldInput != null && broker != null) { - // Create the basic ReactorFormInput. - Form inputForm = oldInput.getForm(); - IAnalysisWidgetRegistry registry = oldInput.getRegistry(); - input = new ReactorFormInput(inputForm, registry, broker); - } - - return input; - } - - /** - * This method creates a {@link ReactorFormInput} based on previous input - * and a {@link ITreeSelection} that will be used to generate a new - * {@link StateBroker}. - * - * @param oldInput - * The previous input for the Reactor Analyzer. - * @param selection - * A selection of {@link IReactorComponent}s that will be fed - * into a new StateBroker. - * @param dataSource - * the DataSource that the selection is being sent to, e.g., - * Input or Reference. - * @return A new ReactorFormInput if the parameters are not null, null - * otherwise. - */ - public ReactorFormInput createInput(ReactorFormInput oldInput, - ITreeSelection selection, DataSource dataSource) { - ReactorFormInput input = null; - - if (oldInput != null && selection != null) { - // Create the basic ReactorFormInput with a new StateBroker. - StateBroker broker = new StateBroker(); - broker.copyValues(oldInput.getStateBroker()); - Form inputForm = oldInput.getForm(); - IAnalysisWidgetRegistry registry = oldInput.getRegistry(); - - // Reset all keys associated with this data source. - broker.resetSource(dataSource.toString()); - - IReactorComponent rootComponent = null; - - // Create the form input. - input = new ReactorFormInput(inputForm, registry, broker); - - // Update the StateBroker based on the ITreeSelection. - if (!selection.isEmpty()) { - TreePath path = selection.getPaths()[0]; - - IAnalysisWidgetFactory factory; - IStateBrokerHandler handler; - - // Loop over the segments in the TreePath. Each segment is a - // node in the tree from the root to the selected object. - int size = path.getSegmentCount(); - Object lastObject = null; - for (int i = 0; i < size; i++) { - Object object = path.getSegment(i); - - // Get the IAnalysisWidgetFactory for the object, then get - // an IStateBrokerKeyProvider from the factory. Use the key - // provider to get a key, then update the StateBroker with - // the object. - factory = registry.getAnalysisWidgetFactory(object - .getClass()); - if (factory != null) { - handler = factory.createStateBrokerHandler(); - handler.setDataSource(dataSource); - if (handler.addValue(object, lastObject, broker)) { - lastObject = object; - - // If possible, set the input reactor and its - // resource for the input. - if (rootComponent == null) { - rootComponent = (IReactorComponent) object; - ICEResource source = (ICEResource) path - .getSegment(0); - - if (dataSource == DataSource.Input) { - input.setInputReactorComponent( - rootComponent, source); - } else { - input.setReferenceReactorComponent( - rootComponent, source); - } - } - } - } - } - } - } - - return input; - } - -} diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormWidgetBuilder.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormWidgetBuilder.java deleted file mode 100644 index 74e718365..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorFormWidgetBuilder.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.ice.client.widgets.IFormWidgetBuilder; -import org.eclipse.ice.iclient.uiwidgets.IFormWidget; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class provides the declarative service that registers the Reactor Editor - * Form Widget with ICE's service for dynamically extending the widget factory. - * - * @author Jay Jay Billings - * - */ -public class ReactorFormWidgetBuilder implements IFormWidgetBuilder { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(ReactorFormWidgetBuilder.class); - - /** - * The name of the items/forms used to create {@link ReactorFormEditor}s. - * This should be the same as the name in the Reactor Analyzer item class. - */ - public static final String name = "Reactor Analyzer"; - - /** - * The current registry used to generate analysis widgets for customized - * analysis views. - */ - private IAnalysisWidgetRegistry widgetRegistry = null; - - /** - * The current registry of ReactorFormEditors. - */ - private IReactorEditorRegistry editorRegistry = null; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.client.widgets.IFormWidgetBuilder#getTargetFormName - * () - */ - @Override - public String getTargetFormName() { - return name; - } - - /** - * This operation builds the FormWidget. - * - * @return The FormWidget for the Reactor Editor. - */ - @Override - public IFormWidget build() { - - ReactorEclipseFormWidget widget = null; - - if (widgetRegistry == null || editorRegistry == null) { - logger.info("ReactorFormWidgetBuilder error: " - + "No analysis widget registry or editor registry " - + "available for creating a ReactorEclipseFormWidget!"); - } else { - widget = new ReactorEclipseFormWidget(widgetRegistry, - editorRegistry); - } - - return widget; - } - - /** - * Sets the IAnalysisWidgetRegistry used by {@link AnalysisToolComposite}s - * in {@link ReactorPage}s. - * - * @param registry - * The widget registry. - */ - public void setAnalysisWidgetRegistry(IAnalysisWidgetRegistry registry) { - logger.info("ReactorFormWidgetBuilder: " - + "Adding new IAnalysisWidgetRegistry."); - if (registry != null) { - this.widgetRegistry = registry; - } - return; - } - - /** - * Sets the IReactorEditorRegistry to which {@link ReactorFormEditor}s - * should register when they are created. These editors are contacted from - * the ReactorViewer in the reactors perspective. - * - * @param registry - * The editor registry. - */ - public void setReactorEditorRegistry(IReactorEditorRegistry registry) { - logger.info("ReactorFormWidgetBuilder: " - + "Adding new IReactorEditorRegistry."); - if (registry != null) { - this.editorRegistry = registry; - } - - IConfigurationElement[] elements = Platform.getExtensionRegistry() - .getConfigurationElementsFor( - "org.eclipse.ice.client.widgets.reactoreditor.ireactoreditorregistry"); - logger.info( - "Available configuration elements(in org.eclipse.ice.client.widgets.reactoreditor.ReactorFormInputFactory.java):"); - for (IConfigurationElement element : elements) { - logger.info( - element.getNamespaceIdentifier() + " " + element.getName()); - } - - return; - } -} diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorPage.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorPage.java deleted file mode 100644 index 93b92b39f..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ReactorPage.java +++ /dev/null @@ -1,416 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; - -import java.util.ArrayList; - -import org.eclipse.ice.client.widgets.ICEFormEditor; -import org.eclipse.ice.client.widgets.ICEFormPage; -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.datastructures.ICEObject.IUpdateable; -import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener; -import org.eclipse.ice.datastructures.ICEObject.ListComponent; -import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.form.AdaptiveTreeComposite; -import org.eclipse.ice.datastructures.form.DataComponent; -import org.eclipse.ice.datastructures.form.GeometryComponent; -import org.eclipse.ice.datastructures.form.MasterDetailsComponent; -import org.eclipse.ice.datastructures.form.MatrixComponent; -import org.eclipse.ice.datastructures.form.MeshComponent; -import org.eclipse.ice.datastructures.form.ResourceComponent; -import org.eclipse.ice.datastructures.form.TableComponent; -import org.eclipse.ice.datastructures.form.TimeDataComponent; -import org.eclipse.ice.datastructures.form.TreeComposite; -import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.ice.reactorAnalyzer.ReactorAnalyzer; -import org.eclipse.ice.reactorAnalyzer.ReactorComposite; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.IFormPart; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.SectionPart; -import org.eclipse.ui.forms.editor.FormEditor; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.forms.widgets.Section; - -/** - * This class extends the default ICEFormPage to provide custom page composed of - * widgets for reactors. - * - * This class only cares about the IReactorComponents and DataComponents that - * are passed to it and all other visitation operations do nothing. - * - * @author Jay Jay Billings - * - */ -public class ReactorPage extends ICEFormPage implements IComponentVisitor, - IUpdateableListener { - - /** - * The list of DataComponents that is formed by visiting the Components - * assigned to this page. These are typically the input and reference data. - */ - private final ArrayList dataComponents; - - /** - * This Composite contains the input and reference reactor components. - */ - private ReactorComposite reactorComposite; - - /** - * The resource Component. This is typically the "Comparison Reactor". - */ - private ResourceComponent resourceComponent; - - /** - * The SectionPart that contains the {@link #analysisComposite}. - */ - private SectionPart sectionPart; - - /** - * The AnalysisToolComposite that renders the reactor data for this page. - */ - private AnalysisToolComposite analysisComposite; - /** - * The registry maintains a Map of factories for analysis widgets. - */ - private IAnalysisWidgetRegistry registry; - /** - * The StateBroker that manages state information about the different views. - */ - private StateBroker stateBroker; - /** - * The ISelectionProvider that manages the current selection in the - * ReactorEditor. The current selection has its properties displayed in the - * ICE Properties View. - */ - private ISelectionProvider selectionProvider; - - /** - * The constructor - * - * @param editor - * The FormEditor that is constructing this page - * @param id - * The unique identifier of this page. - * @param title - * The title that this page should display in the editor. - */ - public ReactorPage(FormEditor editor, String id, String title) { - - // Call the super constructor - super(editor, id, title); - - // Set the FormEditor if it is not null and throw an exception - // otherwise. - if (editor != null && editor instanceof ICEFormEditor) { - this.editor = (ICEFormEditor) editor; - } else { - throw new RuntimeException("Editor in ReactorPage " - + " constructor cannot be null."); - } - // Setup the list for Components - dataComponents = new ArrayList(); - reactorComposite = null; - - return; - } - - /** - * Sets the IAnalysisWidgetRegistry used to generate {@link IAnalysisView}s - * for the {@link #analysisComposite}. - * - * @param registry - * The IAnalysisWidgetRegistry to use. - */ - public void setAnalysisWidgetRegistry(IAnalysisWidgetRegistry registry) { - if (registry != null) { - this.registry = registry; - } - return; - } - - /** - * Sets the ISelectionProvider that manages the current selection in the - * ReactorEditor. The current selection has its properties displayed in the - * ICE Properties View. - * - * @param provider - * The new ISelectionProvider. - */ - public void setSelectionProvider(ISelectionProvider provider) { - // Only set the provider if it is not null. - if (provider != null) { - selectionProvider = provider; - } - return; - } - - /** - * This operation sets the state broker that will be shared by the parts of - * the ReactorEditor to maintain view state. - * - * @param broker - * The state broker - */ - public void setStateBroker(StateBroker broker) { - // Only set the broker if it is not null. - if (broker != null) { - stateBroker = broker; - - // Update the section parts. - if (analysisComposite != null) { - analysisComposite.setStateBroker(broker); - } - } - - return; - } - - /** - * Sets the ReactorComposite that contains the input and reference reactor - * components for this reactor page. - * - * @param reactorComposite - * The new ReactorComposite. - */ - public void setReactorComposite(ReactorComposite reactorComposite) { - // Only proceed if the new reactor composite is not null. - if (reactorComposite != null) { - // If necessary, unregister from the old reactor composite. - if (this.reactorComposite != null) { - this.reactorComposite.unregister(this); - } - - // Set the new one and register with it. - this.reactorComposite = reactorComposite; - reactorComposite.register(this); - - // Update the page based on the new reactor composite. - update(reactorComposite); - } - - return; - } - - /** - * This operation adds a Component to the set of Components that are managed - * by this page. - * - * @param component - * A new Component for this page to manage - */ - public void addComponent(Component component) { - - if (component != null) { - // Visit the components so that they can be sorted - component.accept(this); - } - - return; - } - - /** - * This operation overrides the parent operation to create the graphical - * content of the Form. - * - * @param managedForm - * The IManagedForm from the parent FormEditor. - */ - @Override - protected void createFormContent(IManagedForm managedForm) { - - // Local Declarations - final ScrolledForm form = managedForm.getForm(); - form.getBody().setLayout(new FillLayout()); - form.setMinWidth(10); - - // ---- Create the AnalysisToolComposite ---- // - // Get the toolkit used to create Composites, Sections, etc. - FormToolkit formToolkit = managedForm.getToolkit(); - - // Create a single Section with a single SectionPart. When the form - // updates, it calls the SectionPart's refresh() method. This method - // should call this class' refreshContent() method. - Section section = formToolkit.createSection(form.getBody(), - ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED); - sectionPart = new SectionPart(section) { - @Override - public void refresh() { - super.refresh(); - - // Call the method in the ReactorPage. There's no need for a - // separate class just for this behavior. - refreshContent(); - } - }; - // Add the section part to the form so that updates will be sent to the - // part (and thus will call refreshContent()). - managedForm.addPart(sectionPart); - - // Create the ATC inside the section, and set the ATC as the section's - // primary client Composite. - analysisComposite = new AnalysisToolComposite(section, stateBroker, - registry, selectionProvider); - section.setClient(analysisComposite); - - // Set the background color for the ATC to be the same as the section. - analysisComposite.setBackground(section.getBackground()); - - // Refresh the information displayed in the ATC. - refreshContent(); - // ------------------------------------------ // - - return; - } - - /** - * This method refreshes {@link #analysisComposite}. Normally, this would be - * taken care of by the {@link IFormPart}s on this page. However, we only - * have one part and do not need to have a separate class to handle the - * part's behavior (which is just to wrap an {@link AnalysisToolComposite}. - */ - protected void refreshContent() { - - // If possible, update the ATC. - if (analysisComposite != null) { - // Get the input and reference reactor components from the - // composite. - IReactorComponent input = reactorComposite - .getReactorComponent(ReactorAnalyzer.inputReactorComponentId); - IReactorComponent reference = reactorComposite - .getReactorComponent(ReactorAnalyzer.referenceReactorComponentId); - - // Set the input and reference reactor for the ATC. - analysisComposite.setData(DataSource.Input.toString(), input); - analysisComposite.setData(DataSource.Reference.toString(), - reference); - } - - // If the ResourceComponent has been populated with - // ICEResources, then give it to the AnalysisComposite. - if (resourceComponent != null) { - ArrayList resources = resourceComponent.getResources(); - if (resources != null && !resources.isEmpty()) { - analysisComposite.setData(DataSource.Comparison.toString(), - resourceComponent); - } - } - return; - } - - /** - * This is activated by the {@link IReactorComponent}s in - * {@link #reactorComposite} and by {@link #resourceComponent}. - */ - @Override - public void update(IUpdateable component) { - - // Note that this is called by the reactor composite AND the resource - // component. - - // Redraw - note that we must use the UI Thread - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - // Refresh the section part. This will ultimately call - // refreshContent(). - sectionPart.refresh(); - } - }); - } - - // ---- Implements IComponentVisitor ---- // - // These operations should update the references to components that are - // important to displaying reactor information in the AnalysisToolComposite, - // and, if necessary, register with them. - - @Override - public void visit(DataComponent component) { - // Add the data component to the list - dataComponents.add(component); - } - - @Override - public void visit(ResourceComponent component) { - // Set the resource component and register with it. - resourceComponent = component; - resourceComponent.register(this); - } - - @Override - public void visit(TableComponent component) { - // Nothing to do - } - - @Override - public void visit(MatrixComponent component) { - // Nothing to do - } - - @Override - public void visit(GeometryComponent component) { - // Nothing to do - } - - @Override - public void visit(MasterDetailsComponent component) { - // Nothing to do - } - - @Override - public void visit(TreeComposite component) { - // Nothing to do - } - - @Override - public void visit(IReactorComponent component) { - // Nothing to do - } - - @Override - public void visit(TimeDataComponent component) { - // Nothing to do - } - - @Override - public void visit(MeshComponent component) { - // Nothing to do - } - - - @Override - public void visit(AdaptiveTreeComposite component) { - // Nothing to do - - } - // -------------------------------------- // - - @Override - public void visit(EMFComponent component) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(ListComponent component) { - // TODO Auto-generated method stub - - } - -} diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/properties/ReactorComponentPropertySource.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/properties/ReactorComponentPropertySource.java deleted file mode 100644 index df4a2b6ec..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/properties/ReactorComponentPropertySource.java +++ /dev/null @@ -1,218 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor.properties; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener; -import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; - -/** - * This class provides the properties of an SFRComponent to be displayed in the - * ICE Properties View. It displays all of the properties of an SFRComponent.
- *

- * Sub-classes should add their own properties via - * {@link #addProperty(SimpleProperty)}. - *

- * - * @author Jordan H. Deyton - * - */ -public class ReactorComponentPropertySource implements IPropertySource { - - /** - * A Map of {@linkplain SimpleProperty} instances for the selected - * component. - */ - private final Map properties; - - /** - * The default constructor. - * - * @param component - * The component whose properties are to be displayed in the ICE - * Properties View. - */ - public ReactorComponentPropertySource(IReactorComponent component) { - // Set a default, blank component if the argument is null. - if (component == null) { - component = new IReactorComponent() { - // Give the properties something to signify that the component - // is - // invalid. - @Override - public String getName() { - return "Invalid reactor component!"; - } - - @Override - public String getDescription() { - return "This is an invalid reactor component!"; - } - - @Override - public int getId() { - return 1; - } - - @Override - public void accept(IComponentVisitor visitor) { - } - - @Override - public void update(String updatedKey, String newValue) { - } - - @Override - public void register(IUpdateableListener listener) { - } - - @Override - public void unregister(IUpdateableListener listener) { - } - - @Override - public void setId(int id) { - } - - @Override - public void setName(String name) { - } - - @Override - public void setDescription(String description) { - } - - // This is required to avoid a CloneNotSupported exception. - @Override - public Object clone() { - return null; - } - }; - } - - // Initialize the map of properties. - properties = new HashMap(); - - // Set the basic properties for IReactorComponents. - String category = "Basic Properties"; - addProperty(new SimpleProperty("name", "Name", category, - component.getName())); - addProperty(new SimpleProperty("description", "Description", category, - component.getDescription())); - addProperty(new SimpleProperty("id", "ID", category, component.getId())); - - return; - } - - /** - * Adds a SimpleProperty to the properties exposed by this IPropertySource. - * - * @param property - * A SimpleProperty instance to add. - * @return True if the property is not null and its ID did not already exist - * in the map, false otherwise. - */ - public boolean addProperty(SimpleProperty property) { - - // By default, the addition failed. - boolean success = false; - - // Only attempt to add the property if the property is not null and its - // ID is not already in the Map. - if (property != null && !properties.containsKey(property.getId())) { - properties.put(property.getId(), property); - success = true; - } - - return success; - } - - /* ---- Implements IPropertySource. ---- */ - /** - * Returns null. Properties for IReactorComponents are currently read-only! - */ - @Override - public Object getEditableValue() { - // Read-only! - return null; - } - - /** - * Returns the IPropertyDescriptors for IReactorComponents. - */ - @Override - public IPropertyDescriptor[] getPropertyDescriptors() { - // Create a new Array. - IPropertyDescriptor[] descriptors = new IPropertyDescriptor[properties - .size()]; - - // Add a PropertyDescriptor for each of the simple properties. - int i = 0; - for (SimpleProperty property : properties.values()) { - descriptors[i++] = property.getPropertyDescriptor(); - } - - return descriptors; - } - - /** - * Returns the value for a particular IReactorComponent property or null if - * it is an invalid property. - */ - @Override - public Object getPropertyValue(Object id) { - - // Set the default return value. - Object value = null; - - // See if the id matches any of the supported property IDs. - SimpleProperty property = properties.get(id); - if (property != null) { - value = property.getValue(); - } - return value; - } - - /** - * Returns false. Properties for IReactorComponents are currently read-only! - */ - @Override - public boolean isPropertySet(Object id) { - // Read-only! - return false; - } - - /** - * Does nothing. Properties for IReactorComponents are currently read-only! - */ - @Override - public void resetPropertyValue(Object id) { - // Read-only! - return; - } - - /** - * Does nothing. Properties for IReactorComponents are currently read-only! - */ - @Override - public void setPropertyValue(Object id, Object value) { - // Read-only! - return; - } - /* ------------------------------------- */ -} diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/properties/SimpleProperty.java b/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/properties/SimpleProperty.java deleted file mode 100644 index 56bf7c6d9..000000000 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/properties/SimpleProperty.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor.properties; - -import org.eclipse.ui.views.properties.PropertyDescriptor; - -/** - * This class provides a wrapper for a simple IPropertyDescriptor. A property - * requires at least 3 things: an ID, a display name, and a value. It can also - * have a category, the default value being "Misc".
- *
- * The ID for a SimpleProperty should be unique for a particular - * IPropertySource.
- *
- * If an instance requires a more specialized IPropertyDescriptor, then the - * method {@linkplain SimpleProperty#getPropertyDescriptor()} should be - * overridden. - * - * @author Jordan H. Deyton - * - */ -public class SimpleProperty { - - /** - * The ID of the property. This is used to construct an IPropertyDescriptor - * and should be unique within the IPropertySource. - */ - private final String id; - /** - * The text displayed for the IPropertyDescriptor. This does not need to be - * unique. - */ - private final String displayName; - /** - * The category under which the property will appear. If null, the property - * should default to "Misc". If no categories are specified in the - * IPropertySource, then "Misc" will not appear. - */ - private final String category; - /** - * The value of the property. If null, you may want to override - * {@linkplain SimpleProperty#getValue()}. - */ - private final Object value; - - /** - * The default constructor. - * - * @param id - * The ID of the property. This is used to construct an - * IPropertyDescriptor and should be unique within the - * IPropertySource. - * @param displayName - * The text displayed for the IPropertyDescriptor. This does not - * need to be unique. - * @param category - * The category under which the property will appear. If null, - * the property should default to "Misc". If no categories are - * specified in the IPropertySource, then "Misc" will not appear. - * @param value - * The value of the property. If null, you may want to override - * {@linkplain SimpleProperty#getValue()}. - */ - public SimpleProperty(String id, String displayName, String category, - Object value) { - // Replace any null Strings with empty Strings. - this.id = (id != null ? id : ""); - this.displayName = (displayName != null ? displayName : ""); - this.category = (category != null ? category : ""); - this.value = value; - - return; - } - - /** - * Gets a PropertyDescriptor for the SimpleProperty. - * - * @return A PropertyDescriptor configured with the SimpleProperty's fields. - */ - public PropertyDescriptor getPropertyDescriptor() { - PropertyDescriptor property = new PropertyDescriptor(id, displayName); - property.setCategory(category); - return property; - } - - /** - * Gets the String ID used for the SimpleProperty. It should be unique - * within the parent IPropertySource. - * - * @return A String ID. - */ - public String getId() { - return id; - } - - /** - * Gets the current value of the property. - * - * @return An Object pointing to the value of the property. - */ - public Object getValue() { - return value; - } -} diff --git a/org.eclipse.ice.client.widgets.test/src/org/eclipse/ice/client/widgets/test/ICEResourcePageTester.java b/org.eclipse.ice.client.widgets.test/src/org/eclipse/ice/client/widgets/test/ICEResourcePageTester.java index c98c29e94..027350f3b 100644 --- a/org.eclipse.ice.client.widgets.test/src/org/eclipse/ice/client/widgets/test/ICEResourcePageTester.java +++ b/org.eclipse.ice.client.widgets.test/src/org/eclipse/ice/client/widgets/test/ICEResourcePageTester.java @@ -29,7 +29,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.eclipse.ui.IEditorReference; import org.junit.Test; -import org.hamcrest.Matcher; /** * This class is responsible for testing the ICEResourcePage. diff --git a/org.eclipse.ice.client.widgets.test/src/org/eclipse/ice/client/widgets/test/IFormWidgetBuilderTest.java b/org.eclipse.ice.client.widgets.test/src/org/eclipse/ice/client/widgets/test/IFormWidgetBuilderTest.java index 571f69ddb..8ced4faf1 100644 --- a/org.eclipse.ice.client.widgets.test/src/org/eclipse/ice/client/widgets/test/IFormWidgetBuilderTest.java +++ b/org.eclipse.ice.client.widgets.test/src/org/eclipse/ice/client/widgets/test/IFormWidgetBuilderTest.java @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.ice.client.widgets.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.eclipse.core.runtime.CoreException; import org.eclipse.ice.client.widgets.IFormWidgetBuilder; diff --git a/org.eclipse.ice.client.widgets/META-INF/MANIFEST.MF b/org.eclipse.ice.client.widgets/META-INF/MANIFEST.MF index c58617f95..86e34a55c 100644 --- a/org.eclipse.ice.client.widgets/META-INF/MANIFEST.MF +++ b/org.eclipse.ice.client.widgets/META-INF/MANIFEST.MF @@ -20,13 +20,16 @@ Import-Package: com.jme3.app, org.eclipse.core.resources, org.eclipse.core.runtime;version="3.4.0", org.eclipse.core.runtime.jobs, + org.eclipse.draw2d, + org.eclipse.draw2d.geometry, + org.eclipse.gef, + org.eclipse.gef.editparts, org.eclipse.ice.client.common, org.eclipse.ice.client.common.internal, org.eclipse.ice.client.common.properties, org.eclipse.ice.client.widgets.jme, org.eclipse.ice.iclient, org.eclipse.ice.iclient.uiwidgets, - org.eclipse.ice.reactor, org.eclipse.ice.viz.service, org.eclipse.ice.viz.service.csv, org.eclipse.ice.viz.service.datastructures, @@ -45,7 +48,8 @@ Import-Package: com.jme3.app, org.eclipse.ui.views.properties.tabbed, org.osgi.framework;version="1.6.0", org.slf4j;version="1.7.2" -Export-Package: org.eclipse.ice.client.widgets +Export-Package: org.eclipse.ice.client.widgets, + org.eclipse.ice.client.widgets.analysis Service-Component: OSGI-INF/eclipseWidgetsComponent.xml, OSGI-INF/formEditorVizService.xml Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ComponentPropertySection.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ComponentPropertySection.java index c3a63b17e..785a8e97a 100644 --- a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ComponentPropertySection.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ComponentPropertySection.java @@ -26,12 +26,12 @@ import org.eclipse.ice.datastructures.form.MasterDetailsComponent; import org.eclipse.ice.datastructures.form.MatrixComponent; import org.eclipse.ice.datastructures.form.MeshComponent; +import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.form.TableComponent; import org.eclipse.ice.datastructures.form.TimeDataComponent; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.SWT; diff --git a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/EMFTreeCompositeViewer.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/EMFTreeCompositeViewer.java index f39cb063c..3a0f93057 100644 --- a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/EMFTreeCompositeViewer.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/EMFTreeCompositeViewer.java @@ -16,9 +16,7 @@ import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.dialogs.InputDialog; @@ -28,9 +26,7 @@ import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IWorkbenchPartReference; diff --git a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEFormEditor.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEFormEditor.java index b960c8194..4ea9cc6e8 100644 --- a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEFormEditor.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEFormEditor.java @@ -36,13 +36,13 @@ import org.eclipse.ice.datastructures.form.MasterDetailsComponent; import org.eclipse.ice.datastructures.form.MatrixComponent; import org.eclipse.ice.datastructures.form.MeshComponent; +import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.form.TableComponent; import org.eclipse.ice.datastructures.form.TimeDataComponent; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.datastructures.form.emf.EMFComponent; import org.eclipse.ice.datastructures.form.geometry.ICEGeometry; -import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.iclient.IClient; import org.eclipse.ice.iclient.uiwidgets.IObservableWidget; import org.eclipse.ice.iclient.uiwidgets.IProcessEventListener; diff --git a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEMeshPage.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEMeshPage.java index e186d1045..7e2e468c9 100644 --- a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEMeshPage.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEMeshPage.java @@ -20,12 +20,13 @@ import org.eclipse.ice.datastructures.ICEObject.ICEObject; import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.viz.service.IVizService; +import org.eclipse.ice.viz.service.geometry.widgets.TransformationView; import org.eclipse.ice.viz.service.jme3.mesh.IMeshSelectionListener; import org.eclipse.ice.viz.service.jme3.mesh.JME3MeshCanvas; import org.eclipse.ice.viz.service.jme3.mesh.MeshAppStateMode; import org.eclipse.ice.viz.service.jme3.mesh.MeshAppStateModeFactory; -import org.eclipse.ice.viz.service.jme3.mesh.MeshSelectionManager; import org.eclipse.ice.viz.service.jme3.mesh.MeshAppStateModeFactory.Mode; +import org.eclipse.ice.viz.service.jme3.mesh.MeshSelectionManager; import org.eclipse.ice.viz.service.mesh.datastructures.BezierEdge; import org.eclipse.ice.viz.service.mesh.datastructures.Edge; import org.eclipse.ice.viz.service.mesh.datastructures.Hex; @@ -36,7 +37,6 @@ import org.eclipse.ice.viz.service.mesh.datastructures.Vertex; import org.eclipse.ice.viz.service.mesh.datastructures.VizMeshComponent; import org.eclipse.ice.viz.service.mesh.properties.MeshSelection; -import org.eclipse.ice.viz.service.geometry.widgets.TransformationView; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.ToolBarManager; diff --git a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEResourcePage.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEResourcePage.java index 384c16c47..e6cc7a802 100644 --- a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEResourcePage.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICEResourcePage.java @@ -15,6 +15,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Arrays; + import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IResourceChangeEvent; @@ -30,7 +31,6 @@ import org.eclipse.ice.datastructures.resource.VizResource; import org.eclipse.ice.iclient.uiwidgets.ISimpleResourceProvider; import org.eclipse.ice.viz.service.widgets.PlotGridComposite; -import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; @@ -38,8 +38,6 @@ import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; diff --git a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICESectionPage.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICESectionPage.java index e0c2aea41..6360f7c59 100644 --- a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICESectionPage.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ICESectionPage.java @@ -24,12 +24,12 @@ import org.eclipse.ice.datastructures.form.MasterDetailsComponent; import org.eclipse.ice.datastructures.form.MatrixComponent; import org.eclipse.ice.datastructures.form.MeshComponent; +import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.form.TableComponent; import org.eclipse.ice.datastructures.form.TimeDataComponent; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; diff --git a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/IFormWidgetBuilder.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/IFormWidgetBuilder.java index 6cf100a5c..90357b0aa 100644 --- a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/IFormWidgetBuilder.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/IFormWidgetBuilder.java @@ -17,7 +17,6 @@ import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.Platform; import org.eclipse.ice.iclient.uiwidgets.IFormWidget; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/TreeNodeFilteredItemsSelectionDialog.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/TreeNodeFilteredItemsSelectionDialog.java index 342ca7ac7..9e4052423 100644 --- a/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/TreeNodeFilteredItemsSelectionDialog.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/TreeNodeFilteredItemsSelectionDialog.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; -import java.util.List; import java.util.Set; import org.eclipse.core.runtime.CoreException; @@ -32,7 +31,6 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AbstractColorFactory.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AbstractColorFactory.java similarity index 94% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AbstractColorFactory.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AbstractColorFactory.java index 5bafc0aa2..512a7b1ec 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AbstractColorFactory.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AbstractColorFactory.java @@ -9,7 +9,7 @@ * Jordan Deyton - Initial API and implementation and/or initial documentation * *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisToolComposite.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AnalysisToolComposite.java similarity index 94% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisToolComposite.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AnalysisToolComposite.java index a60778b58..26490a636 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisToolComposite.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AnalysisToolComposite.java @@ -10,13 +10,12 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StackLayout; @@ -497,15 +496,19 @@ public void setData(String key, Object value) { } // Get the factory for the data object's class. - // FIXME - For the moment, we relegate all Comparison data to the LWR + // FIXME - For the moment, we delegate all Comparison data to the LWR // analysis package. - IAnalysisWidgetFactory factory; - if (dataSource == DataSource.Comparison) { - factory = registry - .getAnalysisWidgetFactory(PressurizedWaterReactor.class); - } else { - factory = registry.getAnalysisWidgetFactory(value.getClass()); - } + + // FIXME! Disabled while we remove the reactor stuff! + + IAnalysisWidgetFactory factory = null; + +// if (dataSource == DataSource.Comparison) { +// factory = registry +// .getAnalysisWidgetFactory(PressurizedWaterReactor.class); +// } else { +// factory = registry.getAnalysisWidgetFactory(value.getClass()); +// } // Make sure the registry has a factory for this data object. if (factory == null) { diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisView.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AnalysisView.java similarity index 96% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisView.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AnalysisView.java index f937c1b7e..82c4576a1 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisView.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AnalysisView.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import java.util.ArrayList; import java.util.HashMap; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisWidgetRegistry.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AnalysisWidgetRegistry.java similarity index 95% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisWidgetRegistry.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AnalysisWidgetRegistry.java index baa0c3ff1..cafe6c6aa 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/AnalysisWidgetRegistry.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/AnalysisWidgetRegistry.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import java.util.HashMap; import java.util.List; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/Circle.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/Circle.java similarity index 98% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/Circle.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/Circle.java index 61b0f9259..cf6f9f9ff 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/Circle.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/Circle.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.Shape; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/DataSource.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/DataSource.java similarity index 93% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/DataSource.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/DataSource.java index 7f0a3539c..76fef2abf 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/DataSource.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/DataSource.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; /** * An enum representing the possible data sources supported by the diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IAnalysisView.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IAnalysisView.java similarity index 95% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IAnalysisView.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IAnalysisView.java index 1bf922630..e8a51a53e 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IAnalysisView.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IAnalysisView.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.swt.widgets.Composite; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IAnalysisWidgetFactory.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IAnalysisWidgetFactory.java similarity index 98% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IAnalysisWidgetFactory.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IAnalysisWidgetFactory.java index 826962ac9..67888ba92 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IAnalysisWidgetFactory.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IAnalysisWidgetFactory.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import java.util.List; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IAnalysisWidgetRegistry.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IAnalysisWidgetRegistry.java similarity index 94% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IAnalysisWidgetRegistry.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IAnalysisWidgetRegistry.java index 6a8bb1d2a..29f6de6f0 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IAnalysisWidgetRegistry.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IAnalysisWidgetRegistry.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; /** * This class provides an interface for an OSGi-DS-based registry. The current diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IColorFactory.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IColorFactory.java similarity index 95% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IColorFactory.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IColorFactory.java index 153e128cf..e5bebff58 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IColorFactory.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IColorFactory.java @@ -9,7 +9,7 @@ * Jordan Deyton - Initial API and implementation and/or initial documentation * *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IStateBrokerHandler.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IStateBrokerHandler.java similarity index 97% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IStateBrokerHandler.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IStateBrokerHandler.java index d84ea43ac..1a9952cde 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IStateBrokerHandler.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IStateBrokerHandler.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; /** * This interface is used to get keys for objects that will be added to a diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IStateListener.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IStateListener.java similarity index 93% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IStateListener.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IStateListener.java index a89d536bc..c43a5be1a 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IStateListener.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IStateListener.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; /** * A class implementing this interface should register with a StateBroker as a diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IWizardProvider.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IWizardProvider.java similarity index 95% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IWizardProvider.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IWizardProvider.java index c6b4f2234..95bbdb021 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/IWizardProvider.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/IWizardProvider.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import org.eclipse.jface.wizard.IWizard; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/LinearColorFactory.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/LinearColorFactory.java similarity index 95% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/LinearColorFactory.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/LinearColorFactory.java index e5252df8d..7be8040fc 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/LinearColorFactory.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/LinearColorFactory.java @@ -9,7 +9,7 @@ * Jordan Deyton - Initial API and implementation and/or initial documentation * *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import java.util.ArrayList; import java.util.List; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/MaterialShape.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/MaterialShape.java similarity index 98% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/MaterialShape.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/MaterialShape.java index 2110369cf..e2c32f074 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/MaterialShape.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/MaterialShape.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.Shape; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/PaletteColorFactory.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/PaletteColorFactory.java similarity index 98% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/PaletteColorFactory.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/PaletteColorFactory.java index 4abedb3f1..3a1a7fbc8 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/PaletteColorFactory.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/PaletteColorFactory.java @@ -10,7 +10,7 @@ * Jordan Deyton - bug 474742 * *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import java.util.Iterator; import java.util.LinkedHashMap; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/SelectionProvider.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/SelectionProvider.java similarity index 95% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/SelectionProvider.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/SelectionProvider.java index 51edf0515..058248405 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/SelectionProvider.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/SelectionProvider.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import org.eclipse.core.runtime.ListenerList; import org.eclipse.jface.viewers.ISelection; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/StateBroker.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/StateBroker.java similarity index 99% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/StateBroker.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/StateBroker.java index 1e8cd18ad..1a9d8fd05 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/StateBroker.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/StateBroker.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import java.util.HashMap; import java.util.HashSet; diff --git a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ToolItemMenuListener.java b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/ToolItemMenuListener.java similarity index 97% rename from org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ToolItemMenuListener.java rename to org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/ToolItemMenuListener.java index 9255319d0..eda005530 100644 --- a/org.eclipse.ice.client.widgets.reactoreditor/src/org/eclipse/ice/client/widgets/reactoreditor/ToolItemMenuListener.java +++ b/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/analysis/ToolItemMenuListener.java @@ -10,7 +10,7 @@ * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, * Claire Saunders, Matthew Wang, Anna Wojtowicz *******************************************************************************/ -package org.eclipse.ice.client.widgets.reactoreditor; +package org.eclipse.ice.client.widgets.analysis; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; diff --git a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/ICEItemRenameParticipant.java b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/ICEItemRenameParticipant.java index a01cee26d..e9abea52f 100644 --- a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/ICEItemRenameParticipant.java +++ b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/ICEItemRenameParticipant.java @@ -15,11 +15,8 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.ITextContentDescriber; import org.eclipse.ice.datastructures.form.FormTextContentDescriber; import org.eclipse.ice.iclient.IClient; diff --git a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/properties/FileComboBoxCellEditor.java b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/properties/FileComboBoxCellEditor.java index 59550fd0f..ea9f6fbaf 100644 --- a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/properties/FileComboBoxCellEditor.java +++ b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/properties/FileComboBoxCellEditor.java @@ -38,7 +38,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; /** diff --git a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportFileWizardPage.java b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportFileWizardPage.java index 30b01cff5..0ae903431 100644 --- a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportFileWizardPage.java +++ b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportFileWizardPage.java @@ -15,15 +15,7 @@ import java.util.ArrayList; import java.util.List; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.ice.client.common.internal.ClientHolder; import org.eclipse.ice.client.internal.Client; -import org.eclipse.ice.iclient.IClient; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -34,7 +26,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.slf4j.Logger; diff --git a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportItemWizard.java b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportItemWizard.java index fe068a73f..2c9b5561c 100644 --- a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportItemWizard.java +++ b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportItemWizard.java @@ -17,7 +17,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.ice.client.common.ImportItemWizardHandler; -import org.eclipse.ice.client.common.internal.ClientHolder; import org.eclipse.ice.iclient.IClient; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.ui.IWorkbenchWindow; diff --git a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportItemWizardPage.java b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportItemWizardPage.java index 56f20f97a..c834323d0 100644 --- a/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportItemWizardPage.java +++ b/org.eclipse.ice.client/src/org/eclipse/ice/client/common/wizards/ImportItemWizardPage.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; diff --git a/org.eclipse.ice.client/src/org/eclipse/ice/client/internal/Client.java b/org.eclipse.ice.client/src/org/eclipse/ice/client/internal/Client.java index 1edf8ae63..7ade258ae 100644 --- a/org.eclipse.ice.client/src/org/eclipse/ice/client/internal/Client.java +++ b/org.eclipse.ice.client/src/org/eclipse/ice/client/internal/Client.java @@ -20,7 +20,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.ice.client.common.internal.ClientHolder; import org.eclipse.ice.core.iCore.ICore; import org.eclipse.ice.datastructures.ICEObject.Identifiable; @@ -38,13 +37,7 @@ import org.eclipse.ice.iclient.uiwidgets.IUpdateEventListener; import org.eclipse.ice.iclient.uiwidgets.IWidgetClosedListener; import org.eclipse.ice.iclient.uiwidgets.IWidgetFactory; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.EditorPart; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; diff --git a/org.eclipse.ice.core.test/src/org/eclipse/ice/core/test/ItemManagerTester.java b/org.eclipse.ice.core.test/src/org/eclipse/ice/core/test/ItemManagerTester.java index 5874c98ec..0096c43cf 100644 --- a/org.eclipse.ice.core.test/src/org/eclipse/ice/core/test/ItemManagerTester.java +++ b/org.eclipse.ice.core.test/src/org/eclipse/ice/core/test/ItemManagerTester.java @@ -20,33 +20,16 @@ import static org.junit.Assert.fail; import java.io.File; -import java.io.InputStream; -import java.io.Reader; import java.net.URI; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFileState; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IPathVariableManager; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResourceProxy; -import org.eclipse.core.resources.IResourceProxyVisitor; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourceAttributes; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.ice.core.internal.itemmanager.ItemManager; import org.eclipse.ice.datastructures.ICEObject.Identifiable; import org.eclipse.ice.datastructures.form.DataComponent; diff --git a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/EntryTester.java b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/EntryTester.java index c744468de..71b1e604f 100644 --- a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/EntryTester.java +++ b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/EntryTester.java @@ -32,8 +32,6 @@ import org.eclipse.ice.datastructures.form.BasicEntryContentProvider; import org.eclipse.ice.datastructures.form.Entry; import org.eclipse.ice.datastructures.form.IEntryContentProvider; -import org.eclipse.ice.viz.service.datastructures.VizAllowedValueType; -import org.eclipse.ice.viz.service.datastructures.VizEntry; import org.junit.Test; /** diff --git a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/GeometryTester.java b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/GeometryTester.java index 191ba67c4..b6cc152d7 100644 --- a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/GeometryTester.java +++ b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/GeometryTester.java @@ -24,12 +24,12 @@ import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; import org.eclipse.ice.datastructures.form.GeometryComponent; +import org.eclipse.ice.datastructures.form.geometry.ICEGeometry; +import org.eclipse.ice.datastructures.form.geometry.ICEShape; import org.eclipse.ice.viz.service.geometry.shapes.Geometry; import org.eclipse.ice.viz.service.geometry.shapes.OperatorType; import org.eclipse.ice.viz.service.geometry.shapes.ShapeType; import org.eclipse.ice.viz.service.geometry.shapes.Transformation; -import org.eclipse.ice.datastructures.form.geometry.ICEGeometry; -import org.eclipse.ice.datastructures.form.geometry.ICEShape; import org.junit.Test; /** diff --git a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/ICEShapeTester.java b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/ICEShapeTester.java index 5fe7214d2..4ad444e34 100644 --- a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/ICEShapeTester.java +++ b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/ICEShapeTester.java @@ -28,7 +28,6 @@ import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; import org.eclipse.ice.datastructures.form.geometry.ICEShape; -import org.eclipse.ice.datastructures.test.TestComponentListener; import org.eclipse.ice.viz.service.geometry.shapes.OperatorType; import org.eclipse.ice.viz.service.geometry.shapes.ShapeType; import org.eclipse.ice.viz.service.geometry.shapes.Transformation; diff --git a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MaterialStackTester.java b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MaterialStackTester.java index ca373e1f2..28dfa4639 100644 --- a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MaterialStackTester.java +++ b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MaterialStackTester.java @@ -11,7 +11,10 @@ *******************************************************************************/ package org.eclipse.ice.datastructures.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -23,7 +26,6 @@ import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; import org.eclipse.ice.datastructures.form.Material; import org.eclipse.ice.datastructures.form.MaterialStack; -import org.junit.BeforeClass; import org.junit.Test; /** diff --git a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MeshComponentTester.java b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MeshComponentTester.java index bd8cc02d6..e942b2c37 100644 --- a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MeshComponentTester.java +++ b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MeshComponentTester.java @@ -26,7 +26,6 @@ import javax.xml.bind.JAXBException; -import org.eclipse.ice.datastructures.ICEObject.Component; import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.viz.service.mesh.datastructures.Edge; diff --git a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/TestVisitor.java b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/TestVisitor.java index 6269fa444..378877c28 100644 --- a/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/TestVisitor.java +++ b/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/TestVisitor.java @@ -21,12 +21,12 @@ import org.eclipse.ice.datastructures.form.MasterDetailsComponent; import org.eclipse.ice.datastructures.form.MatrixComponent; import org.eclipse.ice.datastructures.form.MeshComponent; +import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.form.TableComponent; import org.eclipse.ice.datastructures.form.TimeDataComponent; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.datastructures.form.MeshComponent; /** *

diff --git a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/ICEObject/IUpdateableListener.java b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/ICEObject/IUpdateableListener.java index adce38f1e..de9d834ff 100644 --- a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/ICEObject/IUpdateableListener.java +++ b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/ICEObject/IUpdateableListener.java @@ -14,12 +14,6 @@ import java.util.ArrayList; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlRootElement; - -import org.eclipse.ice.datastructures.form.geometry.ICEShape; - /** *

* The IComponentListener interface specifies the operations that must be diff --git a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/componentVisitor/IComponentVisitor.java b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/componentVisitor/IComponentVisitor.java index 2aa9f6f9f..80bb99935 100644 --- a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/componentVisitor/IComponentVisitor.java +++ b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/componentVisitor/IComponentVisitor.java @@ -19,12 +19,12 @@ import org.eclipse.ice.datastructures.form.MasterDetailsComponent; import org.eclipse.ice.datastructures.form.MatrixComponent; import org.eclipse.ice.datastructures.form.MeshComponent; +import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.form.TableComponent; import org.eclipse.ice.datastructures.form.TimeDataComponent; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.datastructures.form.MeshComponent; /** * This interface defines the "visitation" routines that implementations of diff --git a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/componentVisitor/SelectiveComponentVisitor.java b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/componentVisitor/SelectiveComponentVisitor.java index c37af9dc5..7e38ac666 100644 --- a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/componentVisitor/SelectiveComponentVisitor.java +++ b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/componentVisitor/SelectiveComponentVisitor.java @@ -22,12 +22,12 @@ import org.eclipse.ice.datastructures.form.MasterDetailsComponent; import org.eclipse.ice.datastructures.form.MatrixComponent; import org.eclipse.ice.datastructures.form.MeshComponent; +import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.form.TableComponent; import org.eclipse.ice.datastructures.form.TimeDataComponent; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.datastructures.form.MeshComponent; /** * This adapter class provides default implementations for the methods described diff --git a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/GeometryComponent.java b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/GeometryComponent.java index abca4db72..43bce47f3 100644 --- a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/GeometryComponent.java +++ b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/GeometryComponent.java @@ -18,7 +18,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; diff --git a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/ResourceComponent.java b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/ResourceComponent.java index 41c0c5236..3ede5ca98 100644 --- a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/ResourceComponent.java +++ b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/ResourceComponent.java @@ -12,11 +12,13 @@ *******************************************************************************/ package org.eclipse.ice.datastructures.form; -import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener; -import org.eclipse.ice.datastructures.ICEObject.ListComponent; import java.util.ArrayList; + import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; + +import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener; +import org.eclipse.ice.datastructures.ICEObject.ListComponent; import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; import org.eclipse.ice.datastructures.resource.ICEResource; diff --git a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/TreeComposite.java b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/TreeComposite.java index 0edb471e6..cc111d3b3 100644 --- a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/TreeComposite.java +++ b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/TreeComposite.java @@ -36,7 +36,6 @@ import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.datastructures.form.MeshComponent; /** * The TreeComposite realizes the Composite interface to provide a multi-level diff --git a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/geometry/ICEGeometry.java b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/geometry/ICEGeometry.java index a97a2fad6..94aa666a7 100644 --- a/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/geometry/ICEGeometry.java +++ b/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/geometry/ICEGeometry.java @@ -24,7 +24,6 @@ import org.eclipse.ice.datastructures.ICEObject.IUpdateable; import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener; -import org.eclipse.ice.datastructures.form.GeometryComponent; import org.eclipse.ice.viz.service.geometry.shapes.Geometry; import org.eclipse.ice.viz.service.geometry.shapes.IShape; diff --git a/org.eclipse.ice.developer.moose/src/org/eclipse/ice/developer/moose/actions/MooseCloneHandler.java b/org.eclipse.ice.developer.moose/src/org/eclipse/ice/developer/moose/actions/MooseCloneHandler.java index 516a290cc..8473c80db 100644 --- a/org.eclipse.ice.developer.moose/src/org/eclipse/ice/developer/moose/actions/MooseCloneHandler.java +++ b/org.eclipse.ice.developer.moose/src/org/eclipse/ice/developer/moose/actions/MooseCloneHandler.java @@ -42,8 +42,6 @@ import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject; import org.eclipse.cdt.managedbuilder.ui.wizards.CfgHolder; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; @@ -52,20 +50,11 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; import org.eclipse.egit.core.op.CloneOperation.PostCloneTask; import org.eclipse.ice.developer.actions.GitCloneHandler; import org.eclipse.ice.developer.moose.nature.MooseNature; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jgit.lib.Repository; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.ui.wizards.IWizardDescriptor; /** * This handler triggers the "Clone MOOSE" action. diff --git a/org.eclipse.ice.developer/src/org/eclipse/ice/developer/actions/GitCloneHandler.java b/org.eclipse.ice.developer/src/org/eclipse/ice/developer/actions/GitCloneHandler.java index f91a6b36a..f183b5aa1 100644 --- a/org.eclipse.ice.developer/src/org/eclipse/ice/developer/actions/GitCloneHandler.java +++ b/org.eclipse.ice.developer/src/org/eclipse/ice/developer/actions/GitCloneHandler.java @@ -13,7 +13,6 @@ import java.io.File; import java.lang.reflect.InvocationTargetException; -import java.net.URI; import java.net.URISyntaxException; import java.util.Map; diff --git a/org.eclipse.ice.feature/feature.xml b/org.eclipse.ice.feature/feature.xml index 700988b1c..ad3e1e8f0 100644 --- a/org.eclipse.ice.feature/feature.xml +++ b/org.eclipse.ice.feature/feature.xml @@ -86,912 +86,80 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * This class tests the HdfFileFactory class. - *

- * - * @author Eric J. Lingerfelt - */ -public class HdfFileFactoryTester { - - /** - * The file handle for the test - */ - File dataFile = null; - - /** - *

- * This operation checks the openH5File, createH5File, and closeH5File - * operations. - *

- */ - @Test - public void checkFileOperations() { - - // Local Declarations - String separator = System.getProperty("file.separator"); - String testFileName = "test1.h5"; - H5File h5File; - int fileHandle = -1; - int newFileHandle = -1; - String userDir = System.getProperty("user.home") + separator - + "ICETests"; - - // Creating a file: - - // Try to create a file on null - assertNull(HdfFileFactory.createH5File(null)); - - // Create a normal file - File dataFile = new File(userDir + separator + testFileName); - // Create a file - System.out.println(dataFile.getAbsolutePath()); - h5File = HdfFileFactory.createH5File(dataFile.toURI()); - // Make sure it is not null - assertNotNull(h5File); - - // Make sure it exists and can be written and read from - assertTrue(h5File.exists()); - assertTrue(h5File.canWrite()); - assertTrue(h5File.canRead()); - try { - // Get the first file handle - fileHandle = h5File.open(); - // Make sure the file is open and exists - assertTrue(fileHandle >= 0); - - h5File.createGroup("Bob", - (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject()); - - // Close the file - h5File.close(); - - // create a file ontop of a file - h5File = HdfFileFactory.createH5File(dataFile.toURI()); - // Open it - fileHandle = h5File.open(); - // Make sure the file is open and exists - assertTrue(fileHandle >= 0); - - // Check to see if bob exists - H5Group group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - assertEquals(0, group.getMemberList().size()); // Bob, or any other - // group, does not - // exist - - // Now, add Bob back into the group - h5File.createGroup("Bob", - (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject()); - - // Close the file with the correct operation - HdfFileFactory.closeH5File(h5File); - - // Now, try to open that file again with open - h5File = HdfFileFactory.openH5File(dataFile.toURI()); - - assertNotNull(h5File); - - // Show that it exists - assertTrue(h5File.exists()); - - // Delete the dataFile (close the file first) - h5File.close(); - dataFile.delete(); - // Now, try to grab it. This should return null - assertNull(HdfFileFactory.openH5File(dataFile.toURI())); - - } catch (Exception e) { - // Fail if any exceptions are hit - e.printStackTrace(); - fail(); - } - - // Delete the file - if (dataFile.exists()) { - dataFile.delete(); - } - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfIOFactoryTester.java b/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfIOFactoryTester.java deleted file mode 100644 index dc878082d..000000000 --- a/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfIOFactoryTester.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf.test; - -import static org.junit.Assert.fail; - -import org.eclipse.ice.io.hdf.HdfIOFactory; -import org.eclipse.ice.io.hdf.IHdfIORegistry; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Tests the out-of-the-box writing and reading ability of {@link HdfIOFactory}. - * - * @author Jordan H. Deyton - * - */ -@Ignore -public class HdfIOFactoryTester { - - /** - * This test ensures the factory's reference to the {@link IHdfIORegistry} - * is set properly and can be retreived. - */ - @Test - public void checkRegistry() { - fail("Not implemented."); - } - - /** - * This method checks that, by default, the factory can write to an HDF5 - * file. If object types are not supported (which should be the case since - * OSGi is not running), then the HDF5 file will be empty. - */ - @Test - public void checkWriting() { - fail("Not implemented."); - } - - /** - * This method checks that, by default, the factory can read from an HDF5 - * file. If the tag Attributes do not match any other factory in the - * registry or are non-existent, then the HDF5 Group cannot be read. - */ - @Test - public void checkReading() { - fail("Not implemented."); - } -} diff --git a/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfIORegistryTester.java b/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfIORegistryTester.java deleted file mode 100644 index 571f89d20..000000000 --- a/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfIORegistryTester.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.ice.io.hdf.HdfIOFactory; -import org.eclipse.ice.io.hdf.HdfIORegistry; -import org.eclipse.ice.io.hdf.IHdfIOFactory; -import org.eclipse.ice.io.hdf.IHdfIORegistry; -import org.junit.Test; - -/** - * Tests the {@link HdfIORegistry}'s ability to register and retrieve new - * {@link IHdfIOFactory} instances. - * - * @author Jordan H. Deyton - * - */ -public class HdfIORegistryTester { - - /** - * Reference to the HdfIORegistry to test - */ - private HdfIORegistry registry; - - /** - * Stub classes to act as supported classes for the FakeHdfIOFactory - * - * @author Alex McCaskey - * - */ - private class SupportedOne { - } - - private class SupportedTwo { - } - - /** - * Fake HdfIOFactory to be used in the testing the registration - * functionality of the IHdfIORegistry - * - * @author Alex McCaskey - * - */ - private class FakeHdfIOFactory extends HdfIOFactory { - - private final Map> tagMap = new HashMap>(); - private final Map, String> supportedMap = new HashMap, String>(); - - FakeHdfIOFactory() { - tagMap.put("tag1", SupportedOne.class); - tagMap.put("tag2", SupportedTwo.class); - supportedMap.put(SupportedOne.class, "tag1"); - supportedMap.put(SupportedTwo.class, "tag2"); - } - - @Override - public List> getSupportedClasses() { - return new ArrayList>(tagMap.values()); - } - - @Override - public String getTag(Class supportedClass) { - return supportedMap.get(supportedClass); - } - - } - - /** - * Checks that {@link IHdfIOFactory} instances can register with the - * registry and be queried via - * {@link IHdfIORegistry#getHdfIOFactory(Object)} and - * {@link IHdfIORegistry#getHdfIOFactory(String)}. - */ - @Test - public void checkRegistration() { - - // Create a new HdfIORegistry to test - registry = new HdfIORegistry(); - - // Create a Fake Factory to register with the - // HdfIORegistry - FakeHdfIOFactory factory = new FakeHdfIOFactory(); - - // Register that FakeHdfIOFactory - registry.registerHdfIOFactory(factory); - - // Test that it was registered correctly - IHdfIOFactory hdfIOFactory = registry - .getHdfIOFactory(new SupportedOne()); - assertNotNull(hdfIOFactory); - assertEquals(factory, hdfIOFactory); - - hdfIOFactory = registry.getHdfIOFactory(new SupportedTwo()); - assertNotNull(hdfIOFactory); - assertEquals(factory, hdfIOFactory); - - // Check an unsupported class and make sure it - // returns null - hdfIOFactory = registry.getHdfIOFactory(new Object()); - assertNull(hdfIOFactory); - - // Now make sure we can get the factory from tags - hdfIOFactory = registry.getHdfIOFactory("tag1"); - assertNotNull(hdfIOFactory); - assertEquals(factory, hdfIOFactory); - - hdfIOFactory = registry.getHdfIOFactory("tag2"); - assertNotNull(hdfIOFactory); - assertEquals(factory, hdfIOFactory); - - // Test an invalid tag and make sure it returns null - hdfIOFactory = registry.getHdfIOFactory("tag3"); - assertNull(hdfIOFactory); - - } - -} diff --git a/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfReaderFactoryTester.java b/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfReaderFactoryTester.java deleted file mode 100644 index 9c5ba663e..000000000 --- a/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfReaderFactoryTester.java +++ /dev/null @@ -1,464 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Dataset; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5Datatype; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -/** - * This class tests the HdfReaderFactory class. - * - * @author Eric J. Lingerfelt - */ -public class HdfReaderFactoryTester { - - /** - * The data file that will be used for testing purposes. This reference is - * created before each test, and, if the file exists, is deleted after each - * test. - */ - private File dataFile; - /** - * The HDF5 file handle for the {@link #dataFile}. This is set to null - * before each test. If it is left open, it is closed after each test. - */ - private H5File h5File; - - /** - * Initializes {@link #dataFile} and clears {@link #h5File}. - */ - @Before - public void beforeEachTest() { - // Create a reference to the test file. - String separator = System.getProperty("file.separator"); - String testFileName = "hdfReaderFactoryFile.h5"; - String userDir = System.getProperty("user.home") + separator - + "ICETests"; - dataFile = new File(userDir + separator + testFileName); - - // Clear the HDF5 file reference. - h5File = null; - } - - /** - * If possible, closes {@link #h5File} and deletes {@link #dataFile}. - */ - @After - public void afterEachTest() { - - // If necessary, close the HDF5 file. This closes any open streams. - if (h5File != null) { - try { - h5File.close(); - } catch (HDF5Exception e) { - e.printStackTrace(); - } - h5File = null; - } - - // If possible, delete the test file. - if (dataFile.exists()) { - dataFile.delete(); - } - dataFile = null; - - return; - } - - /** - * This operation checks the getChildH5Group, getChildH5Groups, and - * getDataset operations. - */ - @Test - public void checkGetters() { - - // Local declarations - URI uri = dataFile.toURI(); - String subGroupName = "Bob"; - H5Group subH5Group = null; - ArrayList rows = new ArrayList(); - int maxRowSize = 0; - String rowName = "Rows"; - - // Setup ArrayList of Rows - rows.add("ABBA"); - rows.add("BABBA"); - rows.add("CABBA"); - rows.add("DabbbyDabbyDooo!"); - rows.add("E"); - - // Setup the string array - String[] rowArray = new String[rows.size()]; - - // Figure out the biggest row size and add to array - for (int i = 0; i < rows.size(); i++) { - maxRowSize = Math.max(maxRowSize, rows.get(i).length()); - // Add to array - rowArray[i] = rows.get(i); - } - - // Create a good H5File - h5File = HdfFileFactory.createH5File(uri); - assertNotNull(h5File); - - // Open file and setup H5 File to have a parent and child. Check get - // Readers and get Datasets - try { - h5File.open(); - // Setup the H5 File to have a Parent and child - // Get the parent group - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Test to see if a getChild returns null - group does not exist - assertNull(HdfReaderFactory.getChildH5Group(parentH5Group, - subGroupName)); - - // Null Checks - assertNull(HdfReaderFactory.getChildH5Group(null, subGroupName)); - assertNull(HdfReaderFactory.getChildH5Group(parentH5Group, null)); - assertNull(HdfReaderFactory.getChildH5Group(null, null)); - - // Add a group to the root group - h5File.createGroup(subGroupName, parentH5Group); - - // Persist data - h5File.close(); - h5File.open(); - - // Get the parent - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check to see it exists with the group grabber - subH5Group = HdfReaderFactory.getChildH5Group(parentH5Group, - subGroupName); - - // Check the subH5Groups name to make sure that it does exist and - // has the correct name - assertNotNull(subH5Group); - assertTrue(subGroupName.equals(subH5Group.getName())); - - // Check getDatasets - - // Check invalid usage of getting dataset that does not exist - assertNull(HdfReaderFactory.getDataset(subH5Group, rowName)); - - // Nullary checks for dataSet - assertNull(HdfReaderFactory.getDataset(null, rowName)); - assertNull(HdfReaderFactory.getDataset(subH5Group, null)); - assertNull(HdfReaderFactory.getDataset(null, null)); - - // Add a Dataset to the subH5Group - - // Create datatypes for the row and column labels - H5Datatype rowH5Datatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, maxRowSize, Datatype.NATIVE, - Datatype.NATIVE); - long[] dims = { rows.size() }; - - // Add array to dataset and add dataset ot the subgroup - Dataset h5RowDataset = h5File.createScalarDS(rowName, subH5Group, - rowH5Datatype, dims, null, null, 0, null); - h5RowDataset.write(rowArray); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - subH5Group = (H5Group) parentH5Group.getMemberList().get(0); - - // Now, check to see if you can get it! - Dataset data = HdfReaderFactory.getDataset(subH5Group, rowName); - // Make sure it is not null - assertNotNull(data); - - // Check information on dataset - assertEquals(1, subH5Group.getMemberList().size()); - // Check the value of that dataset - assertEquals(rowName, subH5Group.getMemberList().get(0).getName()); - // Check labels that they are not a group - assertFalse(subH5Group.getMemberList().get(0) instanceof Group); - - // Check DataSet information - - // Check the rowData - Object rowData = data.getData(); - - // Iterate over the list and check the arrayLists - for (int i = 0; i < rows.size(); i++) { - // Check contents of rowData at X - assertEquals(rows.get(i), ((String[]) rowData)[i]); - } - - // Check the getter for index - // Check nullaries - assertNull(HdfReaderFactory.getChildH5Group(null, 0)); - assertNull(HdfReaderFactory.getChildH5Group(parentH5Group, -1)); - assertNull(HdfReaderFactory.getChildH5Group(null, -1)); - // Check invalid index - out of bounds - assertNull(HdfReaderFactory.getChildH5Group(parentH5Group, 1)); - - // Check valid usage - subH5Group = HdfReaderFactory.getChildH5Group(parentH5Group, 0); - - // Check the subH5Groups name to make sure that it does exist and - // has the correct name - assertNotNull(subH5Group); - assertEquals(subGroupName, subH5Group.getName()); - - // Try to grab the group as a dataset - should throw a class cast - // exception - assertNull( - HdfReaderFactory.getDataset(parentH5Group, subGroupName)); - - // Try to grab the dataset as a group - should throw a class cast - // exception - assertNull(HdfReaderFactory.getChildH5Group(subH5Group, rowName)); - assertNull(HdfReaderFactory.getChildH5Group(subH5Group, 0)); - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - return; - } - - /** - * This operation checks the readDoubleAttribute, readStringAttribute, and - * readIntegerAttribute operations. - */ - @Test - public void checkReaders() { - - // Local declarations - URI uri = dataFile.toURI(); - String integerName = "Integer1"; - String doubleName = "Double1"; - String stringName = "String1"; - int intValue = 3; - double doubleValue = 5.67656565343; - String stringValue = "Bobby Lee Jones"; - String childGroupName = "new Group"; - - // Create a good H5File - h5File = HdfFileFactory.createH5File(uri); - assertNotNull(h5File); - - // Open file and setup H5 File to have a parent and child. Check get - // Readers and get Datasets - try { - h5File.open(); - // Setup the H5 File to have a Parent and child - // Get the parent group - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check nullary reader operations - - // Check nullary and invalid values for Integer read - assertNull(HdfReaderFactory.readIntegerAttribute(parentH5Group, - integerName)); - assertNull( - HdfReaderFactory.readIntegerAttribute(null, integerName)); - assertNull( - HdfReaderFactory.readIntegerAttribute(parentH5Group, null)); - assertNull(HdfReaderFactory.readIntegerAttribute(null, null)); - - // Check nullary and invalid values for Double read - assertNull(HdfReaderFactory.readDoubleAttribute(parentH5Group, - doubleName)); - assertNull(HdfReaderFactory.readDoubleAttribute(null, doubleName)); - assertNull( - HdfReaderFactory.readDoubleAttribute(parentH5Group, null)); - assertNull(HdfReaderFactory.readDoubleAttribute(null, null)); - - // Check nullary and invalid values for String read - assertNull(HdfReaderFactory.readStringAttribute(parentH5Group, - stringName)); - assertNull(HdfReaderFactory.readStringAttribute(null, stringName)); - assertNull( - HdfReaderFactory.readStringAttribute(parentH5Group, null)); - assertNull(HdfReaderFactory.readStringAttribute(null, null)); - - // Add a Integer, a Double, and a String to the parentGroup - - // Setup dataTypes for Integer, Double, and a String - - // Integer Datatype - // Create the integer datatype - H5Datatype intDatatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_INTEGER, Datatype.NATIVE, Datatype.NATIVE, - Datatype.NATIVE); - - // Double (float) Datatype - // Create the float datatype - H5Datatype doubleDatatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_FLOAT, 8, Datatype.NATIVE, Datatype.NATIVE); - - // String Datatype - // Create a custom String data type for the value - H5Datatype stringDatatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, stringValue.length(), - Datatype.NATIVE, Datatype.NATIVE); - - // Add a Integer - long[] intDims = { 1 }; - int[] intValues = { intValue }; - // Create an attribute object - Attribute intAttribute = new Attribute(integerName, intDatatype, - intDims, intValues); - // Write the attribute - parentH5Group.writeMetadata(intAttribute); - - // Add a Double - long[] doubleDims = { 1 }; - double[] doubleValues = { doubleValue }; - // Create an attribute object - Attribute doubleAttribute = new Attribute(doubleName, - doubleDatatype, doubleDims, doubleValues); - // Write the attribute - parentH5Group.writeMetadata(doubleAttribute); - - // Add a String - String[] stringValues = new String[1]; - stringValues[0] = stringValue; - // Create a byte array from values using the stringToByte method - // See - // http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/2011-March/004509.html - byte[] bvalue = Dataset.stringToByte(stringValues, - stringValue.length()); - // Create an attribute object - Attribute stringAttribute = new Attribute(stringName, - stringDatatype, new long[] { 1 }); - // Set the value of the attribute to bvalue - stringAttribute.setValue(bvalue); - // Write the attribute to the group's metadata - parentH5Group.writeMetadata(stringAttribute); - - h5File.close(); - - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Now, time to read those values! - assertEquals(intValue, - HdfReaderFactory - .readIntegerAttribute(parentH5Group, integerName) - .intValue()); - assertEquals(doubleValue, - HdfReaderFactory - .readDoubleAttribute(parentH5Group, doubleName) - .doubleValue(), - 0.0); - assertEquals(stringValue, HdfReaderFactory - .readStringAttribute(parentH5Group, stringName)); - - // Checking for child groups. - assertNotNull(HdfReaderFactory.getChildH5Groups(parentH5Group)); - assertEquals(0, - HdfReaderFactory.getChildH5Groups(parentH5Group).size()); - - // Check for child objects. - assertNotNull(HdfReaderFactory.getChildH5Members(parentH5Group)); - assertEquals(0, - HdfReaderFactory.getChildH5Members(parentH5Group).size()); - - // Lets add something to the group - H5Group h5Group = (H5Group) h5File.createGroup(childGroupName, - parentH5Group); - // Add an attribute to the group - // Add a Integer - h5Group.writeMetadata(intAttribute); - assertNotNull(h5Group); - - // Add a dataset (100x50 integer array) to the parent group. - String datasetName = "2D integer"; - Datatype dtype = new H5Datatype(Datatype.CLASS_INTEGER, 4, - Datatype.ORDER_LE, Datatype.SIGN_NONE); - long[] dims = { 100, 50 }; - long[] maxdims = dims; - long[] chunks = null; - int gzip = 0; - Object data = null; - h5File.createScalarDS(datasetName, parentH5Group, dtype, dims, - maxdims, chunks, gzip, data); - - // Close to persist the data and reopen, get the new parenth5Group - // object - h5File.close(); - - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check for children now. There should only be one child group. - assertNotNull(HdfReaderFactory.getChildH5Groups(parentH5Group)); - assertEquals(1, - HdfReaderFactory.getChildH5Groups(parentH5Group).size()); - assertEquals(childGroupName, HdfReaderFactory - .getChildH5Groups(parentH5Group).get(0).getName()); - - // Check for child objects. There should be two (a group and a - // dataset). - assertNotNull(HdfReaderFactory.getChildH5Members(parentH5Group)); - assertEquals(2, - HdfReaderFactory.getChildH5Members(parentH5Group).size()); - assertEquals(childGroupName, HdfReaderFactory - .getChildH5Members(parentH5Group).get(1).getName()); - assertEquals(datasetName, HdfReaderFactory - .getChildH5Members(parentH5Group).get(0).getName()); - - } catch (Exception e) { - // Fail out of the test, not supposed to happen - e.printStackTrace(); - fail(); - } - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfWriterFactoryTester.java b/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfWriterFactoryTester.java deleted file mode 100644 index 9c5830950..000000000 --- a/org.eclipse.ice.io.test/src/org/eclipse/ice/io/hdf/test/HdfWriterFactoryTester.java +++ /dev/null @@ -1,362 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Dataset; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.HObject; -import ncsa.hdf.object.h5.H5Datatype; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -/** - * This class tests the HdfWriterFactory class. - * - * @author Eric J. Lingerfelt - */ -public class HdfWriterFactoryTester { - - /** - * The data file that will be used for testing purposes. This reference is - * created before each test, and, if the file exists, is deleted after each - * test. - */ - private File dataFile; - /** - * The HDF5 file handle for the {@link #dataFile}. This is set to null - * before each test. If it is left open, it is closed after each test. - */ - private H5File h5File; - - /** - * Initializes {@link #dataFile} and clears {@link #h5File}. - */ - @Before - public void beforeEachTest() { - // Create a reference to the test file. - String separator = System.getProperty("file.separator"); - String testFileName = "hdfWriterFactoryFile.h5"; - String userDir = System.getProperty("user.home") + separator - + "ICETests"; - dataFile = new File(userDir + separator + testFileName); - - // Clear the HDF5 file reference. - h5File = null; - } - - /** - * If possible, closes {@link #h5File} and deletes {@link #dataFile}. - */ - @After - public void afterEachTest() { - - // If necessary, close the HDF5 file. This closes any open streams. - if (h5File != null) { - try { - h5File.close(); - } catch (HDF5Exception e) { - e.printStackTrace(); - } - h5File = null; - } - - // If possible, delete the test file. - if (dataFile.exists()) { - dataFile.delete(); - } - dataFile = null; - - return; - } - - /** - * This operation checks the createFloatDatatype, createH5Group, and - * createIntegerH5Datatype operations. - */ - @Test - public void checkCreators() { - // Local declarations - URI uri = dataFile.toURI(); - - // Create a bad H5File - h5File = HdfFileFactory.createH5File(null); - assertNull(h5File); - - // Create a good H5File - h5File = HdfFileFactory.createH5File(uri); - assertNotNull(h5File); - - // Create a bad Reactor group - H5Group reactorGroup = HdfWriterFactory.createH5Group(null, null, null); - assertNull(reactorGroup); - - // Create a bad Reactor group - reactorGroup = HdfWriterFactory.createH5Group(h5File, null, null); - assertNull(reactorGroup); - - // Create a bad Reactor group - reactorGroup = HdfWriterFactory.createH5Group(h5File, "", null); - assertNull(reactorGroup); - - // Get the root group - H5Group rootH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Create a good Reactor group - reactorGroup = HdfWriterFactory.createH5Group(h5File, "Reactor", - rootH5Group); - assertNotNull(reactorGroup); - - try { - - // Get the HObject at the given path - HObject hObject = h5File.get("/Reactor"); - - // Check that its not null and an instance of H5Group - assertNotNull(hObject); - assertTrue(hObject instanceof H5Group); - - // Cast the H5Object to an H5Group and check its name - H5Group tempGroup = (H5Group) hObject; - assertTrue("Reactor".equals(tempGroup.getName())); - - } catch (Exception e) { - - // Print the stack trace - e.printStackTrace(); - - // Fail the test - fail(); - } - - // Create a bad Geometry group under the Reactor Group - H5Group geometryGroup = HdfWriterFactory.createH5Group(null, "", - reactorGroup); - assertNull(geometryGroup); - - // Create a bad Geometry group under the Reactor Group - geometryGroup = HdfWriterFactory.createH5Group(null, "Geometry", - reactorGroup); - assertNull(geometryGroup); - - // Create a good Geometry group under the Reactor Group - geometryGroup = HdfWriterFactory.createH5Group(h5File, "Geometry", - reactorGroup); - assertNotNull(geometryGroup); - - try { - - // Get the HObject at the given path - HObject hObject = h5File.get("/Reactor/Geometry"); - - // Check that its not null and an instance of H5Group - assertNotNull(hObject); - assertTrue(hObject instanceof H5Group); - - // Cast the H5Object to an H5Group and check its name - H5Group tempGroup = (H5Group) hObject; - assertTrue("Geometry".equals(tempGroup.getName())); - - } catch (Exception e) { - - // Print the stack trace - e.printStackTrace(); - - // Fail the test - fail(); - } - - // Create a bad integer datatype - H5Datatype integerDatatype = HdfWriterFactory - .createIntegerH5Datatype(null); - assertNull(integerDatatype); - - // Create a good integer datatype - integerDatatype = HdfWriterFactory.createIntegerH5Datatype(h5File); - assertNotNull(integerDatatype); - assertEquals(integerDatatype.getDatatypeClass(), - H5Datatype.CLASS_INTEGER); - - // Create a bad float datatype - H5Datatype floatDatatype = HdfWriterFactory.createFloatH5Datatype(null); - assertNull(floatDatatype); - - // Create a good float datatype - floatDatatype = HdfWriterFactory.createFloatH5Datatype(h5File); - assertNotNull(floatDatatype); - assertEquals(floatDatatype.getDatatypeClass(), H5Datatype.CLASS_FLOAT); - - return; - } - - /** - * This operation checks the writeDoubleAttribute, writeStringAttribute, and - * writeIntegerAttribute operations. - */ - @Test - public void checkWriters() { - // Local declarations - URI uri = dataFile.toURI(); - boolean flag = true; - double number = 0.12345678912345; - - // Create a good H5File - h5File = HdfFileFactory.createH5File(uri); - - H5Group rootH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Create a good Reactor group - H5Group reactorGroup = HdfWriterFactory.createH5Group(h5File, "Reactor", - rootH5Group); - assertNotNull(reactorGroup); - - // Write some double attributes with bad arguments - flag = HdfWriterFactory.writeDoubleAttribute(null, null, null, number); - assertFalse(flag); - - flag = HdfWriterFactory.writeDoubleAttribute(h5File, null, null, - number); - assertFalse(flag); - - flag = HdfWriterFactory.writeDoubleAttribute(h5File, reactorGroup, null, - number); - assertFalse(flag); - - // Write a double attribute with good arguments - flag = HdfWriterFactory.writeDoubleAttribute(h5File, reactorGroup, - "double value", number); - assertTrue(true); - - try { - - // Check to see if the attribute was actually written - Attribute attribute = (Attribute) reactorGroup.getMetadata().get(0); - assertEquals(attribute.getName(), "double value"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(((double[]) attribute.getValue())[0], number, 0.0); - - } catch (Exception e) { - - // Print the stack trace - e.printStackTrace(); - - // Fail the test - fail(); - } - - // Write some integer attributes with bad arguments - flag = HdfWriterFactory.writeIntegerAttribute(null, null, null, 5); - assertFalse(flag); - - flag = HdfWriterFactory.writeIntegerAttribute(h5File, null, null, 5); - assertFalse(flag); - - flag = HdfWriterFactory.writeIntegerAttribute(h5File, reactorGroup, - null, 5); - assertFalse(flag); - - // Write a integer attribute with good arguments - flag = HdfWriterFactory.writeIntegerAttribute(h5File, reactorGroup, - "integer value", 5); - assertTrue(true); - - try { - - // Check to see if the attribute was actually written - Attribute attribute = (Attribute) reactorGroup.getMetadata().get(1); - assertEquals(attribute.getName(), "integer value"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(((int[]) attribute.getValue())[0], 5); - - } catch (Exception e) { - - // Print the stack trace - e.printStackTrace(); - - // Fail the test - fail(); - } - - // Write some string attributes with bad arguments - flag = HdfWriterFactory.writeStringAttribute(null, null, null, null); - assertFalse(flag); - - flag = HdfWriterFactory.writeStringAttribute(h5File, null, null, null); - assertFalse(flag); - - flag = HdfWriterFactory.writeStringAttribute(h5File, reactorGroup, null, - null); - assertFalse(flag); - - flag = HdfWriterFactory.writeStringAttribute(h5File, reactorGroup, "", - null); - assertFalse(flag); - - flag = HdfWriterFactory.writeStringAttribute(h5File, reactorGroup, "", - ""); - assertFalse(flag); - - flag = HdfWriterFactory.writeStringAttribute(h5File, reactorGroup, - "string value", ""); - assertFalse(flag); - - // Write a string attribute with good arguments - flag = HdfWriterFactory.writeStringAttribute(h5File, reactorGroup, - "string value", "USS Defiant"); - assertTrue(flag); - - try { - - // Check to see if the attribute was actually written - Attribute attribute = (Attribute) reactorGroup.getMetadata().get(2); - assertEquals(attribute.getName(), "string value"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - String attributeValue = Dataset.byteToString( - (byte[]) attribute.getValue(), - ((byte[]) attribute.getValue()).length)[0]; - assertEquals(attributeValue, "USS Defiant"); - - } catch (Exception e) { - - // Print the stack trace - e.printStackTrace(); - - // Fail the test - fail(); - } - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.io/.classpath b/org.eclipse.ice.io/.classpath index 039123375..098194ca4 100644 --- a/org.eclipse.ice.io/.classpath +++ b/org.eclipse.ice.io/.classpath @@ -1,10 +1,5 @@ - - - - - diff --git a/org.eclipse.ice.io/META-INF/MANIFEST.MF b/org.eclipse.ice.io/META-INF/MANIFEST.MF index cd3a00ef5..367e18ed8 100644 --- a/org.eclipse.ice.io/META-INF/MANIFEST.MF +++ b/org.eclipse.ice.io/META-INF/MANIFEST.MF @@ -4,29 +4,13 @@ Bundle-Name: org.eclipse.ice.io Bundle-SymbolicName: org.eclipse.ice.io;singleton:=true Bundle-Version: 2.1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-ClassPath: ., - deps/jhdf.jar, - deps/jhdf4obj.jar, - deps/jhdf5.jar, - deps/jhdf5obj.jar, - deps/jhdfobj.jar +Bundle-ClassPath: . Require-Bundle: org.eclipse.ice.datastructures, org.eclipse.ice.dependencies;bundle-version="2.0.0";visibility:=reexport Service-Component: OSGI-INF/HdfIORegistry.xml,OSGI-INF/HdfIOFactory.xml, OSGI-INF/ioservice.xml Comment: Service-Component: OSGI-INF/ICEDatabaseHarness.xml -Export-Package: ncsa.hdf.hdf5lib, - ncsa.hdf.hdf5lib.callbacks, - ncsa.hdf.hdf5lib.exceptions, - ncsa.hdf.hdf5lib.structs, - ncsa.hdf.hdflib, - ncsa.hdf.object, - ncsa.hdf.object.fits, - ncsa.hdf.object.h4, - ncsa.hdf.object.h5, - ncsa.hdf.object.nc2, - org.eclipse.ice.io.csv, - org.eclipse.ice.io.hdf, +Export-Package: org.eclipse.ice.io.csv, org.eclipse.ice.io.ini, org.eclipse.ice.io.ips, org.eclipse.ice.io.serializable diff --git a/org.eclipse.ice.io/build.properties b/org.eclipse.ice.io/build.properties index 499ea41ad..8d9fed03f 100644 --- a/org.eclipse.ice.io/build.properties +++ b/org.eclipse.ice.io/build.properties @@ -7,11 +7,6 @@ bin.includes = META-INF/,\ OSGI-INF/HdfIORegistry.xml,\ OSGI-INF/HdfIOFactory.xml,\ OSGI-INF/ioservice.xml,\ - deps/jhdf.jar,\ - deps/jhdf4obj.jar,\ - deps/jhdf5.jar,\ - deps/jhdf5obj.jar,\ - deps/jhdfobj.jar,\ deps/lib/linux/x86_64,\ plugin.xml src.includes = src/,\ diff --git a/org.eclipse.ice.io/deps/jhdf.jar b/org.eclipse.ice.io/deps/jhdf.jar deleted file mode 100644 index 9716445d7..000000000 Binary files a/org.eclipse.ice.io/deps/jhdf.jar and /dev/null differ diff --git a/org.eclipse.ice.io/deps/jhdf4obj.jar b/org.eclipse.ice.io/deps/jhdf4obj.jar deleted file mode 100644 index eef1ce876..000000000 Binary files a/org.eclipse.ice.io/deps/jhdf4obj.jar and /dev/null differ diff --git a/org.eclipse.ice.io/deps/jhdf5.jar b/org.eclipse.ice.io/deps/jhdf5.jar deleted file mode 100644 index 6765c8770..000000000 Binary files a/org.eclipse.ice.io/deps/jhdf5.jar and /dev/null differ diff --git a/org.eclipse.ice.io/deps/jhdf5obj.jar b/org.eclipse.ice.io/deps/jhdf5obj.jar deleted file mode 100644 index 9092b67e3..000000000 Binary files a/org.eclipse.ice.io/deps/jhdf5obj.jar and /dev/null differ diff --git a/org.eclipse.ice.io/deps/jhdfobj.jar b/org.eclipse.ice.io/deps/jhdfobj.jar deleted file mode 100644 index 99619360f..000000000 Binary files a/org.eclipse.ice.io/deps/jhdfobj.jar and /dev/null differ diff --git a/org.eclipse.ice.io/deps/lib/linux/x86_64/libhdf.a b/org.eclipse.ice.io/deps/lib/linux/x86_64/libhdf.a deleted file mode 100644 index 87cdc6596..000000000 Binary files a/org.eclipse.ice.io/deps/lib/linux/x86_64/libhdf.a and /dev/null differ diff --git a/org.eclipse.ice.io/deps/lib/linux/x86_64/libhdf5.a b/org.eclipse.ice.io/deps/lib/linux/x86_64/libhdf5.a deleted file mode 100644 index 867ae49eb..000000000 Binary files a/org.eclipse.ice.io/deps/lib/linux/x86_64/libhdf5.a and /dev/null differ diff --git a/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf.so b/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf.so deleted file mode 100755 index 0c08fb560..000000000 Binary files a/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf.so and /dev/null differ diff --git a/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf.so.2.10.0 b/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf.so.2.10.0 deleted file mode 100755 index 0c08fb560..000000000 Binary files a/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf.so.2.10.0 and /dev/null differ diff --git a/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf5.so b/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf5.so deleted file mode 100755 index 2cc4200f7..000000000 Binary files a/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf5.so and /dev/null differ diff --git a/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf5.so.2.10.0 b/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf5.so.2.10.0 deleted file mode 100755 index 2cc4200f7..000000000 Binary files a/org.eclipse.ice.io/deps/lib/linux/x86_64/libjhdf5.so.2.10.0 and /dev/null differ diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfFileFactory.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfFileFactory.java deleted file mode 100644 index 4308e82fd..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfFileFactory.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import java.io.File; -import java.net.URI; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; -import ncsa.hdf.object.FileFormat; -import ncsa.hdf.object.h5.H5File; - -/** - *

- * The HDFFileFactory class contains static methods used to create, open, and - * close HDF5 files. - *

- * - * @author Eric J. Lingerfelt - */ -public class HdfFileFactory { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(HdfFileFactory.class); - - /** - *

- * Creates, opens, and returns an H5File from the provided uri. If the uri - * is null, the null is returned. If the FID of resulting h5File is -1, then - * null is returned. If any Exception is thrown, then null is returned. - *

- * - * @param uri - *

- * The URI of the H5File to create and open. - *

- * @return - *

- * An H5File that has been created and opened for read/write - * operations. - *

- */ - public static H5File createH5File(URI uri) { - - // If parameter is null, return null - if (uri == null) { - return null; - } - - // Retrieve an instance of the HDF5 format - FileFormat fileFormat = FileFormat - .getFileFormat(FileFormat.FILE_TYPE_HDF5); - - try { - - // Create a file from the uri - File file = new File(uri); - - // Create an H5 file. If it exists already, then delete it. - H5File h5File = (H5File) fileFormat.createFile(file.getPath(), - FileFormat.FILE_CREATE_DELETE); - - // We must get an instance to the file and set the format to write - h5File = (H5File) fileFormat.createInstance(file.getPath(), - FileFormat.WRITE); - - // Open the file - h5File.open(); - - // If the file id of the h5File is -1, return null - if (h5File.getFID() == -1) { - - return null; - - } - - // Return the file - return h5File; - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfFileFactory Exception!", e); - - // Return null - return null; - - } - - } - - /** - *

- * Closes an h5File. - *

- * - * @param h5File - *

- * The H5File to close. - *

- */ - public static void closeH5File(H5File h5File) { - - try { - - // If the file is not null - if (h5File != null) { - - // Close the file - h5File.close(); - - } - - } catch (HDF5Exception e) { - - // Print the stack trace - logger.error("HdfFileFactory Exception!", e); - } - - } - - /** - *

- * Opens and returns an h5File from the provided URI. If the uri is null, - * the null is returned. If the File for uri does not exist, then null is - * returned. If the resulting h5File is null or does not exist, then null is - * returned. If any Exception is thrown, then null is returned. - *

- * - * @param uri - *

- * The URI of the H5File to open. - *

- * @return - *

- * An H5File that has been opened for read/write operations. - *

- */ - public static H5File openH5File(URI uri) { - - // If parameter is null or does not exist, return null - if (uri == null || !(new File(uri).exists())) { - return null; - } - - // Retrieve an instance of the HDF5 format - FileFormat fileFormat = FileFormat - .getFileFormat(FileFormat.FILE_TYPE_HDF5); - - try { - - // Create a file from the uri - File file = new File(uri); - - // Open a h5File - H5File h5File = (H5File) fileFormat.createInstance(file.getPath(), - FileFormat.WRITE); - - // If the h5File does not exist, then return null - if (h5File == null || !h5File.exists()) { - return null; - } - - // Open the file - h5File.open(); - - // If the file id of the h5File is -1, return null - if (h5File.getFID() == -1) { - - return null; - - } - - // Return the file - return h5File; - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfFileFactory Exception!", e); - - // Return null - return null; - - } - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfIOFactory.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfIOFactory.java deleted file mode 100644 index e8fe85493..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfIOFactory.java +++ /dev/null @@ -1,1036 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import ncsa.hdf.hdf5lib.H5; -import ncsa.hdf.hdf5lib.HDF5Constants; -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; -import ncsa.hdf.hdf5lib.exceptions.HDF5LibraryException; -import ncsa.hdf.hdf5lib.structs.H5O_info_t; - -import org.eclipse.ice.datastructures.ICEObject.ICEObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - *

- * This class provides a base for implementing {@link IHdfIOFactory} and - * includes many helpful methods for writing and reading HDF5 attributes, - * datasets, groups, and more. - *

- *

- * Sub-classes must override the following methods (no calls to - * the super method necessary): - *

    - *
  • {@link #getSupportedClasses()} - *
  • {@link #getTag(Class)} - *
  • {@link #read(int, String)} - *
  • {@link #writeObjectData(int, Object)} - *
- * Note that this class cannot be abstract because it references an OSGi service - * so that sub-classes have easy access to the {@link IHdfIORegistry} - * implementation. - *

- * - * @author Jordan H. Deyton - * - */ -public class HdfIOFactory implements IHdfIOFactory { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(HdfIOFactory.class); - - /** - * The default rank of an attribute. This means an attribute is a 1D array. - */ - private static final int attributeRank = 1; - /** - * The default data dimension array for all attributes. This just means that - * an attribute is a 1D array with 1 element. - */ - private static final long[] attributeDims = new long[] { 1 }; - /** - * A buffer that contains a single double value. Helps avoid having to - * create a new double array for double attributes. - */ - private static final Double[] doubleAttributeBuffer = new Double[1]; - /** - * A buffer that contains a single integer value. Helps avoid having to - * create a new integer array for integer attributes. - */ - private static final Integer[] integerAttributeBuffer = new Integer[1]; - - /** - * The IHdfIORegistry implementation that is running as an OSGi Declarative - * Service. - */ - private static IHdfIORegistry hdfIORegistry = null; - - // ---- Methods that sub-classes MUST override! ---- // - /** - * Sub-classes must override this method. - */ - @Override - public List> getSupportedClasses() { - return new ArrayList>(); - } - - /** - * Sub-classes must override this method. - */ - @Override - public String getTag(Class supportedClass) { - return null; - } - - /** - * Sub-classes must override this method. - */ - @Override - public Object read(int groupId, String tag) throws NullPointerException, - HDF5Exception, HDF5LibraryException { - return null; - } - - /** - * Sub-classes must override this method. Fills out an HDF5 Group - * with information regarding the specified object. - * - * @param groupId - * The group for the object. - * @param object - * The object whose information is being written to the group. - */ - public void writeObjectData(int groupId, Object object) - throws NullPointerException, HDF5Exception, HDF5LibraryException { - return; - } - - // ------------------------------------------------- // - - // ---- HdfIORegistry operations. ---- // - /** - * Sets the {@link IHdfIORegistry} implementation that is running as an OSGi - * Declarative Service. - */ - public static void setHdfIORegistry(IHdfIORegistry registry) { - if (registry != null) { - hdfIORegistry = registry; - logger.info("HdfIOFactory message: " + "Registry set successfully!"); - } else { - logger.info("HdfIOFactory message: " - + "Failed to set the registry."); - } - - return; - } - - /** - * Unsets the {@link IHdfIORegistry} implementation. This happens only when - * the bundle has shut down. - */ - public static void unsetHdfIORegistry(IHdfIORegistry registry) { - hdfIORegistry = null; - } - - /** - * Gets the {@link IHdfIORegistry} implementation that is running as an OSGi - * Declarative Service. - * - * @return The current implementation of the IHdfIORegistry. - */ - public static IHdfIORegistry getHdfIORegistry() { - return hdfIORegistry; - } - - // ----------------------------------- // - - // ---- Intercept the write method to force writing tag Attributes. ---- // - /** - * When writing an object to an HDF5 file, we must create a tag Attribute. - * This operation enforces this requirement. It also creates a group named - * with the object's toString() value. Sub-classes should instead implement - * {@link #writeObjectData(int, Object)}. - */ - @Override - public void write(int parentGroupId, Object object) - throws NullPointerException, HDF5Exception, HDF5LibraryException { - - if (object != null) { - // Create the group. - int groupId = createGroup(parentGroupId, object.toString()); - - // Write the tag. - writeTag(getTag(object.getClass()), groupId); - - // Write the object's info to the group. - writeObjectData(groupId, object); - - // Close the group. - closeGroup(groupId); - } - - return; - } - - // --------------------------------------------------------------------- // - - // ---- File writing and reading. ---- // - /** - * Writes several objectss to the file specified by the URI. - * - * @param uri - * The URI of the file that will hold the objects. - * @param objects - * The objects that will be written to the file. - */ - public final void writeObjects(URI uri, List objects) { - - if (uri != null && objects != null) { - // ---- Open the file ---- // - // Check the file associated with the URI. If it exists, delete it. - File file = new File(uri); - String path = file.getPath(); - logger.info("HdfIOFactory message: " + "File \"" + path - + "\" is being opened."); - if (file.exists()) { - logger.info("HdfIOFactory message: " + "File \"" + path - + "\" already exists and will be overwritten."); - } else { - // Make sure the directory containing this file exists! If we - // can't create the directory, then quit! - String directoryName = file.getParent(); - File directory = new File(directoryName); - if (!directory.exists()) { - logger.info("HdfIOFactory message: " + "Directory \"" - + directoryName - + "\" does not exist. Creating directory..."); - if (!directory.mkdirs()) { - System.err.println("HdfIOFactory error: " - + "Directory \"" + directoryName - + "\" could not be created."); - return; - } - } - } - // ----------------------- // - - // ---- HDF5 constants, for convenience. ---- // - // Writing out "HDF5Constants." every time is annoying. - // Default flag. - int H5P_DEFAULT = HDF5Constants.H5P_DEFAULT; - // Create, open, truncate. - int H5F_ACC_TRUNC = HDF5Constants.H5F_ACC_TRUNC; - // ------------------------------------------ // - - // The status of the previous HDF5 operation. Generally, if it is - // negative, there was some error. - int status; - - // Other IDs for HDF5 components. - int fileId; - - try { - // Create the H5 file. This should also open it with RW-access. - status = H5.H5Fcreate(path, H5F_ACC_TRUNC, H5P_DEFAULT, - H5P_DEFAULT); - if (status < 0) { - throwException("Opening file \"" + path + "\"", status); - } - fileId = status; - - // Try to write each object in the list. - for (Object object : objects) { - // Get the IO factory for the component's type from the - // registry. If a valid factory exists, try to write the - // component to the file. - IHdfIOFactory factory = hdfIORegistry - .getHdfIOFactory(object); - if (factory != null) { - factory.write(fileId, object); - } - } - - // Close the H5file. - status = H5.H5Fclose(fileId); - if (status < 0) { - throwException("Closing file \"" + path + "\"", status); - } - } catch (HDF5LibraryException e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - } - } - - return; - } - - /** - * Reads all objects from the file specified by the URI. - * - * @param uri - * The URI of the file that should contain readable objects. - * @return A List of objects successfully read in from the file. - */ - public final List readObjects(URI uri) { - List objects = new ArrayList(); - - if (uri != null) { - // ---- Open the file. ---- // - // Check the file associated with the URI. We need to be able to - // read from it. - File file = new File(uri); - String path = file.getPath(); - logger.info("HdfIOFactory message: " + "File \"" + path - + "\" is being opened."); - if (!file.canRead()) { - System.err.println("HdfIOFactory error: " + "File \"" + path - + "\" cannot be read."); - return objects; - } - // ------------------------ // - - // ---- HDF5 constants, for convenience. ---- // - // Default flag. - int H5P_DEFAULT = HDF5Constants.H5P_DEFAULT; - // Open read-only. - int H5F_ACC_RDONLY = HDF5Constants.H5F_ACC_RDONLY; - int H5O_TYPE_GROUP = HDF5Constants.H5O_TYPE_GROUP; - // ------------------------------------------ // - - // The status of the previous HDF5 operation. Generally, if it is - // negative, there was some error. - int status; - - // Other IDs for HDF5 components. - int fileId; - - try { - // Open the H5 file with read-only access. - status = H5.H5Fopen(path, H5F_ACC_RDONLY, H5P_DEFAULT); - if (status < 0) { - throwException("Opening file \"" + path + "\"", status); - } - fileId = status; - - // Try to load each group from the file as an object. - for (String name : getChildNames(fileId, H5O_TYPE_GROUP)) { - // Open the group. - int groupId = openGroup(fileId, name); - - // Pull the tag from the group. If a factory is associated - // with the tag, use it to read the object from the group. - String tag = readTag(groupId); - IHdfIOFactory factory = hdfIORegistry.getHdfIOFactory(tag); - if (factory != null) { - Object object = factory.read(groupId, tag); - // If the factory could read the object from the group, - // we need to add the object to the list of objects. - if (object != null) { - objects.add(object); - } - } - - // Close the group. - closeGroup(groupId); - } - - // Close the H5file. - status = H5.H5Fclose(fileId); - if (status < 0) { - throwException("Closing file \"" + path + "\"", status); - } - } catch (HDF5LibraryException e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - } - } - - return objects; - } - - // ----------------------------------- // - - // -------------------------- // - // ---- Utility methods. ---- // - // -------------------------- // - - /** - * This utility method throws an HDF5LibraryException with a custom message. - * - * @param message - * The message to append to the exception. - * @param status - * The integer flag that indicated a problem. This is usually a - * negative number. - */ - public final void throwException(String message, int status) - throws HDF5LibraryException { - throw new HDF5LibraryException("HdfIOFactory error: " + message + ": " - + Integer.toString(status)); - } - - // ---- Group Operations ---- // - /** - * Opens an HDF5 Group. - * - * @param parentId - * The ID of the parent's Group, which should be open itself. - * @param name - * The name of the Group to open. - * @return The ID of the newly-opened Group. - */ - public final int openGroup(int parentId, String name) - throws HDF5LibraryException, NullPointerException { - int status = H5.H5Gopen(parentId, name, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Opening group \"" + name + "\"", status); - } - return status; - } - - /** - * Creates and opens an HDF5 Group. - * - * @param parentId - * The ID of the parent's Group, which should be open itself. - * @param name - * The name of the Group to open. - * @return The ID of the newly-opened Group. - */ - public final int createGroup(int parentId, String name) - throws HDF5LibraryException, NullPointerException { - int status = H5.H5Gcreate(parentId, name, HDF5Constants.H5P_DEFAULT, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Creating group \"" + name + "\"", status); - } - return status; - } - - /** - * Closes an HDF5 Group. - * - * @param groupId - * The ID of the Group to close. - */ - public final void closeGroup(int groupId) throws HDF5LibraryException { - int status = H5.H5Gclose(groupId); - if (status < 0) { - throwException("Closing group with id " + groupId + ".", status); - } - return; - } - - /** - * Gets a List of all child Objects of an HDF5 Group with the specified ID - * and type. - * - * @param parentId - * The ID of the parent Group. - * @param objectType - * The type of object we are looking for, e.g., H5O_TYPE_GROUP or - * H5O_TYPE_DATASET. - * @return A List of names of all child objects that are HDF5 Groups. - */ - public final List getChildNames(int parentId, int objectType) - throws HDF5LibraryException { - - // Constants used below. - String parentGroup = "."; - int indexType = HDF5Constants.H5_INDEX_NAME; - int indexOrder = HDF5Constants.H5_ITER_INC; - int lapl_id = HDF5Constants.H5P_DEFAULT; - - // Get the number of members in this group. - int status = H5.H5Gn_members(parentId, "."); - if (status < 0) { - throwException("Getting number of children of group with ID " - + parentId + "", status); - } - int nMembers = status; - - // A List of group names within the parent group (which has ID groupId). - List groupNames = new ArrayList(nMembers); - - // Loop over the possible indexes. - for (int i = 0; i < nMembers; i++) { - // Get the info for the object in this position. - H5O_info_t info = H5.H5Oget_info_by_idx(parentId, parentGroup, - indexType, indexOrder, i, lapl_id); - - // See if the object exists and is an HDF5 Group. - if (info != null && info.type == objectType) { - - // Get the name and add it to the List if possible. - String name = H5.H5Lget_name_by_idx(parentId, parentGroup, - indexType, indexOrder, i, lapl_id); - if (name != null) { - groupNames.add(name); - } - } - } - - return groupNames; - } - - // -------------------------- // - - // ---- Atribute Operations ---- // - /** - * Writes an Attribute for an HDF5 Object, which is typically a Group. Array - * Attributes are not supported. - * - * @param objectId - * The ID for the Object, which should be open, that will get the - * Attribute. - * @param name - * The name of the Attribute. - * @param type - * The HDF5 datatype of the Attribute. Currently supported are - * H5T_NATIVE_INT and H5T_NATIVE_DOUBLE. - * @param value - * The value of the Attribute being written. - */ - public final void writeAttribute(int objectId, String name, int type, - Object value) throws NullPointerException, HDF5Exception { - int status; - - // Create the buffer that holds the data to write to the attribute. - int rank = attributeRank; - long[] dims = attributeDims; - Object[] buffer = getBuffer(type); - buffer[0] = value; - - // Create the dataspace to hold the value. - status = H5.H5Screate_simple(rank, dims, null); - if (status < 0) { - throwException("Creating dataspace for attribute \"" + name + "\"", - status); - } - int dataspaceId = status; - - // Create the attribute for the dataspace. - status = H5.H5Acreate(objectId, name, type, dataspaceId, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Creating attribute \"" + name + "\"", status); - } - int attributeId = status; - - // Write the attribute. - status = H5.H5Awrite(attributeId, type, buffer); - if (status < 0) { - throwException("Writing attribute \"" + name + "\"", status); - } - // Close the attribute. - status = H5.H5Aclose(attributeId); - if (status < 0) { - throwException("Closing attribute \"" + name + "\"", status); - } - // Close the dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException("Closing dataspace for attribute \"" + name + "\"", - status); - } - return; - } - - /** - * Reads an Attribute for an HDF5 Object, which is typically a Group. Array - * Attributes are not supported. - * - * @param objectId - * The ID for the Object, which should be open, that has the - * Attribute. - * @param name - * The name of the Attribute. - * @param type - * The HDF5 datatype of the Attribute. Currently supported are - * H5T_NATIVE_INT and H5T_NATIVE_DOUBLE. - * @return Returns the value of the attribute. - */ - public final Object readAttribute(int objectId, String name, int type) - throws NullPointerException, HDF5Exception { - int status; - - // Get a buffer to read the attribute. - Object[] buffer = getBuffer(type); - - // Open the attribute. - status = H5.H5Aopen(objectId, name, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Opening attribute \"" + name + "\"", status); - } - int attributeId = status; - - // Read the attribute. - status = H5.H5Aread(attributeId, type, buffer); - if (status < 0) { - throwException("Reading attribute \"" + name + "\"", status); - } - // Close the attribute. - status = H5.H5Aclose(attributeId); - if (status < 0) { - throwException("Closing attribute \"" + name + "\"", status); - } - return buffer[0]; - } - - /** - * Writes a String as an Attribute for an HDF5 Object, which is typically a - * Group. This requires a special method because the String must first be - * converted to a byte array. - * - * @param objectId - * The ID for the Object, which should be open, that will get the - * Attribute. - * @param name - * The name of the Attribute. - * @param value - * The String value of the Attribute. - */ - public final void writeStringAttribute(int objectId, String name, - String value) throws NullPointerException, HDF5Exception { - int status; - - // HDF5 requires null-terminated strings. Unfortunately, Java's - // String.getBytes() method does not return a byte array that includes a - // null character in the last position, so we have to create a new - // buffer that includes all bytes from the string and a null (0) byte. - - // Method 1: Create byte array of correct size, then copy string bytes - // to byte array. - - // Methd 2: Create array from a new string that has the null character. - byte[] buffer = (value + "\0").getBytes(); - - // We have 1 string, so set rank to 1 and the length of the 1st - // dimension is 1. - int rank = 1; - long[] dims = new long[] { 1 }; - - // Create the dataspace to hold the value. - status = H5.H5Screate_simple(rank, dims, null); - if (status < 0) { - throwException("Creating dataspace for attribute \"" + name + "\"", - status); - } - int dataspaceId = status; - - // Create the datatype for the attribute. Note that we include the size - // of the string byte buffer that includes the null character. - status = H5.H5Tcreate(HDF5Constants.H5T_STRING, buffer.length); - if (status < 0) { - throwException("Creating datatype for attribute \"" + name + "\"", - status); - } - int datatypeId = status; - - // FIXME I don't think this is necessary, but it may be! - // H5.H5Tset_strpad(datatypeId, HDF5Constants.H5T_STR_NULLTERM); - - // Create the attribute for the dataspace. - status = H5.H5Acreate(objectId, name, datatypeId, dataspaceId, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Creating attribute \"" + name + "\"", status); - } - int attributeId = status; - - // Write the attribute. - status = H5.H5Awrite(attributeId, datatypeId, buffer); - if (status < 0) { - throwException("Writing attribute \"" + name + "\"", status); - } - // Close the attribute. - status = H5.H5Aclose(attributeId); - if (status < 0) { - throwException("Closing attribute \"" + name + "\"", status); - } - // Close the datatype. - status = H5.H5Tclose(datatypeId); - if (status < 0) { - throwException("Closing datatype for attribute \"" + name + "\"", - status); - } - // Close the dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException("Closing dataspace for attribute \"" + name + "\"", - status); - } - return; - } - - /** - * Reads a String Attribute from an HDF5 Object, which is typically a Group. - * This requires a special method because the String must first be converted - * to a byte array. - * - * @param objectId - * The ID for the Object, which should be open, that has the - * Attribute. - * @param name - * The name of the Attribute. - * @return The value of the String stored in the Attribute. - */ - public final String readStringAttribute(int objectId, String name) - throws NullPointerException, HDF5Exception { - int status; - - // Open the attribute. - status = H5.H5Aopen(objectId, name, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Opening attribute \"" + name + "\"", status); - } - int attributeId = status; - - // Get the datatype for the String (H5T_STRING with a size in bytes). - status = H5.H5Aget_type(attributeId); - if (status < 0) { - throwException("Reading datatype for attribute \"" + name + "\"", - status); - } - int datatypeId = status; - - // Get the size of the String from the datatype. - status = H5.H5Tget_size(datatypeId); - if (status <= 0) { - throwException("Reading size of datatype for attribute \"" + name - + "\"", status); - } - int size = status; - - // Initialize the buffer. - byte[] buffer = new byte[size]; - - // Read the attribute. - status = H5.H5Aread(attributeId, datatypeId, buffer); - if (status < 0) { - throwException("Reading attribute \"" + name + "\"", status); - } - // Close the attribute. - status = H5.H5Aclose(attributeId); - if (status < 0) { - throwException("Closing attribute \"" + name + "\"", status); - } - // Convert the buffer into a String. The null character is only required - // inside HDF5, so strip the null character. - return new String(buffer, 0, size - 1); - } - - // ----------------------------- // - - // ---- Dataset Operations ---- // - /** - * This method writes an HDF5 Dataset containing the data that is stored in - * a buffer. All of the data's properties and the buffer must be allocated - * before calling this method. - * - * @param objectId - * The ID for the Object, which should be open, that will get the - * Dataset. - * @param name - * The name of the Dataset. - * @param rank - * The number of dimensions in the data. - * @param dims - * An array containing the sizes of each dimension in the data. - * @param type - * The HDF5 datatype of the data in the Dataset, e.g., - * H5T_NATIVE_INT or H5T_NATIVE_DOUBLE. This may also be an ID - * for an opened Datatype, e.g., an array of Strings (byte - * arrays). - * @param buffer - * The buffer that contains the data to write. This needs to be - * an array, e.g., a double[n] or int[n]. - */ - public final void writeDataset(int objectId, String name, int rank, - long[] dims, int type, Object buffer) throws NullPointerException, - HDF5Exception { - int status; - - // Create the dataspace. - status = H5.H5Screate_simple(rank, dims, null); - if (status < 0) { - throwException("Creating dataspace for dataset \"" + name + "\"", - status); - } - int dataspaceId = status; - - // Create the dataset. - status = H5.H5Dcreate(objectId, name, type, dataspaceId, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, - HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Creating dataset \"" + name + "\"", status); - } - int datasetId = status; - - // Write the dataset. - status = H5.H5Dwrite(datasetId, type, HDF5Constants.H5S_ALL, - HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, buffer); - if (status < 0) { - throwException("Writing dataset \"" + name + "\"", status); - } - // Close the dataset. - status = H5.H5Dclose(datasetId); - if (status < 0) { - throwException("Closing dataset \"" + name + "\"", status); - } - // Close the dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException("Closing dataspace for dataset \"" + name + "\"", - status); - } - return; - } - - /** - * Reads a dataset without requiring advance knowledge of its entire - * structure. However, the returned buffer does not have any dimensional - * data associated with it, just the data from the dataset. - * - * @param groupId - * The ID of the Object, which should be open, that contains the - * dataset. - * @param name - * The name of the dataset. - * @param type - * The HDF5 datatype of the data in the dataset, e.g., - * H5T_NATIVE_INT or H5T_NATIVE_DOUBLE. This may also be an ID - * for an opened datatype, e.g., an array of Strings (byte - * arrays). - * @return A buffer containing the data from the dataset, or null if the - * dataset could not be read. - */ - public Object readDataset(int groupId, String name, int type) - throws NullPointerException, HDF5Exception { - - Object buffer = null; - - int status; - - // Commonly-used constants. - int H5P_DEFAULT = HDF5Constants.H5P_DEFAULT; - int H5S_ALL = HDF5Constants.H5S_ALL; - - // See if the dataset exists. If so, read it in. - if (H5.H5Lexists(groupId, name, H5P_DEFAULT)) { - - // Open the dataset. - status = H5.H5Dopen(groupId, name, H5P_DEFAULT); - if (status < 0) { - throwException("Could not open dataset \"" + name + "\".", - status); - } - int datasetId = status; - - // Open the dataspace. - status = H5.H5Dget_space(datasetId); - if (status < 0) { - throwException("Could not open dataspace for dataset \"" + name - + "\".", status); - } - int dataspaceId = status; - - // Get the rank of the dataspace. - status = H5.H5Sget_simple_extent_ndims(dataspaceId); - if (status < 0) { - throwException( - "Could not determine rank (number of dimensions) of dataspace for dataset \"" - + name + "\".", status); - } - int rank = status; - - // Get the dimensions of the dataspace. - long[] dims = new long[rank]; - status = H5.H5Sget_simple_extent_dims(dataspaceId, dims, null); - if (status != rank) { - throwException( - "Could not determine dimensions of dataspace for dataset \"" - + name + "\".", status); - } - // Create an appropriately sized buffer. - buffer = getBuffer(type, dims); - - // Read in the Dataset. - status = H5.H5Dread(datasetId, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, - buffer); - if (status < 0) { - throwException("Could not read dataset \"" + name + "\".", - status); - } - // Close the Dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException("Could not close dataspace for dataset \"" - + name + "\".", status); - } - // Close the Dataset. - status = H5.H5Dclose(datasetId); - if (status < 0) { - throwException("Could not close dataset \"" + name + "\".", - status); - } - } - - return buffer; - } - - // ---------------------------- // - - /** - * Writes an ICEObject's name, description, and ID as Attributes for an HDF5 - * Object. - * - * @param object - * The ICEObject whose info should be written in HDF5. - * @param objectId - * The ID of the HDF5 Object receiving the ICEObject Attributes. - */ - public final void writeICEObjectInfo(ICEObject object, int objectId) - throws NullPointerException, HDF5Exception { - - // Write the component's name, description, and ID. - writeStringAttribute(objectId, "name", object.getName()); - writeStringAttribute(objectId, "description", object.getDescription()); - writeAttribute(objectId, "id", HDF5Constants.H5T_NATIVE_INT, - object.getId()); - } - - /** - * Reads the ICEObject information (name, description, ID) from an HDF5 - * Group or Object into an ICEObject. - * - * @param object - * The ICEObject that should have its information set. - * @param objectId - * The ID of the HDF5 Group or Object that contains the - * ICEObject's information. - */ - public final void readICEObjectInfo(ICEObject object, int objectId) - throws NullPointerException, HDF5Exception { - - // Read the object's name, description, and ID from the HDF5 Group or - // Object. - object.setName(readStringAttribute(objectId, "name")); - object.setDescription(readStringAttribute(objectId, "description")); - object.setId((Integer) readAttribute(objectId, "id", - HDF5Constants.H5T_NATIVE_INT)); - } - - /** - * Writes the tag value for the specified HDF5 Group. - * - * @param tag - * The tag string. - * @param objectId - * The HDF5 Group that will have the specified tag. - */ - public final void writeTag(String tag, int objectId) - throws NullPointerException, HDF5Exception { - - if (tag == null) { - tag = ""; - } - - writeStringAttribute(objectId, "tag", tag); - } - - /** - * Reads the value of a tag from the specified HDF5 Group. - * - * @param objectId - * The HDF5 Group that should have a tag Attribute. - * @return The value of the tag Attribute. - */ - public String readTag(int objectId) throws NullPointerException, - HDF5Exception { - return readStringAttribute(objectId, "tag"); - } - - /** - * Gets a buffer used for writing or reading an HDF5 attribute. Currently - * supports doubles and integers. - * - * @param type - * The data type, e.g. {@link HDF5Constants#H5T_NATIVE_DOUBLE} or - * {@link HDF5Constants#H5T_NATIVE_INT}. - * @return The buffer as an array of Objects (of size 1). To set its value - * for writing, set buffer[0]. - */ - public final Object[] getBuffer(int type) throws HDF5LibraryException { - Object[] buffer = null; - - if (type == HDF5Constants.H5T_NATIVE_DOUBLE) { - buffer = doubleAttributeBuffer; - } else if (type == HDF5Constants.H5T_NATIVE_INT) { - buffer = integerAttributeBuffer; - } else { - throwException("Unsupported data type.", -1); - } - return buffer; - } - - /** - * Gets a buffer used for writing or reading HDF5 datasets. Currently - * supports doubles and integers. - * - * @param type - * The data type, e.g. {@link HDF5Constants#H5T_NATIVE_DOUBLE} or - * {@link HDF5Constants#H5T_NATIVE_INT}. - * @param dims - * The sizes of each dimension of the data. - * @return A buffer of the appropriate size to contain the data defined by - * the dimensions, e.g., 1st dimension length * 2nd dimension length - * * ... * nth dimension length. - */ - public final Object getBuffer(int type, long[] dims) - throws HDF5LibraryException { - Object buffer = null; - - // Get the total size of the buffer from the dimension sizes. - int size = 1; - for (long dimension : dims) { - size *= dimension; - } - // Create the buffer depending on the type. - if (type == HDF5Constants.H5T_NATIVE_DOUBLE) { - buffer = new double[size]; - } else if (type == HDF5Constants.H5T_NATIVE_INT) { - buffer = new int[size]; - } else { - throwException("Unsupported data type.", -1); - } - return buffer; - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfIORegistry.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfIORegistry.java deleted file mode 100644 index e615b54b3..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfIORegistry.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import java.util.HashMap; -import java.util.Map; - -/** - * This class provides an implementation of {@link IHdfIORegistry}. To support - * {@link IHdfIOFactory} lookups based on both objects and tag Strings - * (presumably read from a file), this class uses a map from tags to object - * classes and a map from object classes to IHdfIOFactories. - * - * @author Jordan H. Deyton - * - */ -public class HdfIORegistry implements IHdfIORegistry { - - /** - * The map of tag Strings to object classes. - */ - private final Map> tagMap = new HashMap>(); - - /** - * The map of object classes to IHdfIOFactories. - */ - private final Map, IHdfIOFactory> factoryMap = new HashMap, IHdfIOFactory>(); - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ice.io.hdf.IHdfIORegistry#registerHdfIOFactory(org.eclipse - * .ice .io.hdf.IHdfIOFactory) - */ - @Override - public void registerHdfIOFactory(IHdfIOFactory factory) { - - if (factory != null) { - for (Class supportedClass : factory.getSupportedClasses()) { - String tag = factory.getTag(supportedClass); - - // Put all tag/class pairs into tagMap. - // Put all class/factory pairs into factoryMap. - if (tag != null && supportedClass != null) { - tagMap.put(tag, supportedClass); - factoryMap.put(supportedClass, factory); - } - } - } - - return; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ice.io.hdf.IHdfIORegistry#getHdfIOFactory(java.lang.Object) - */ - @Override - public IHdfIOFactory getHdfIOFactory(Object object) { - return (object != null ? factoryMap.get(object.getClass()) : null); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ice.io.hdf.IHdfIORegistry#getHdfIOFactory(java.lang.String) - */ - @Override - public IHdfIOFactory getHdfIOFactory(String tag) { - return factoryMap.get(tagMap.get(tag)); - } - -} diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfReaderFactory.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfReaderFactory.java deleted file mode 100644 index 2bc395f8f..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfReaderFactory.java +++ /dev/null @@ -1,531 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import java.util.ArrayList; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import ncsa.hdf.hdf5lib.H5; -import ncsa.hdf.hdf5lib.HDF5Constants; -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Dataset; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.HObject; -import ncsa.hdf.object.h5.H5Group; - -/** - *

- * The HdfReaderFactory class contains static methods used to read elements from - * an HDF5 file. - *

- * - * @author Eric J. Lingerfelt - */ -public class HdfReaderFactory { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(HdfReaderFactory.class); - - /** - *

- * Returns the child H5Group called name from parentH5Group. If - * parentH5Group is null, then null is returned. If name is null or is an - * empty String, then null is returned. If there is no child H5Group called - * name, then null is returned. - *

- * - * @param parentH5Group - *

- * The parent H5Group to search. - *

- * @param name - *

- * The name of the child H5Group. - *

- * @return - *

- * The child H5Group. - *

- */ - public static H5Group getChildH5Group(H5Group parentH5Group, String name) { - - // If the name or parentH5Group is null or size is 0, return null - if (name == null || parentH5Group == null - || parentH5Group.getNumberOfMembersInFile() == 0) { - return null; - } - // Get the group or return null - try { - return (H5Group) parentH5Group.getFileFormat() - .get(parentH5Group.getFullName() - + System.getProperty("file.separator") + name); - } catch (Exception e) { - logger.error("HdfReaderFactory Exception!", e); - return null; - } - - } - - /** - *

- * Returns the child H5Group at the provided index from parentH5Group's - * member list. If parentH5Group is null, then null is returned. If index - * < 0, then null is returned. If parentH5Group has no children, then - * null is returned. If the object at located at the provided index is not - * an H5Group, then null is returned. - *

- * - * @param parentH5Group - *

- * The parent H5Group to search. - *

- * @param index - *

- * The index of the child H5Group in parentH5Group's member list. - *

- * @return - *

- * The child H5Group. - *

- */ - public static H5Group getChildH5Group(H5Group parentH5Group, int index) { - - // Return null if the parameters are invalid. - if (parentH5Group == null || index < 0) { - return null; - } - - String name; - H5Group childGroup = null; - try { - // Get the parent H5Group's file ID. - int fileID = parentH5Group.getFID(); - - // Get the name of the parent H5Group. - String parentName = parentH5Group.getFullName(); - - // Make sure the index parameter is not too large. - // H5Gn_members tells us how many children parentH5Group has. - if (index >= H5.H5Gn_members(fileID, parentName)) { - return null; - } - - // These constants are required in the H5 library call. - int indexType = HDF5Constants.H5_INDEX_NAME; // Members are ordered - // by name! - int order = HDF5Constants.H5_ITER_INC; - int linkAccessPropertyList = HDF5Constants.H5P_DEFAULT; - - // Get the member object's name by its index. - name = H5.H5Lget_name_by_idx(fileID, parentName, indexType, order, - index, linkAccessPropertyList); - - childGroup = (H5Group) parentH5Group.getFileFormat() - .get(parentH5Group.getFullName() - + System.getProperty("file.separator") + name); - } catch (Exception e) { - // If we encounter an error, return null. - logger.error("HdfReaderFactory Exception!", e); - } - - // Now that we have the object's name, get the child H5Group. - return childGroup; - } - - /** - *

- * Returns an ArrayList of all child H5Groups from parentH5Group's member - * list. If parentH5Group is null, then null is returned. If parentH5Group - * has no H5Group children, then an empty ArrayList is returned. - *

- * - * @param parentH5Group - *

- * The parent H5Group to search. - *

- * @return - *

- * An ArrayList of child H5Groups. - *

- */ - public static ArrayList getChildH5Groups(H5Group parentH5Group) { - - // Previously with this code, we used only the HDF5 Java object library - // to perform this function. However, when the child groups take up too - // much memory, only a subset of those groups will be in the list - // returned by parentH5Group.getMemberList(). Instead, we need to call - // the standard HDF5 Java library to perform such a lookup. - - // Initialize the list to return. - ArrayList groupList = new ArrayList(); - - // Return the empty list if the parameters are invalid. - if (parentH5Group == null) { - return groupList; - } - - // Get the file ID of the parent group. - int file_id = parentH5Group.getFID(); - - // Get the name of the parent group. - String parentName = parentH5Group.getFullName(); - - // These variables will hold metadata about parentH5Group: - // The number of members in parentH5Group. - int count = 0; - // The names of the members. - String[] objectNames; - // The types of the members (e.g., DataSet or Group). - int[] objectTypes; - - try { - // Get the number of members in parentH5Group. - count = H5.H5Gn_members(file_id, parentName); - - // Go ahead and return if we there are no child members. - if (count == 0) { - return groupList; - } - // Initialize the metadata containers. - objectNames = new String[count]; - objectTypes = new int[count]; - - // These are required for the following function call but are not - // used elsewhere. - int[] ltype = new int[count]; - long[] orefs = new long[count]; - int indexType = HDF5Constants.H5_INDEX_NAME; - - // Get the metadata for of of parentH5Group's members. - H5.H5Gget_obj_info_all(file_id, parentName, objectNames, - objectTypes, ltype, orefs, indexType); - - // Look for any members that are of the type H5O_TYPE_GROUP - // (H5Groups). - for (int i = 0; i < count; i++) { - if (objectTypes[i] == HDF5Constants.H5O_TYPE_GROUP) { - // Try to get the child H5Group from parentH5Group and add - // it - // to the list. - HObject hobj = parentH5Group.getFileFormat() - .get(parentH5Group.getFullName() - + System.getProperty("file.separator") - + objectNames[i]); - if (hobj != null) { - groupList.add((H5Group) hobj); - } - } - } - } catch (Exception e) { - // If we encounter an error, return the empty list. - logger.error("HdfReaderFactory Exception!", e); - return groupList; - } - - return groupList; - } - - /** - * Returns an ArrayList of all child HObjects from a parentH5Group. - * This is analogous to and should be used in lieu of - * parentH5Group.getMemberList(), which only returns child HObjects that are - * in memory. - * - * @param parentH5Group - * The parent H5Group to query. - * @return An ArrayList of all child H5Objects, or an empty list if - * the group cannot be read. - */ - public static ArrayList getChildH5Members(H5Group parentH5Group) { - - // Initialize the list to return. - ArrayList groupList = new ArrayList(); - - // Return the empty list if the parameters are invalid. - if (parentH5Group == null) { - return groupList; - } - - // Get the file ID of the parent group. - int file_id = parentH5Group.getFID(); - - // Get the name of the parent group. - String parentName = parentH5Group.getFullName(); - - // These variables will hold metadata about parentH5Group: - // The number of members in parentH5Group. - int count = 0; - // The names of the members. - String[] objectNames; - // The types of the members (e.g., DataSet or Group). - int[] objectTypes; - - try { - // Get the number of members in parentH5Group. - count = H5.H5Gn_members(file_id, parentName); - - // Go ahead and return if we there are no child members. - if (count == 0) { - return groupList; - } - - // Initialize the metadata containers. - objectNames = new String[count]; - objectTypes = new int[count]; - - // These are required for the following function call but are not - // used elsewhere. - int[] ltype = new int[count]; - long[] orefs = new long[count]; - int indexType = HDF5Constants.H5_INDEX_NAME; - - // Get the metadata for of of parentH5Group's members. - H5.H5Gget_obj_info_all(file_id, parentName, objectNames, - objectTypes, ltype, orefs, indexType); - - // Add all members to the array. - for (int i = 0; i < count; i++) { - HObject hobj = parentH5Group.getFileFormat() - .get(parentH5Group.getFullName() - + System.getProperty("file.separator") - + objectNames[i]); - if (hobj != null) { - groupList.add(hobj); - } - } - - } catch (Exception e) { - // If we encounter an error, return the empty list. - logger.error("HdfReaderFactory Exception!", e); - return groupList; - } - - return groupList; - } - - /** - *

- * Returns the Dataset called name from h5Group. If h5Group is null, then - * null is returned. If name is null or an empty String, then null is - * returned. If h5Group has no Datasets, then null is returned. If a Dataset - * called name can not be located, then null is returned. - *

- * - * @param h5Group - *

- * The H5Group to search. - *

- * @param name - *

- * The name of the Dataset to search for. - *

- * @return - *

- * The located Dataset. - *

- */ - public static Dataset getDataset(H5Group h5Group, String name) { - - // Check to make sure the group and name is not null AND that it - // contains members - if (h5Group == null || name == null - || h5Group.getNumberOfMembersInFile() == 0) { - return null; - } - // Get the dataset or return null - try { - return (Dataset) h5Group.getFileFormat().get(h5Group.getFullName() - + System.getProperty("file.separator") + name); - } catch (Exception e) { - logger.error("HdfReaderFactory Exception!", e); - return null; - } - - } - - /** - *

- * Reads and returns a Double object read from the Attribute called name - * from the metadata for h5Group. If name is null or an empty String, then - * null is returned. If h5Group is null, then null is returned. If an - * Attribute called name cannot be located, then null is returned. If the - * Attribute called name is located but is not of Datatype.CLASS_FLOAT, then - * null is returned. - *

- * - * @param h5Group - *

- * The H5Group to read. - *

- * @param name - *

- * The name of the attribute. - *

- * @return - *

- * The Attribute's value as a Double object. - *

- */ - public static Double readDoubleAttribute(H5Group h5Group, String name) { - - try { - // If the name or H5Group is null or if there is no meta data, - // return null - if (h5Group == null || name == null - || h5Group.getMetadata().isEmpty()) { - return null; - } - // Loop over the meta data to find the attribute with the correct - // name - for (int i = 0; i < h5Group.getMetadata().size(); i++) { - - // Cast as an attribute - Attribute attribute = (Attribute) h5Group.getMetadata().get(i); - - // If the attribute is the correct name and type, return the - // Double - if (attribute.getName().equals(name) && attribute.getType() - .getDatatypeClass() == Datatype.CLASS_FLOAT) { - - // Return the correct value - return ((double[]) attribute.getValue())[0]; - } - } - } catch (Exception e) { - // Print the stack trace - logger.error("HdfReaderFactory Exception!", e); - } - - // Return null, nothing found - return null; - - } - - /** - *

- * Reads and returns an Integer object read from the Attribute called name - * from the metadata for h5Group. If name is null or an empty String, then - * null is returned. If h5Group is null, then null is returned. If an - * Attribute called name cannot be located, then null is returned. If the - * Attribute called name is located but is not of Datatype.CLASS_INTEGER, - * then null is returned. - *

- * - * @param h5Group - *

- * The H5Group to read. - *

- * @param name - *

- * The name of the attribute. - *

- * @return - *

- * The Attribute's value as an Integer object. - *

- */ - public static Integer readIntegerAttribute(H5Group h5Group, String name) { - try { - // If the name or H5Group is null or if there is no meta data, - // return null - if (h5Group == null || name == null - || h5Group.getMetadata().isEmpty()) { - return null; - } - // Loop over the meta data to find the attribute with the correct - // name - for (int i = 0; i < h5Group.getMetadata().size(); i++) { - - // Cast as an attribute - Attribute attribute = (Attribute) h5Group.getMetadata().get(i); - - // If the attribute is the correct name and type, return the - // Integer - if (attribute.getName().equals(name) && attribute.getType() - .getDatatypeClass() == Datatype.CLASS_INTEGER) { - - // Return the correct value - return ((int[]) attribute.getValue())[0]; - } - } - } catch (Exception e) { - // Print the stack trace - logger.error("HdfReaderFactory Exception!", e); - } - // Return null, nothing found - return null; - - } - - /** - *

- * Reads and returns a String object read from the Attribute called name - * from the metadata for h5Group. If name is null or an empty String, then - * null is returned. If h5Group is null, then null is returned. If an - * Attribute called name cannot be located, then null is returned. If the - * Attribute called name is located but is not of Datatype.CLASS_STRING, - * then null is returned. - *

- * - * @param h5Group - *

- * The H5Group to read. - *

- * @param name - *

- * The name of the attribute. - *

- * @return - *

- * The Attribute's value as a String object. - *

- */ - public static String readStringAttribute(H5Group h5Group, String name) { - - try { - // If the name or H5Group is null or if there is no meta data, - // return null - if (h5Group == null || name == null - || h5Group.getMetadata().isEmpty()) { - return null; - } - // Loop over the meta data to find the attribute with the correct - // name - for (int i = 0; i < h5Group.getMetadata().size(); i++) { - // Cast as an attribute - Attribute attribute = (Attribute) h5Group.getMetadata().get(i); - - // If the attribute is the correct name and type, return the - // String - if (attribute.getName().equals(name) && attribute.getType() - .getDatatypeClass() == Datatype.CLASS_STRING) { - - // Return the correct value - return ((String[]) attribute.getValue())[0]; - - } - } - } catch (Exception e) { - // Print the stack trace - logger.error("HdfReaderFactory Exception!", e); - } - // Return null, nothing found - return null; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfWriterFactory.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfWriterFactory.java deleted file mode 100644 index 26dbf8d38..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/HdfWriterFactory.java +++ /dev/null @@ -1,553 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Dataset; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.h5.H5Datatype; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -/** - *

- * The HdfWriterFactory class contains static methods used to write elements to - * an HDF5 file. - *

- * - * @author Eric J. Lingerfelt - */ -public class HdfWriterFactory { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(HdfWriterFactory.class); - - /** - *

- * Creates and returns a child H5Group called name for parentH5Group using - * the h5File. If h5File is null or can not be opened, then null is - * returned. If name is null or is an empty String, then null is returned. - * If parentH5Group is null, then null is returned. If an exception is - * thrown, then null is returned. - *

- * - * @param h5File - *

- * An H5File. - *

- * @param name - *

- * The name of the new H5Group. - *

- * @param parentH5Group - *

- * The parent H5Group of the new H5Group. - *

- * @return - *

- * An H5Group called name which is a child of parentH5Group. - *

- */ - public static H5Group createH5Group(H5File h5File, String name, - H5Group parentH5Group) { - - // If the file or the name is null, or if the name is the empty string, - // return - if (h5File == null || name == null || "".equals(name.trim()) - || parentH5Group == null) { - return null; - } - - try { - - // Declare a file id - int fileIdentifier = h5File.getFID(); - - // Try to open the file and get a file id - if (fileIdentifier == -1) { - - fileIdentifier = h5File.open(); - - } - - // Check the file identifier - if (fileIdentifier == -1) { - return null; - } - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - return null; - } - - try { - - // Create the group - H5Group h5Group = (H5Group) h5File.createGroup(name, parentH5Group); - - // Return it - return h5Group; - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - // Return null - return null; - } - - } - - /** - *

- * Creates and returns a 64-bit floating point H5Datatype from h5File. If - * h5File is null or can not be opened, then null is returned. If an - * exception is thrown, then null is returned. - *

- * - * @param h5File - *

- * An H5File. - *

- * @return - *

- * A 64-bit floating point H5Datatype. - *

- */ - public static H5Datatype createFloatH5Datatype(H5File h5File) { - - try { - - // Declare a file id - int fileIdentifier = h5File.getFID(); - - // Try to open the file and get a file id - if (fileIdentifier == -1) { - - fileIdentifier = h5File.open(); - - } - - // Check the file identifier - if (fileIdentifier == -1) { - return null; - } - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - return null; - } - - try { - - // Create the float datatype - H5Datatype h5Datatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_FLOAT, 8, Datatype.NATIVE, Datatype.NATIVE); - - // Return it - return h5Datatype; - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - // Return null - return null; - } - - } - - /** - *

- * Creates and returns an integer H5Datatype from h5File. If h5File is null - * or can not be opened, then null is returned. If an exception is thrown, - * then null is returned. - *

- * - * @param h5File - *

- * An H5File. - *

- * @return - *

- * A 32-bit integer H5Datatype. - *

- */ - public static H5Datatype createIntegerH5Datatype(H5File h5File) { - - try { - - // Declare a file id - int fileIdentifier = h5File.getFID(); - - // Try to open the file and get a file id - if (fileIdentifier == -1) { - - fileIdentifier = h5File.open(); - - } - - // Check the file identifier - if (fileIdentifier == -1) { - return null; - } - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - return null; - } - - try { - - // Create the integer datatype - H5Datatype h5Datatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_INTEGER, 4, Datatype.NATIVE, - Datatype.NATIVE); - - // Return it - return h5Datatype; - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - // Return null - return null; - } - - } - - /** - *

- * Writes an Attribute to h5Group called name with a double value using - * h5File. If h5File is null or can not be opened, then false is returned. - * If name is null or is an empty String, then false is returned. If h5Group - * is null, then false is returned. If an exception is thrown, then false is - * returned. Otherwise, true is returned. - *

- * - * @param h5File - *

- * An H5File. - *

- * @param h5Group - *

- * The H5Group to write the attribute to. - *

- * @param name - *

- * The name of the Attribute. - *

- * @param value - *

- * The value of the Attribute. - *

- * @return - *

- * If h5File is null or can not be opened, then false is returned. - * If name is null or is an empty String, then false is returned. If - * h5Group is null, then false is returned. If an exception is - * thrown, then false is returned. Otherwise, true is returned. - *

- */ - public static boolean writeDoubleAttribute(H5File h5File, H5Group h5Group, - String name, double value) { - - // If the file, h5Group, or the name is null, or if the name is the - // empty string, return false - if (h5File == null || name == null || "".equals(name.trim()) - || h5Group == null) { - return false; - } - - try { - - // Declare a file id - int fileIdentifier = h5File.getFID(); - - // Try to open the file and get a file id - if (fileIdentifier == -1) { - - fileIdentifier = h5File.open(); - - } - - // Check the file identifier - if (fileIdentifier == -1) { - return false; - } - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - return false; - } - - // Get a integer datatype - H5Datatype datatype = HdfWriterFactory.createFloatH5Datatype(h5File); - - // 1D of size 1 - long[] dims = { 1 }; - - // Create the value - double[] values = { value }; - - // Create an attribute object - Attribute attribute = new Attribute(name, datatype, dims, values); - - // Write the attribute - try { - - h5Group.writeMetadata(attribute); - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - // return false - return false; - } - - return true; - } - - /** - *

- * Writes an Attribute to h5Group called name with an integer value using - * h5File. If h5File is null or can not be opened, then false is returned. - * If name is null or is an empty String, then false is returned. If h5Group - * is null, then false is returned. If an exception is thrown, then false is - * returned. Otherwise, true is returned. - *

- * - * @param h5File - *

- * An H5File. - *

- * @param h5Group - *

- * The H5Group to write the attribute to. - *

- * @param name - *

- * The name of the Attribute. - *

- * @param value - *

- * The value of the Attribute. - *

- * @return - *

- * If h5File is null or can not be opened, then false is returned. - * If name is null or is an empty String, then false is returned. If - * h5Group is null, then false is returned. If an exception is - * thrown, then false is returned. Otherwise, true is returned. - *

- */ - public static boolean writeIntegerAttribute(H5File h5File, H5Group h5Group, - String name, int value) { - - // If the file, h5Group, or the name is null, or if the name is the - // empty string, return false - if (h5File == null || name == null || "".equals(name.trim()) - || h5Group == null) { - return false; - } - - try { - - // Declare a file id - int fileIdentifier = h5File.getFID(); - - // Try to open the file and get a file id - if (fileIdentifier == -1) { - - fileIdentifier = h5File.open(); - - } - - // Check the file identifier - if (fileIdentifier == -1) { - return false; - } - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - return false; - } - // Get a integer datatype - H5Datatype datatype = HdfWriterFactory.createIntegerH5Datatype(h5File); - - // 1D of size 1 - long[] dims = { 1 }; - - // Create the value - int[] values = { value }; - - // Create an attribute object - Attribute attribute = new Attribute(name, datatype, dims, values); - - // Write the attribute - try { - - h5Group.writeMetadata(attribute); - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - // return false - return false; - } - - return true; - } - - /** - *

- * Writes an Attribute to h5Group called name with a String value using - * h5File. If h5File is null or can not be opened, then false is returned. - * If name is null or is an empty String, then false is returned. If value - * is null or is an empty String, then false is returned. If an exception is - * thrown, then false is returned. If h5Group is null, then false is - * returned. Otherwise, true is returned. - *

- * - * @param h5File - *

- * An H5File. - *

- * @param h5Group - *

- * The H5Group to write the attribute to. - *

- * @param name - *

- * The name of the Attribute. - *

- * @param value - *

- * The value of the Attribute. - *

- * @return - *

- * If h5File is null or can not be opened, then false is returned. - * If name is null or is an empty String, then false is returned. If - * value is null or is an empty String, then false is returned. If - * an exception is thrown, then false is returned. If h5Group is - * null, then false is returned. Otherwise, true is returned. - *

- */ - public static boolean writeStringAttribute(H5File h5File, H5Group h5Group, - String name, String value) { - - // If the file, h5Group, or the name is null, or if the name is the - // empty string, return false - if (h5File == null || name == null || "".equals(name.trim()) - || h5Group == null || value == null || "".equals(name.trim())) { - return false; - } - - try { - - // Declare a file id - int fileIdentifier = h5File.getFID(); - - // Try to open the file and get a file id - if (fileIdentifier == -1) { - - fileIdentifier = h5File.open(); - - } - - // Check the file identifier - if (fileIdentifier == -1) { - return false; - } - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - return false; - } - - try { - - // Create a custom String data type for the value - H5Datatype datatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, value.length(), Datatype.NATIVE, - Datatype.NATIVE); - - // 1D of size 1 - long[] dims = { 1 }; - - // Create a String array of size one to hold the value - String[] values = new String[1]; - - // Assign the value to the first array index - values[0] = value; - - // Create a byte array from values using the stringToByte method - // See - // http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/2011-March/004509.html - byte[] bvalue = Dataset.stringToByte(values, value.length()); - - // Create an attribute object - Attribute attribute = new Attribute(name, datatype, - new long[] { 1 }); - - // Set the value of the attribute to bvalue - attribute.setValue(bvalue); - - // Write the attribute to the group's metadata - h5Group.writeMetadata(attribute); - - } catch (Exception e) { - - // Print the stack trace - logger.error("HdfWriterFactory Exception!", e); - - // return false - return false; - } - - return true; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfIOFactory.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfIOFactory.java deleted file mode 100644 index defb39467..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfIOFactory.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import java.util.List; - -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; -import ncsa.hdf.hdf5lib.exceptions.HDF5LibraryException; - -/** - *

- * This is an interface for factories that can write and read objects to and - * from HDF5 files. - *

- *

- * Bundles that write or read HDF files for data structures should implement - * this interface or extend the basic implementation, {@link HdfIOFactory} - * (which contains several useful methods for handling HDF5 files), and provide - * the {@link IHdfIOFactory} service via OSGi so that the factory is registered - * with the {@link IHdfIORegistry}. - *

- * - * @author Jordan H. Deyton - * - */ -public interface IHdfIOFactory { - - /** - * Gets the supported classes for this IHDFIOFactory. The classes returned - * can be written and read using this factory. Each class should have its - * own unique tag String. - * - * @return A Map containing the supported classes and their associated tags. - */ - public List> getSupportedClasses(); - - /** - * Gets a tag String for a supported class returned via - * {@link #getSupportedClasses()}. All classes should have a String tag that - * will be written to the file. - * - * @param supportedClass - * The supported class. - * @return A tag String uniquely associated with the supported class. - */ - public String getTag(Class supportedClass); - - /** - * Writes an object to an HDF5 file specified by a URI. - * - * @param parentGroupId - * The HDF5 file ID for the parent group containing the object. - * @param object - * An object to write to HDF5. If the object type is not - * supported by the handler, nothing is written. - */ - public void write(int parentGroupId, Object object) - throws NullPointerException, HDF5Exception, HDF5LibraryException; - - /** - * Reads an object from an HDF5 file specified by a URI. - * - * @param groupId - * The HDF5 file ID for the group containing the object. - * @param tag - * The tag Attribute for the group. This specifies the type of - * object to be read from the file. - * @return An object read in from the HDF5, or null if the type is not - * supported by the handler. - */ - public Object read(int groupId, String tag) throws NullPointerException, - HDF5Exception, HDF5LibraryException; -} diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfIORegistry.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfIORegistry.java deleted file mode 100644 index 45ffb7bb7..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfIORegistry.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -/** - *

- * This interface provides a registry for {@link IHdfIOFactory} instances - * provided as OSGi Declarative Services. This interface can similarly be - * referenced via OSGi. - *

- *

- * The purpose of this class is to enable other bundles to create their own - * factories for writing to/reading from HDF5 files. These other bundles - * register their factories with the registry so that UI bundles can request - * said factories to write or read supported objects. - *

- *

- * See {@link HdfIORegistry} for a basic implementation of this interface. - *

- * - * @author Jordan H. Deyton - * - */ -public interface IHdfIORegistry { - - /** - * Registers an {@link IHdfIOFactory} with the registry. Only non-null - * factories can be registered. If two factories share the same supported - * classes, only the most recently registered factory will be associated - * with those classes. - * - * @param factory - * The IHdfIOFactory to add to the registry. - */ - public void registerHdfIOFactory(IHdfIOFactory factory); - - /** - *

- * Gets an {@link IHdfIOFactory} from the registry. This factory supports - * writing and reading for the specified class. - *

- *

- * This method is typically used for writing an object. - *

- * - * - * @param object - * The object that needs to be written to or read from a file. - * @return An IHdfIOFactory for the object's type, or null if there is no - * factory that supports the specified component. - */ - public IHdfIOFactory getHdfIOFactory(Object object); - - /** - *

- * Gets an {@link IHdfIOFactory} from the registry. Instead of using a class - * as a key, this uses a String tag read from a file. - *

- *

- * This method is typically used for reading an object. - *

- * - * @param tag - * The tag used to associated an object from a file with an - * IHdfIOFactory. - * @return An IHdfIOFactory for the tag, or null if there is no factory that - * supports the specified tag. - */ - public IHdfIOFactory getHdfIOFactory(String tag); - -} diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfReadable.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfReadable.java deleted file mode 100644 index 4bb61158d..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfReadable.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import ncsa.hdf.object.h5.H5Group; - -/** - *

- * An interface that provides the required operations for populating an ICE data - * structure from an HDF5 file. - *

- * - * @author Eric J. Lingerfelt - */ -public interface IHdfReadable { - - /** - *

- * This operation assigns the reference of the provided iHdfReadable to a - * class variable. If iHdfReadable is null, then false is returned. If - * iHdfReadable fails casting, then false is returned. Otherwise, true is - * returned. - *

- * - * @param iHdfReadable - *

- * The IHdfReadable whose reference is to be cast and assigned to - * a class variable. - *

- * @return - *

- * If iHdfReadable is null, then false is returned. If iHdfReadable - * fails casting, then false is returned. Otherwise, true is - * returned. - *

- */ - public boolean readChild(IHdfReadable iHdfReadable); - - /** - *

- * This operation reads Attributes from h5Group and assigns their values to - * class variables. If h5Group is null, false is returned. If any Attribute - * values are null, false is returned. Otherwise, true is returned. - *

- * - * @param h5Group - *

- * The H5Group to read Attributes from. - *

- * @return - *

- * If h5Group is null, false is returned. If any Attribute values - * are null, false is returned. Otherwise, true is returned. - *

- */ - public boolean readAttributes(H5Group h5Group); - - /** - *

- * This operation reads Datasets from h5Group and assigns their values to - * class variables. If h5Group is null or an Exception is thrown, false is - * returned. If the Otherwise, true is returned. - *

- * - * @param h5Group - *

- * The H5Group to read Datasets from. - *

- * @return - *

- * If h5Group is null or an Exception is thrown, false is returned. - * If the Otherwise, true is returned. - *

- */ - public boolean readDatasets(H5Group h5Group); -} \ No newline at end of file diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfReader.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfReader.java deleted file mode 100644 index 423a52a99..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfReader.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import java.net.URI; - -/** - *

- * An interface that provides the required operations for reading and creating - * an IHdfWriteable tree from an HDF5 file. - *

- * - * @author Eric J. Lingerfelt - */ -public interface IHdfReader { - /** - *

- * This operation creates and populates an IHdfWriteable instance and its - * children from the HDF5 file at the provided URI. If any error or failure - * to read is encountered, then null is returned. - *

- * - * @param uri - *

- * The URI of the H5File. - *

- * @return - *

- * The IHdfreadable instance created and populated from the H5File - * at uri. - *

- */ - public IHdfReadable read(URI uri); -} \ No newline at end of file diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfWriteable.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfWriteable.java deleted file mode 100644 index 8c66e91e1..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfWriteable.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import java.util.ArrayList; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -/** - *

- * An interface that provides the required operations for populating an HDF5 - * file from an ICE data structure. - *

- * - * @author Eric J. Lingerfelt - */ -public interface IHdfWriteable { - /** - *

- * This operation creates and returns a child H5Group for the parentH5Group - * in the h5File. If h5File is null or can not be opened, then null is - * returned. If parentH5Group is null, then null is returned. If an - * exception is thrown, then null is returned. - *

- * - * @param h5File - *

- * The H5File. - *

- * @param parentH5Group - *

- * The parent H5Group. - *

- * @return - *

- * The new H5Group. - *

- */ - public H5Group createGroup(H5File h5File, H5Group parentH5Group); - - /** - *

- * This operation returns an ArrayList of IHdfWriteable child objects. If - * this IHdfWriteable has no IHdfWriteable child objects, then null is - * returned. - *

- * - * @return - *

- * An ArrayList of IHdfWriteable child objects. - *

- */ - public ArrayList getWriteableChildren(); - - /** - *

- * This operation writes HDF5 Attributes to the metadata of h5Group in the - * h5File. If the h5Group is null or h5File is null or can not be opened, - * then false is returned. If the operation fails to write all Attributes, - * then false is returned. Otherwise, true is returned. - *

- * - * @param h5File - *

- * The H5File. - *

- * @param h5Group - *

- * The H5Group to write Attributes to. - *

- * @return - *

- * If the h5Group is null or h5File is null or can not be opened, - * then false is returned. If the operation fails to write all - * Attributes, then false is returned. Otherwise, true is returned. - *

- */ - public boolean writeAttributes(H5File h5File, H5Group h5Group); - - /** - *

- * This operation writes HDF5 Datasets to the h5Group in the h5File. If the - * h5Group is null or h5File is null or can not be opened, then false is - * returned. If the operation fails to write all Datasets, then false is - * returned. Otherwise, true is returned. - *

- * - * @param h5File - *

- * The H5File. - *

- * @param h5Group - *

- * The H5Group to write Datasets to. - *

- * @return - *

- * If the h5Group is null or h5File is null or can not be opened, - * then false is returned. If the operation fails to write all - * Datasets, then false is returned. Otherwise, true is returned. - *

- */ - public boolean writeDatasets(H5File h5File, H5Group h5Group); -} \ No newline at end of file diff --git a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfWriter.java b/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfWriter.java deleted file mode 100644 index daae1ec41..000000000 --- a/org.eclipse.ice.io/src/org/eclipse/ice/io/hdf/IHdfWriter.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.io.hdf; - -import java.net.URI; - -/** - *

- * An interface that provides the required operations for writing an - * IHdfWriteable tree to an HDF5 file. - *

- * - * @author Eric J. Lingerfelt - */ -public interface IHdfWriter { - /** - *

- * This operation writes an IHdfWriteable to the HDF5 file at the provided - * URI. If any error or failure to write is encountered, then false is - * returned. Otherwise, true is returned. - *

- * - * @param iHdfWriteable - *

- * The IHdfWriteable instance to write to the H5File at uri. - *

- * @param uri - *

- * The URI of the H5File to write to. - *

- * @return - *

- * If any error or failure to write is encountered, then false is - * returned. Otherwise, true is returned. - *

- */ - public boolean write(IHdfWriteable iHdfWriteable, URI uri); -} \ No newline at end of file diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/IPersistenceProviderTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/IPersistenceProviderTester.java index 8ea977351..36e7a8d85 100644 --- a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/IPersistenceProviderTester.java +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/IPersistenceProviderTester.java @@ -12,7 +12,6 @@ package org.eclipse.ice.item.test; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import org.eclipse.core.runtime.CoreException; import org.eclipse.ice.item.persistence.IPersistenceProvider; diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ItemTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ItemTester.java index 8641ae801..a2e31eae3 100644 --- a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ItemTester.java +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/ItemTester.java @@ -46,15 +46,12 @@ import org.eclipse.ice.datastructures.resource.ICEResource; import org.eclipse.ice.datastructures.resource.VizResource; import org.eclipse.ice.io.serializable.IIOService; -import org.eclipse.ice.io.serializable.IOService; import org.eclipse.ice.io.serializable.IReader; import org.eclipse.ice.io.serializable.IWriter; import org.eclipse.ice.item.Item; import org.eclipse.ice.item.ItemListener; import org.eclipse.ice.item.ItemType; import org.eclipse.ice.item.messaging.Message; -import org.eclipse.ice.item.persistence.IPersistenceProvider; -import org.eclipse.ice.persistence.xml.XMLPersistenceProvider; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/MOOSEFileHandlerTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/MOOSEFileHandlerTester.java index beb37479d..7b12a8729 100644 --- a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/MOOSEFileHandlerTester.java +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/moose/MOOSEFileHandlerTester.java @@ -25,7 +25,6 @@ import org.eclipse.ice.datastructures.form.AdaptiveTreeComposite; import org.eclipse.ice.datastructures.form.DataComponent; -import org.eclipse.ice.datastructures.form.Entry; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.item.utilities.moose.MOOSEFileHandler; import org.eclipse.ice.item.utilities.moose.Parameter; diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSELauncherTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSELauncherTester.java index 4ed2a21b3..7e54060a4 100644 --- a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSELauncherTester.java +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSELauncherTester.java @@ -36,10 +36,8 @@ import org.eclipse.ice.datastructures.form.DataComponent; import org.eclipse.ice.datastructures.form.Entry; import org.eclipse.ice.io.serializable.IIOService; -import org.eclipse.ice.io.serializable.IOService; import org.eclipse.ice.item.nuclear.MOOSE; import org.eclipse.ice.item.nuclear.MOOSELauncher; -import org.eclipse.ice.item.nuclear.MOOSEModel; import org.eclipse.ice.item.test.FakeIOService; import org.eclipse.ice.item.utilities.moose.MOOSEFileHandler; import org.junit.AfterClass; diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java index 83316e8ec..6aa2d0f3f 100644 --- a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java @@ -41,7 +41,6 @@ import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.io.serializable.IIOService; -import org.eclipse.ice.io.serializable.IOService; import org.eclipse.ice.item.nuclear.MOOSE; import org.eclipse.ice.item.nuclear.MOOSEModel; import org.eclipse.ice.item.test.FakeIOService; diff --git a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSETester.java b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSETester.java index d28cf8709..55d66ceb2 100644 --- a/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSETester.java +++ b/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSETester.java @@ -40,21 +40,16 @@ import org.eclipse.core.runtime.Path; import org.eclipse.ice.datastructures.ICEObject.Component; import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler; -import org.eclipse.ice.datastructures.form.AdaptiveTreeComposite; import org.eclipse.ice.datastructures.form.DataComponent; import org.eclipse.ice.datastructures.form.Entry; import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.form.FormStatus; import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.datastructures.jaxbclassprovider.ICEJAXBClassProvider; import org.eclipse.ice.io.serializable.IIOService; -import org.eclipse.ice.io.serializable.IOService; -import org.eclipse.ice.item.jobLauncher.JobLauncher; -import org.eclipse.ice.item.nuclear.MOOSELauncher; +import org.eclipse.ice.item.nuclear.MOOSE; import org.eclipse.ice.item.nuclear.MOOSEModel; import org.eclipse.ice.item.test.FakeIOService; -import org.eclipse.ice.item.nuclear.MOOSE; import org.eclipse.ice.item.utilities.moose.MOOSEFileHandler; import org.junit.AfterClass; import org.junit.BeforeClass; diff --git a/org.eclipse.ice.item/src/org/eclipse/ice/item/Item.java b/org.eclipse.ice.item/src/org/eclipse/ice/item/Item.java index 655c597ed..81a066d49 100644 --- a/org.eclipse.ice.item/src/org/eclipse/ice/item/Item.java +++ b/org.eclipse.ice.item/src/org/eclipse/ice/item/Item.java @@ -64,12 +64,12 @@ import org.eclipse.ice.datastructures.form.MasterDetailsComponent; import org.eclipse.ice.datastructures.form.MatrixComponent; import org.eclipse.ice.datastructures.form.MeshComponent; +import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.form.TableComponent; import org.eclipse.ice.datastructures.form.TimeDataComponent; import org.eclipse.ice.datastructures.form.TreeComposite; import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.datastructures.form.MeshComponent; import org.eclipse.ice.datastructures.form.painfullySimpleForm.PainfullySimpleForm; import org.eclipse.ice.datastructures.resource.ICEResource; import org.eclipse.ice.datastructures.resource.ResourceHandler; diff --git a/org.eclipse.ice.item/src/org/eclipse/ice/item/action/JobLaunchAction.java b/org.eclipse.ice.item/src/org/eclipse/ice/item/action/JobLaunchAction.java index 77074697e..2c48819aa 100644 --- a/org.eclipse.ice.item/src/org/eclipse/ice/item/action/JobLaunchAction.java +++ b/org.eclipse.ice.item/src/org/eclipse/ice/item/action/JobLaunchAction.java @@ -16,15 +16,12 @@ import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.UnknownHostException; -import java.nio.file.Files; -import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; @@ -37,7 +34,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileInfo; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -53,7 +49,6 @@ import org.eclipse.remote.core.IRemoteConnectionHostService; import org.eclipse.remote.core.IRemoteConnectionType; import org.eclipse.remote.core.IRemoteConnectionWorkingCopy; -import org.eclipse.remote.core.IRemoteFileService; import org.eclipse.remote.core.IRemoteProcess; import org.eclipse.remote.core.IRemoteProcessBuilder; import org.eclipse.remote.core.IRemoteProcessService; diff --git a/org.eclipse.ice.item/src/org/eclipse/ice/item/action/RemoteFileUploadAction.java b/org.eclipse.ice.item/src/org/eclipse/ice/item/action/RemoteFileUploadAction.java index 2e6021f85..195df83a2 100644 --- a/org.eclipse.ice.item/src/org/eclipse/ice/item/action/RemoteFileUploadAction.java +++ b/org.eclipse.ice.item/src/org/eclipse/ice/item/action/RemoteFileUploadAction.java @@ -13,8 +13,6 @@ package org.eclipse.ice.item.action; import java.io.File; -import java.text.SimpleDateFormat; -import java.util.Date; import java.util.Dictionary; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSE.java b/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSE.java index c55c19faa..61abb0b6a 100644 --- a/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSE.java +++ b/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSE.java @@ -14,17 +14,13 @@ import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.PrintWriter; import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.HashMap; -import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; @@ -32,7 +28,6 @@ import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.ice.datastructures.ICEObject.Component; import org.eclipse.ice.datastructures.ICEObject.IUpdateable; diff --git a/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSELauncher.java b/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSELauncher.java index b9ef3b15b..0c6b9acbf 100644 --- a/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSELauncher.java +++ b/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSELauncher.java @@ -24,7 +24,6 @@ import org.eclipse.ice.datastructures.form.Entry; import org.eclipse.ice.datastructures.form.Form; import org.eclipse.ice.datastructures.form.FormStatus; -import org.eclipse.ice.item.jobLauncher.JobLauncherForm; import org.eclipse.ice.item.jobLauncher.SuiteLauncher; /** diff --git a/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/RemoteYamlSyntaxGenerator.java b/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/RemoteYamlSyntaxGenerator.java index 2d58b9414..8c8bdc623 100644 --- a/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/RemoteYamlSyntaxGenerator.java +++ b/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/RemoteYamlSyntaxGenerator.java @@ -12,23 +12,13 @@ package org.eclipse.ice.item.nuclear; import java.io.File; -import java.io.IOException; -import java.io.InputStream; import java.io.PrintStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Dictionary; -import org.apache.commons.io.IOUtils; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileInfo; import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.ice.datastructures.form.FormStatus; import org.eclipse.ice.item.action.Action; import org.eclipse.remote.core.IRemoteConnection; diff --git a/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/SHARPModelBuilder.java b/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/SHARPModelBuilder.java index 280df12d2..4c49eba70 100644 --- a/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/SHARPModelBuilder.java +++ b/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/SHARPModelBuilder.java @@ -13,8 +13,8 @@ package org.eclipse.ice.item.nuclear; import org.eclipse.core.resources.IProject; -import org.eclipse.ice.item.Item; import org.eclipse.ice.item.AbstractItemBuilder; +import org.eclipse.ice.item.Item; import org.eclipse.ice.item.ItemType; /** diff --git a/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/MaterialStackWritableTableFormatTest.java b/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/MaterialStackWritableTableFormatTest.java index aeeaab4bb..984edf965 100644 --- a/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/MaterialStackWritableTableFormatTest.java +++ b/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/MaterialStackWritableTableFormatTest.java @@ -11,7 +11,8 @@ *******************************************************************************/ package org.eclipse.ice.materials.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.eclipse.ice.datastructures.form.Material; import org.eclipse.ice.datastructures.form.MaterialStack; diff --git a/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/SingleMaterialWritableTableFormatTester.java b/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/SingleMaterialWritableTableFormatTester.java index 652c9e770..dc8fef071 100644 --- a/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/SingleMaterialWritableTableFormatTester.java +++ b/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/SingleMaterialWritableTableFormatTester.java @@ -11,7 +11,8 @@ *******************************************************************************/ package org.eclipse.ice.materials.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.eclipse.ice.datastructures.form.Material; import org.eclipse.ice.materials.SingleMaterialWritableTableFormat; diff --git a/org.eclipse.ice.nek5000/src/org/eclipse/ice/nek5000/NekWriter.java b/org.eclipse.ice.nek5000/src/org/eclipse/ice/nek5000/NekWriter.java index 11ddff12c..ee249299c 100644 --- a/org.eclipse.ice.nek5000/src/org/eclipse/ice/nek5000/NekWriter.java +++ b/org.eclipse.ice.nek5000/src/org/eclipse/ice/nek5000/NekWriter.java @@ -12,6 +12,19 @@ *******************************************************************************/ package org.eclipse.ice.nek5000; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; + import org.eclipse.ice.datastructures.ICEObject.Component; import org.eclipse.ice.datastructures.ICEObject.ListComponent; import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; @@ -32,20 +45,7 @@ import org.eclipse.ice.viz.service.mesh.datastructures.BoundaryConditionType; import org.eclipse.ice.viz.service.mesh.datastructures.Edge; import org.eclipse.ice.viz.service.mesh.datastructures.Quad; -import org.eclipse.ice.viz.service.mesh.datastructures.Vertex; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; +import org.eclipse.ice.viz.service.mesh.datastructures.Vertex; /** * This class is responsible for writing the contents of a Component collection diff --git a/org.eclipse.ice.persistence.xml.test/src/org/eclipse/ice/persistence/xml/test/XMLPersistenceExtensionFactoryTester.java b/org.eclipse.ice.persistence.xml.test/src/org/eclipse/ice/persistence/xml/test/XMLPersistenceExtensionFactoryTester.java index ced7612b2..aec1542c6 100644 --- a/org.eclipse.ice.persistence.xml.test/src/org/eclipse/ice/persistence/xml/test/XMLPersistenceExtensionFactoryTester.java +++ b/org.eclipse.ice.persistence.xml.test/src/org/eclipse/ice/persistence/xml/test/XMLPersistenceExtensionFactoryTester.java @@ -11,7 +11,9 @@ *******************************************************************************/ package org.eclipse.ice.persistence.xml.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.eclipse.core.runtime.CoreException; import org.eclipse.ice.persistence.xml.XMLPersistenceExtensionFactory; diff --git a/org.eclipse.ice.persistence.xml.test/src/org/eclipse/ice/persistence/xml/test/XMLPersistenceProviderTester.java b/org.eclipse.ice.persistence.xml.test/src/org/eclipse/ice/persistence/xml/test/XMLPersistenceProviderTester.java index 9806bad7c..6cb5235ae 100644 --- a/org.eclipse.ice.persistence.xml.test/src/org/eclipse/ice/persistence/xml/test/XMLPersistenceProviderTester.java +++ b/org.eclipse.ice.persistence.xml.test/src/org/eclipse/ice/persistence/xml/test/XMLPersistenceProviderTester.java @@ -21,8 +21,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.net.URI; import java.util.ArrayList; @@ -32,15 +30,12 @@ import javax.xml.bind.Unmarshaller; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.ice.datastructures.form.Form; import org.eclipse.ice.datastructures.jaxbclassprovider.ICEJAXBClassProvider; import org.eclipse.ice.item.Item; diff --git a/org.eclipse.ice.persistence.xml/META-INF/MANIFEST.MF b/org.eclipse.ice.persistence.xml/META-INF/MANIFEST.MF index 37d7bab9e..ae52e1cc2 100644 --- a/org.eclipse.ice.persistence.xml/META-INF/MANIFEST.MF +++ b/org.eclipse.ice.persistence.xml/META-INF/MANIFEST.MF @@ -7,7 +7,6 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: org.eclipse.ice.core.iCore, org.eclipse.ice.datastructures.ICEObject, org.eclipse.ice.io.serializable, - org.eclipse.ice.reactorAnalyzer, org.slf4j;version="1.7.2" Require-Bundle: org.eclipse.core.resources;bundle-version="3.8.1", org.eclipse.core.runtime;bundle-version="3.8.0", diff --git a/org.eclipse.ice.persistence.xml/src/org/eclipse/ice/persistence/xml/XMLPersistenceProvider.java b/org.eclipse.ice.persistence.xml/src/org/eclipse/ice/persistence/xml/XMLPersistenceProvider.java index f106a2db6..a4b3c61fa 100644 --- a/org.eclipse.ice.persistence.xml/src/org/eclipse/ice/persistence/xml/XMLPersistenceProvider.java +++ b/org.eclipse.ice.persistence.xml/src/org/eclipse/ice/persistence/xml/XMLPersistenceProvider.java @@ -40,7 +40,6 @@ import org.eclipse.ice.item.Item; import org.eclipse.ice.item.ItemBuilder; import org.eclipse.ice.item.persistence.IPersistenceProvider; -import org.eclipse.ice.reactorAnalyzer.ReactorAnalyzer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -453,7 +452,7 @@ private void processTask(QueuedTask currentTask) { file = currentTask.item.getProject().getFile(name); } // Process persists - if ("persist".equals(currentTask.task) && !(currentTask.item instanceof ReactorAnalyzer)) { + if ("persist".equals(currentTask.task)) { // Send the Item off to be written to the file writeFile(currentTask.item, file); // Update the item id map diff --git a/org.eclipse.ice.poly/.classpath b/org.eclipse.ice.poly/.classpath deleted file mode 100644 index eca7bdba8..000000000 --- a/org.eclipse.ice.poly/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.poly/.gitignore b/org.eclipse.ice.poly/.gitignore deleted file mode 100644 index ae3c17260..000000000 --- a/org.eclipse.ice.poly/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/org.eclipse.ice.poly/.project b/org.eclipse.ice.poly/.project deleted file mode 100644 index bc9866dad..000000000 --- a/org.eclipse.ice.poly/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - org.eclipse.ice.poly - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.poly/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.poly/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0c68a61dc..000000000 --- a/org.eclipse.ice.poly/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/org.eclipse.ice.poly/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.poly/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 706f07e8a..000000000 --- a/org.eclipse.ice.poly/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -pluginProject.extensions=true -resolve.requirebundle=false diff --git a/org.eclipse.ice.poly/META-INF/MANIFEST.MF b/org.eclipse.ice.poly/META-INF/MANIFEST.MF deleted file mode 100644 index ac2559146..000000000 --- a/org.eclipse.ice.poly/META-INF/MANIFEST.MF +++ /dev/null @@ -1,13 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Poly -Bundle-SymbolicName: org.eclipse.ice.poly;singleton:=true -Bundle-Version: 2.1.7.20150825 -Bundle-Vendor: Oak Ridge National Laboratory -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Import-Package: org.eclipse.ice.item, - org.eclipse.ice.item.jobLauncher, - org.slf4j;version="1.7.2" -Require-Bundle: org.eclipse.core.resources;bundle-version="3.10.0", - org.eclipse.ice.datastructures -Service-Component: OSGI-INF/polyComponent.xml diff --git a/org.eclipse.ice.poly/OSGI-INF/polyComponent.xml b/org.eclipse.ice.poly/OSGI-INF/polyComponent.xml deleted file mode 100644 index 2bf79bde7..000000000 --- a/org.eclipse.ice.poly/OSGI-INF/polyComponent.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.poly/build.properties b/org.eclipse.ice.poly/build.properties deleted file mode 100644 index 11fbb378e..000000000 --- a/org.eclipse.ice.poly/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/polyComponent.xml,\ - plugin.xml -source.. = src/ diff --git a/org.eclipse.ice.poly/plugin.xml b/org.eclipse.ice.poly/plugin.xml deleted file mode 100644 index 0a6954a0a..000000000 --- a/org.eclipse.ice.poly/plugin.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/org.eclipse.ice.poly/src/org/eclipse/ice/poly/PolyItemBuilder.java b/org.eclipse.ice.poly/src/org/eclipse/ice/poly/PolyItemBuilder.java deleted file mode 100644 index 36e4ff3bc..000000000 --- a/org.eclipse.ice.poly/src/org/eclipse/ice/poly/PolyItemBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Rajeev Kumar - *******************************************************************************/ -package org.eclipse.ice.poly; - -import org.eclipse.core.resources.IProject; -import org.eclipse.ice.item.AbstractItemBuilder; -import org.eclipse.ice.item.Item; -import org.eclipse.ice.item.ItemType; - -/** - * @author Jay Jay Billings, Rajeev Kumar - * - */ -public class PolyItemBuilder extends AbstractItemBuilder { - - /** - * The name that should be used for the Item and this builder - */ - public static final String name = "Poly Launcher"; - - /** - * The type of the Item - */ - public static final ItemType type = ItemType.Simulation; - - /** - * The Constructor - */ - public PolyItemBuilder() { - setName(name); - setType(type); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.item.AbstractItemBuilder#getInstance(org.eclipse.core.resources.IProject) - */ - @Override - public Item getInstance(IProject project) { - return new PolyJobLauncher(project); - } - -} diff --git a/org.eclipse.ice.poly/src/org/eclipse/ice/poly/PolyJobLauncher.java b/org.eclipse.ice.poly/src/org/eclipse/ice/poly/PolyJobLauncher.java deleted file mode 100644 index 0cb4d7164..000000000 --- a/org.eclipse.ice.poly/src/org/eclipse/ice/poly/PolyJobLauncher.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Rajeev Kumar - *******************************************************************************/ -package org.eclipse.ice.poly; - -import javax.xml.bind.annotation.XmlRootElement; - -import org.eclipse.core.resources.IProject; -import org.eclipse.ice.datastructures.form.AllowedValueType; -import org.eclipse.ice.datastructures.form.DataComponent; -import org.eclipse.ice.datastructures.form.Entry; -import org.eclipse.ice.datastructures.form.FormStatus; -import org.eclipse.ice.item.jobLauncher.JobLauncher; -import org.eclipse.ice.item.jobLauncher.JobLauncherForm; - -/** - * @author Jay Jay Billings, Rajeev Kumar - * - */ -@XmlRootElement(name = "PolyLauncher") -public class PolyJobLauncher extends JobLauncher { - - PolyJobLauncher() { - this(null); - } - - PolyJobLauncher(IProject project) { - super(project); - } - - /** - * This operation sets the information that identifies this Item. - */ - @Override - protected void setupItemInfo() { - - // Local declarations - String description = "Poly simulates polymers using " - + "self-consistent field theory."; - - // Set the model defaults - setName(PolyItemBuilder.name); - setDescription(description); - setItemBuilderName(PolyItemBuilder.name); - - return; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.item.jobLauncher.JobLauncher#setupForm() - */ - @Override - protected void setupForm() { - - // Setup the Form - super.setupForm(); - - // Create a data component for the working directory - DataComponent workingDirComponent = new DataComponent(); - workingDirComponent.setName("Working Directory Parameters"); - workingDirComponent.setId(JobLauncherForm.parallelId + 2); - workingDirComponent - .setDescription("Parameters for the Working Directory"); - form.addComponent(workingDirComponent); - // Create the Entry - Entry fileEntry = new Entry() { - @Override - public void setup() { - allowedValueType = AllowedValueType.Undefined; - } - }; - fileEntry.setId(1); - fileEntry.setName("Working Directory"); - fileEntry.setDescription("The working directory"); - workingDirComponent.addEntry(fileEntry); - - // Add localhost - setExecutable("poly", "Run Poly", "qsub"); - addHost("extb16l01.oic.ornl.gov", "linux", "${workingDir}"); - - return; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ice.item.jobLauncher.JobLauncher#process(java.lang.String) - */ - @Override - public FormStatus process(String actionName) { - - DataComponent workingDirComp = (DataComponent) form - .getComponent(JobLauncherForm.parallelId + 2); - String workingDirName = workingDirComp - .retrieveEntry("Working Directory").getValue(); - - setExecutable("poly", "Run Poly", "cd " + workingDirName + ";qsub"); - - return super.process(actionName); - } -} diff --git a/org.eclipse.ice.proteus.test/META-INF/MANIFEST.MF b/org.eclipse.ice.proteus.test/META-INF/MANIFEST.MF index 8c7fbc3db..de1060516 100644 --- a/org.eclipse.ice.proteus.test/META-INF/MANIFEST.MF +++ b/org.eclipse.ice.proteus.test/META-INF/MANIFEST.MF @@ -9,8 +9,11 @@ Require-Bundle: org.junit;bundle-version="4.8.2", org.eclipse.core.resources;bundle-version="3.7.100", org.eclipse.ice.item;bundle-version="2.0.0", org.eclipse.ice.datastructures -Import-Package: org.eclipse.ice.core.iCore, +Import-Package: org.eclipse.core.runtime;version="3.5.0", + org.eclipse.ice.core.iCore, org.eclipse.ice.datastructures.ICEObject, org.eclipse.ice.datastructures.form.painfullySimpleForm, - org.eclipse.ice.persistence.xml + org.eclipse.ice.persistence.xml, + org.eclipse.ice.proteus, + org.eclipse.ice.viz.service.datastructures.resource Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSLauncherBuilderTester.java b/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSLauncherBuilderTester.java index 72bd91ffd..f2901ebca 100644 --- a/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSLauncherBuilderTester.java +++ b/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSLauncherBuilderTester.java @@ -12,7 +12,7 @@ *******************************************************************************/ package org.eclipse.ice.proteus.test; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import org.eclipse.ice.item.ItemType; import org.eclipse.ice.proteus.PROTEUSLauncher; diff --git a/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSLauncherTester.java b/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSLauncherTester.java index b19d43153..b9e75071d 100644 --- a/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSLauncherTester.java +++ b/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSLauncherTester.java @@ -12,10 +12,7 @@ *******************************************************************************/ package org.eclipse.ice.proteus.test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.io.File; import java.net.URI; diff --git a/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSModelBuilderTester.java b/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSModelBuilderTester.java index 28c0cb693..76dff297d 100644 --- a/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSModelBuilderTester.java +++ b/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSModelBuilderTester.java @@ -12,8 +12,7 @@ *******************************************************************************/ package org.eclipse.ice.proteus.test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.*; import org.eclipse.ice.item.ItemType; import org.eclipse.ice.proteus.PROTEUSModel; diff --git a/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSModelTester.java b/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSModelTester.java index 52d2aa514..cc31dc566 100644 --- a/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSModelTester.java +++ b/org.eclipse.ice.proteus.test/src/org/eclipse/ice/proteus/test/PROTEUSModelTester.java @@ -12,10 +12,7 @@ *******************************************************************************/ package org.eclipse.ice.proteus.test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.IOException; diff --git a/org.eclipse.ice.reactor.perspective/.classpath b/org.eclipse.ice.reactor.perspective/.classpath deleted file mode 100644 index 098194ca4..000000000 --- a/org.eclipse.ice.reactor.perspective/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.reactor.perspective/.gitignore b/org.eclipse.ice.reactor.perspective/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.reactor.perspective/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.reactor.perspective/.project b/org.eclipse.ice.reactor.perspective/.project deleted file mode 100644 index 27f152386..000000000 --- a/org.eclipse.ice.reactor.perspective/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - org.eclipse.ice.reactor.perspective - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.reactor.perspective/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.reactor.perspective/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f42de363a..000000000 --- a/org.eclipse.ice.reactor.perspective/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/org.eclipse.ice.reactor.perspective/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.reactor.perspective/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 4b0893777..000000000 --- a/org.eclipse.ice.reactor.perspective/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -pluginProject.extensions=false diff --git a/org.eclipse.ice.reactor.perspective/META-INF/MANIFEST.MF b/org.eclipse.ice.reactor.perspective/META-INF/MANIFEST.MF deleted file mode 100644 index e2ff5da18..000000000 --- a/org.eclipse.ice.reactor.perspective/META-INF/MANIFEST.MF +++ /dev/null @@ -1,37 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: ICE Reactors Component -Bundle-SymbolicName: org.eclipse.ice.reactor.perspective;singleton:=true -Bundle-Version: 2.1.8 -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Import-Package: org.eclipse.ice.client.widgets, - org.eclipse.ice.client.widgets.reactoreditor, - org.eclipse.ice.datastructures.ICEObject, - org.eclipse.ice.datastructures.componentVisitor, - org.eclipse.ice.datastructures.form, - org.eclipse.ice.datastructures.resource, - org.eclipse.ice.iclient, - org.eclipse.ice.io.hdf, - org.eclipse.ice.reactor, - org.eclipse.ice.reactor.bwr, - org.eclipse.ice.reactor.pwr, - org.eclipse.ice.reactor.sfr.base, - org.eclipse.ice.reactor.sfr.core, - org.eclipse.ice.reactor.sfr.core.assembly, - org.eclipse.ice.reactorAnalyzer, - org.eclipse.swt, - org.eclipse.swt.widgets, - org.eclipse.ui, - org.eclipse.ui.part, - org.eclipse.ui.views, - org.eclipse.ui.views.contentoutline, - org.eclipse.ui.views.properties, - org.eclipse.ui.views.properties.tabbed, - org.slf4j;version="1.7.2" -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.9.100", - org.eclipse.ice.client.compatibility;bundle-version="2.0.0", - org.eclipse.ice.datastructures -Export-Package: org.eclipse.ice.reactor.perspective -Service-Component: OSGI-INF/ReactorEditorRegistry.xml,OSGI-INF/ReactorClientHolder.xml, - OSGI-INF/IORegistryHolder.xml -Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.reactor.perspective/OSGI-INF/IORegistryHolder.xml b/org.eclipse.ice.reactor.perspective/OSGI-INF/IORegistryHolder.xml deleted file mode 100644 index 630136a8c..000000000 --- a/org.eclipse.ice.reactor.perspective/OSGI-INF/IORegistryHolder.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/org.eclipse.ice.reactor.perspective/OSGI-INF/ReactorClientHolder.xml b/org.eclipse.ice.reactor.perspective/OSGI-INF/ReactorClientHolder.xml deleted file mode 100644 index 63763b8a6..000000000 --- a/org.eclipse.ice.reactor.perspective/OSGI-INF/ReactorClientHolder.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/org.eclipse.ice.reactor.perspective/OSGI-INF/ReactorEditorRegistry.xml b/org.eclipse.ice.reactor.perspective/OSGI-INF/ReactorEditorRegistry.xml deleted file mode 100644 index a8e262106..000000000 --- a/org.eclipse.ice.reactor.perspective/OSGI-INF/ReactorEditorRegistry.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/org.eclipse.ice.reactor.perspective/ReactorsRCPApp.launch b/org.eclipse.ice.reactor.perspective/ReactorsRCPApp.launch deleted file mode 100644 index dfc6b5139..000000000 --- a/org.eclipse.ice.reactor.perspective/ReactorsRCPApp.launch +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.eclipse.ice.reactor.perspective/about.html b/org.eclipse.ice.reactor.perspective/about.html deleted file mode 100644 index b47b18406..000000000 --- a/org.eclipse.ice.reactor.perspective/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

July 1, 2014

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/org.eclipse.ice.reactor.perspective/build.properties b/org.eclipse.ice.reactor.perspective/build.properties deleted file mode 100644 index cbb60cd0a..000000000 --- a/org.eclipse.ice.reactor.perspective/build.properties +++ /dev/null @@ -1,13 +0,0 @@ -output.. = bin/ -bin.includes = .,\ - META-INF/,\ - plugin.xml,\ - build.properties,\ - icons/,\ - schema/,\ - OSGI-INF/ -src.includes = ReactorsRCPApp.launch,\ - icons/,\ - schema/,\ - OSGI-INF/ -source.. = src/ diff --git a/org.eclipse.ice.reactor.perspective/icons/add.png b/org.eclipse.ice.reactor.perspective/icons/add.png deleted file mode 100644 index 29b5f22d7..000000000 Binary files a/org.eclipse.ice.reactor.perspective/icons/add.png and /dev/null differ diff --git a/org.eclipse.ice.reactor.perspective/icons/analyze.png b/org.eclipse.ice.reactor.perspective/icons/analyze.png deleted file mode 100644 index d20b32c19..000000000 Binary files a/org.eclipse.ice.reactor.perspective/icons/analyze.png and /dev/null differ diff --git a/org.eclipse.ice.reactor.perspective/icons/compare.png b/org.eclipse.ice.reactor.perspective/icons/compare.png deleted file mode 100644 index e65704a03..000000000 Binary files a/org.eclipse.ice.reactor.perspective/icons/compare.png and /dev/null differ diff --git a/org.eclipse.ice.reactor.perspective/icons/delete_X.png b/org.eclipse.ice.reactor.perspective/icons/delete_X.png deleted file mode 100644 index c64d2f5df..000000000 Binary files a/org.eclipse.ice.reactor.perspective/icons/delete_X.png and /dev/null differ diff --git a/org.eclipse.ice.reactor.perspective/icons/folder.gif b/org.eclipse.ice.reactor.perspective/icons/folder.gif deleted file mode 100644 index ab602f25d..000000000 Binary files a/org.eclipse.ice.reactor.perspective/icons/folder.gif and /dev/null differ diff --git a/org.eclipse.ice.reactor.perspective/icons/importArrow.png b/org.eclipse.ice.reactor.perspective/icons/importArrow.png deleted file mode 100644 index c8f0db4b3..000000000 Binary files a/org.eclipse.ice.reactor.perspective/icons/importArrow.png and /dev/null differ diff --git a/org.eclipse.ice.reactor.perspective/plugin.xml b/org.eclipse.ice.reactor.perspective/plugin.xml deleted file mode 100644 index 3c5881e50..000000000 --- a/org.eclipse.ice.reactor.perspective/plugin.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.eclipse.ice.reactor.perspective/pom.xml b/org.eclipse.ice.reactor.perspective/pom.xml deleted file mode 100644 index a88aa012c..000000000 --- a/org.eclipse.ice.reactor.perspective/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.reactor.perspective - eclipse-plugin - \ No newline at end of file diff --git a/org.eclipse.ice.reactor.perspective/schema/IAnalysisWidgetRegistry.exsd b/org.eclipse.ice.reactor.perspective/schema/IAnalysisWidgetRegistry.exsd deleted file mode 100644 index 2ee5d8f75..000000000 --- a/org.eclipse.ice.reactor.perspective/schema/IAnalysisWidgetRegistry.exsd +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/org.eclipse.ice.reactor.perspective/schema/IHdfIORegistry.exsd b/org.eclipse.ice.reactor.perspective/schema/IHdfIORegistry.exsd deleted file mode 100644 index d311a4c1d..000000000 --- a/org.eclipse.ice.reactor.perspective/schema/IHdfIORegistry.exsd +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/org.eclipse.ice.reactor.perspective/schema/org.eclipse.ui.actionSets.exsd b/org.eclipse.ice.reactor.perspective/schema/org.eclipse.ui.actionSets.exsd deleted file mode 100644 index 79411de57..000000000 --- a/org.eclipse.ice.reactor.perspective/schema/org.eclipse.ui.actionSets.exsd +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AddReactorPartAction.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AddReactorPartAction.java deleted file mode 100644 index ae1bfce5f..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AddReactorPartAction.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.ice.client.widgets.reactoreditor.IAnalysisWidgetFactory; -import org.eclipse.ice.client.widgets.reactoreditor.IAnalysisWidgetRegistry; -import org.eclipse.ice.reactor.perspective.internal.ReactorEditorRegistry; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.ViewPart; -import org.osgi.framework.Bundle; -import org.osgi.framework.FrameworkUtil; - -/** - * - * @author Taylor Patterson - */ -public class AddReactorPartAction extends Action { - - /** - * The ViewPart that owns an object of this class. - */ - private final ViewPart viewer; - - /** - * The constructor - * - * @param parent - * The ViewPart to whom the object of this class belongs. - */ - public AddReactorPartAction(ViewPart parent) { - - viewer = parent; - - // Set the action's tool tip text. - setText("Add reactor component"); - setToolTipText("Add a reactor component"); - - // Set the action's image (the green plus button for adding). - Bundle bundle = FrameworkUtil.getBundle(getClass()); - Path imagePath = new Path("icons" - + System.getProperty("file.separator") + "add.png"); - URL imageURL = FileLocator.find(bundle, imagePath, null); - ImageDescriptor imageDescriptor = ImageDescriptor - .createFromURL(imageURL); - setImageDescriptor(imageDescriptor); - - return; - } - - /** - * The function called whenever the action is clicked. - */ - @Override - public void run() { - // Get the selection in the Reactor Viewer. - Object selection = ((ReactorViewer) viewer).getSelectedElement(); - - if (selection != null) { - - // Get the registry - IAnalysisWidgetRegistry registry = ReactorEditorRegistry - .getAnalysisWidgetRegistry(); - - // Get the factory - IAnalysisWidgetFactory factory = registry - .getAnalysisWidgetFactory(registry.getClass()); - - // Get the wizard - IWizard wizard = factory.createWizard(selection); - - // Get the Shell of the workbench - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - - // Create a WizardDialog with an AddReactorPartWizard constructed - // with the selection in the Reactor Viewer. - WizardDialog dialog = new WizardDialog(shell, wizard); - - // Open the dialog - dialog.open(); - } - - return; - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AddReactorPartWizard.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AddReactorPartWizard.java deleted file mode 100644 index 858998824..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AddReactorPartWizard.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.jface.wizard.Wizard; - -/** - * This class creates wizards to generate and add reactor components to a .h5 - * file in the Reactor Viewer. The content of the wizard is determined by the - * type of selection input to the constructor. - * - * @author Taylor Patterson - */ -public class AddReactorPartWizard extends Wizard { - - /** - * The constructor - * - * @param selectedElement - */ - public AddReactorPartWizard(Object selectedElement) { - - // Call Wizard's constructor - super(); - - // Get the selection type. If the selection is an ICEResource, it is a - // .h5 file, and we can simply add the appropriate page to the wizard. - // If the selection is an IReactorComponent, use the visitor to discover - // its type and add the appropriate page to the wizard. - if (selectedElement instanceof ICEResource) { - // Add page for adding reactors to .h5 files - addPage(new AddReactorPartWizardPage((ICEResource) selectedElement)); - } else if (selectedElement instanceof IReactorComponent) { - // Add page for adding to an IReactorComponent - addPage(new AddReactorPartWizardPage( - (IReactorComponent) selectedElement)); - } - - return; - } - - /** - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.Wizard#performFinish() - */ - @Override - public boolean performFinish() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AddReactorPartWizardPage.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AddReactorPartWizardPage.java deleted file mode 100644 index 0c78ec5b8..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AddReactorPartWizardPage.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -/** - * This class creates wizard pages to provide the user with SWT widgets to - * create and add reactor parts to the selection in the Reactor Viewer. The - * content of the page is determined by the type of selection input to the - * constructor. - * - * @author Taylor Patterson - */ -public class AddReactorPartWizardPage extends WizardPage { - - /** - * The constructor for wizard pages for ICEResource selections in the - * Reactor Viewer. - * - * @param resource - * The ICEResource selection in the Reactor Viewer - */ - public AddReactorPartWizardPage(ICEResource resource) { - - // Call WizardPage's constructor - // TODO Consider better String input - resource.getName() was just a - // quick placeholder - super(resource.getName()); - - // Set the page's title and description - setTitle("Add a Reactor"); - setDescription("Use this page to add a reactor to the selected .h5 " - + "file"); - - return; - } - - /** - * The constructor for wizard pages for IReactorComponent selections in the - * Reactor Viewer. - * - * @param component - * The IReactorComponent selection in the Reactor Viewer - */ - public AddReactorPartWizardPage(IReactorComponent component) { - - // Call WizardPage's constructor - // TODO Consider better String input - component.getName() was just a - // quick placeholder - super(component.getName()); - - // TODO Use an IReactorComponent visitor to set these? - // Set the page's title and description - setTitle("Add a "); - setDescription("Use this page to add a to the ."); - - return; - } - - /** - * Create and layout the widgets to be included in the WizardPage. - * - * @param parent - * The parent Composite of the control to be created - * - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new FillLayout()); - - Label testLabel = new Label(composite, SWT.NONE); - testLabel.setText("Composite area for this page"); - - setControl(composite); - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AnalyzeInReactorEditorAction.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AnalyzeInReactorEditorAction.java deleted file mode 100644 index 4bfe66eed..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/AnalyzeInReactorEditorAction.java +++ /dev/null @@ -1,244 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.ice.client.widgets.reactoreditor.ReactorFormWidgetBuilder; -import org.eclipse.ice.iclient.IClient; -import org.eclipse.ice.reactor.perspective.internal.ReactorClientHolder; -import org.eclipse.ice.reactor.perspective.internal.ReactorEditorRegistry; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.part.ViewPart; -import org.osgi.framework.Bundle; -import org.osgi.framework.FrameworkUtil; - -/** - * This class looks up the currently open Reactor Editors using the - * {@link ReactorEditorRegistry} and tells the {@link ReactorViewer} to send its - * current selection to one of the Reactor Editors. - * - * @author Taylor Patterson, Jordan H. Deyton - */ -public class AnalyzeInReactorEditorAction extends Action { - - /** - * The name used by ICE for Reactor Editors. - */ - private final String editorName; - - /** - * The ViewPart that owns an object of this class. - */ - private final ViewPart viewer; - - /** - * The action that causes a new Reactor Editor to be created for the - * selection. - */ - private final Action newEditorAction; - - /** - * The constructor - * - * @param parent - * The ViewPart to whom the object of this class belongs. - */ - public AnalyzeInReactorEditorAction(ViewPart parent) { - // Create this action as a drop down menu. - super(null, IAction.AS_DROP_DOWN_MENU); - - viewer = parent; - - // Get the editor name from the ReactorFormWidgetBuilder. - editorName = ReactorFormWidgetBuilder.name; - - // Set the action's tool tip text. - setText("Analyze in..."); - setToolTipText("Open the selection in a " + editorName); - - // Set the action's image (the import arrow). - Bundle bundle = FrameworkUtil.getBundle(getClass()); - Path imagePath = new Path("icons" - + System.getProperty("file.separator") + "analyze.png"); - URL imageURL = FileLocator.find(bundle, imagePath, null); - ImageDescriptor imageDescriptor = ImageDescriptor - .createFromURL(imageURL); - setImageDescriptor(imageDescriptor); - - // Create the action that creates a new Reactor Analyzer and sets the - // input to the current selection in the TreeViewer. - newEditorAction = new Action() { - @Override - public void run() { - - // Create a new Reactor Analyzer and tell the viewer to pass the - // selection to it. - IClient client = ReactorClientHolder.getClient(); - if (client != null) { - int id = client.createItem(editorName); - ((ReactorViewer) viewer).showSelection(id); - } - - return; - } - }; - newEditorAction.setText("A new " + editorName); - newEditorAction.setToolTipText("Creates a new " + editorName + " to" - + " display the tree selection."); - - // Create the IMenuCreator that generates the menus for the - // ShowInReactorEditorAction. - final IMenuCreator menuCreator = new IMenuCreator() { - - /** - * The MenuManager that contains all of the actions that show the - * current selection in a Reactor Editor. - */ - private MenuManager menuManager = null; - /** - * The Menu of actions used in the ToolBar. - */ - private Menu dropdownMenu = null; - /** - * The Menu of actions used in the context Menu in the reactor - * TreeViewer. - */ - private Menu contextMenu = null; - - @Override - public void dispose() { - - // Dispose of the dropdown menu if possible. - if (dropdownMenu != null) { - dropdownMenu.dispose(); - dropdownMenu = null; - } - - // Dispose of the context menu if possible. - if (contextMenu != null) { - contextMenu.dispose(); - contextMenu = null; - } - - // Dispose of the MenuManager if possible. - if (menuManager != null) { - menuManager.removeAll(); - menuManager.dispose(); - menuManager = null; - } - - return; - } - - @Override - public Menu getMenu(Control parent) { - // Refresh the menu of actions. - updateMenuManager(); - - // Make sure any stale dropdown menu is disposed. - if (dropdownMenu != null) { - dropdownMenu.dispose(); - } - - // Refresh the dropdown menu. - dropdownMenu = menuManager.createContextMenu(parent); - - return dropdownMenu; - } - - @Override - public Menu getMenu(Menu parent) { - // Refresh the menu of actions. - updateMenuManager(); - - // Make sure any stale context menu is disposed. - if (contextMenu != null) { - contextMenu.dispose(); - } - // Refresh the context menu. We need to loop over the - // MenuManager's actions and add each of them to the context - // menu. - contextMenu = new Menu(parent); - for (IContributionItem item : menuManager.getItems()) { - item.fill(contextMenu, -1); - } - - return contextMenu; - } - - /** - * Refreshes the MenuManager with all available Reactor Editors. - */ - private void updateMenuManager() { - - // Make sure the MenuManager is empty. - if (menuManager == null) { - menuManager = new MenuManager(); - } else { - menuManager.removeAll(); - } - - // Add the item for creating a new Reactor Editor, followed by a - // separator. - menuManager.add(newEditorAction); - menuManager.add(new Separator()); - - // Add an item for each of the current Reactor Editors. - for (final int id : ReactorEditorRegistry.getEditorIds()) { - Action action = new Action() { - @Override - public void run() { - ((ReactorViewer) viewer).showSelection(id); - } - }; - action.setText(editorName + " " + id); - action.setToolTipText("Displays the tree selection in " - + editorName + " " + id); - menuManager.add(action); - } - - return; - } - }; - // Don't forget to set the menu creator for this action. - setMenuCreator(menuCreator); - - return; - } - - /** - * The function called whenever the action is clicked. - */ - @Override - public void run() { - - // TODO We may want to change this behavior. - - // Create a new Reactor Analyzer. - newEditorAction.run(); - - return; - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/CompareAction.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/CompareAction.java deleted file mode 100644 index 1dfbcb209..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/CompareAction.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import java.net.URL; -import java.util.List; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.ice.client.widgets.reactoreditor.ReactorFormWidgetBuilder; -import org.eclipse.ice.reactor.perspective.internal.ReactorEditorRegistry; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.part.ViewPart; -import org.osgi.framework.Bundle; -import org.osgi.framework.FrameworkUtil; - -/** - * This class looks up the currently open Reactor Editors using the - * {@link ReactorEditorRegistry} and tells the {@link ReactorViewer} to send its - * current selection to one of the Reactor Editors. - * - * @author Taylor Patterson, Jordan H. Deyton - */ -public class CompareAction extends Action { - - /** - * The name used by ICE for Reactor Editors. - */ - private final String editorName; - - /** - * The ViewPart that owns an object of this class. - */ - private final ViewPart viewer; - - /** - * The constructor - * - * @param parent - * The ViewPart to whom the object of this class belongs. - */ - public CompareAction(ViewPart parent) { - // Create this action as a drop down menu. - super(null, IAction.AS_DROP_DOWN_MENU); - - viewer = parent; - - // Get the editor name from the ReactorFormWidgetBuilder. - editorName = ReactorFormWidgetBuilder.name; - - // Set the action's tool tip text. - setText("Compare with..."); - setToolTipText("Compare with a component in an existing " + editorName); - - // Set the action's image (the import arrow). - Bundle bundle = FrameworkUtil.getBundle(getClass()); - Path imagePath = new Path("icons" - + System.getProperty("file.separator") + "compare.png"); - URL imageURL = FileLocator.find(bundle, imagePath, null); - ImageDescriptor imageDescriptor = ImageDescriptor - .createFromURL(imageURL); - setImageDescriptor(imageDescriptor); - - // Create the IMenuCreator that generates the menus for the - // ShowInReactorEditorAction. - final IMenuCreator menuCreator = new IMenuCreator() { - - /** - * The MenuManager that contains all of the actions that show the - * current selection in a Reactor Editor. - */ - private MenuManager menuManager = null; - /** - * The Menu of actions used in the ToolBar. - */ - private Menu dropdownMenu = null; - /** - * The Menu of actions used in the context Menu in the reactor - * TreeViewer. - */ - private Menu contextMenu = null; - - @Override - public void dispose() { - - // Dispose of the dropdown menu if possible. - if (dropdownMenu != null) { - dropdownMenu.dispose(); - dropdownMenu = null; - } - - // Dispose of the context menu if possible. - if (contextMenu != null) { - contextMenu.dispose(); - contextMenu = null; - } - - // Dispose of the MenuManager if possible. - if (menuManager != null) { - menuManager.removeAll(); - menuManager.dispose(); - menuManager = null; - } - - return; - } - - @Override - public Menu getMenu(Control parent) { - // Refresh the menu of actions. - updateMenuManager(); - - // Make sure any stale dropdown menu is disposed. - if (dropdownMenu != null) { - dropdownMenu.dispose(); - } - // Refresh the dropdown menu. - dropdownMenu = menuManager.createContextMenu(parent); - - return dropdownMenu; - } - - @Override - public Menu getMenu(Menu parent) { - // Refresh the menu of actions. - updateMenuManager(); - - // Make sure any stale context menu is disposed. - if (contextMenu != null) { - contextMenu.dispose(); - } - // Refresh the context menu. We need to loop over the - // MenuManager's actions and add each of them to the context - // menu. - contextMenu = new Menu(parent); - for (IContributionItem item : menuManager.getItems()) { - item.fill(contextMenu, -1); - } - - return contextMenu; - } - - /** - * Refreshes the MenuManager with all available Reactor Editors. - */ - private void updateMenuManager() { - - // Make sure the MenuManager is empty. - if (menuManager == null) { - menuManager = new MenuManager(); - } else { - menuManager.removeAll(); - } - - // Get the List of editor IDs. - List editorIds = ReactorEditorRegistry.getEditorIds(); - - // If the list of editors is empty, place an empty action to - // notify the user that they can't compare. - // TODO Disable the action if the list of editors is empty! - if (editorIds.isEmpty()) { - menuManager.add(new Action("No editor available.") { - // Nothing to do. Don't override run(). - }); - } - - // Add an item for each of the current Reactor Editors. - for (final int id : editorIds) { - Action action = new Action() { - @Override - public void run() { - ((ReactorViewer) viewer).compareSelection(id); - } - }; - action.setText(editorName + " " + id); - action.setToolTipText("Compares the tree selection with " - + editorName + " " + id); - menuManager.add(action); - } - - return; - } - }; - // Don't forget to set the menu creator for this action. - setMenuCreator(menuCreator); - - return; - } - - /** - * The function called whenever the action is clicked. - */ - @Override - public void run() { - - // TODO We may want to change this behavior to do something like compare - // with the currently-active reactor editor. - - return; - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/DeleteReactorPartAction.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/DeleteReactorPartAction.java deleted file mode 100644 index 51c205e00..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/DeleteReactorPartAction.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.part.ViewPart; -import org.osgi.framework.Bundle; -import org.osgi.framework.FrameworkUtil; - -/** - * - * @author Taylor Patterson - */ -public class DeleteReactorPartAction extends Action { - - /** - * The ViewPart that owns an object of this class. - */ - private final ViewPart viewer; - - /** - * The constructor - * - * @param parent - * The ViewPart to whom the object of this class belongs. - */ - public DeleteReactorPartAction(ViewPart parent) { - - viewer = parent; - - // Set the action's tool tip text. - setText("Delete reactor component"); - setToolTipText("Delete the selected reactor component"); - - // Set the action's image (the red x button). - Bundle bundle = FrameworkUtil.getBundle(getClass()); - Path imagePath = new Path("icons" - + System.getProperty("file.separator") + "delete_X.png"); - URL imageURL = FileLocator.find(bundle, imagePath, null); - ImageDescriptor imageDescriptor = ImageDescriptor - .createFromURL(imageURL); - setImageDescriptor(imageDescriptor); - - return; - } - - /** - * The function called whenever the action is clicked. - */ - @Override - public void run() { - - // Call the parent view's method to remove the current tree selection - // from its TreeViewer. - ((ReactorViewer) viewer).removeSelection(); - - return; - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/OpenReactorFileAction.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/OpenReactorFileAction.java deleted file mode 100644 index acfa6e1ec..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/OpenReactorFileAction.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import java.io.File; -import java.io.IOException; -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.ViewPart; -import org.osgi.framework.Bundle; -import org.osgi.framework.FrameworkUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This Action is used to open a FileDialog that allows the user to select - * compatible files as {@link ICEResource}s into a "Resources" View. - * - * @author Taylor Patterson - */ -public class OpenReactorFileAction extends Action { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(OpenReactorFileAction.class); - - /** - * The ViewPart that owns an object of this class. - */ - private final ViewPart viewer; - - /** - * The constructor - * - * @param parent - * The ViewPart to whom the object of this class belongs. - */ - public OpenReactorFileAction(ViewPart parent) { - viewer = parent; - - // Set the action's tool tip text. - setText("Open reactor file"); - setToolTipText("Open a new reactor file"); - - // Set the action's image (the folder button). - Bundle bundle = FrameworkUtil.getBundle(getClass()); - Path imagePath = new Path("icons" - + System.getProperty("file.separator") + "folder.gif"); - URL imageURL = FileLocator.find(bundle, imagePath, null); - ImageDescriptor imageDescriptor = ImageDescriptor - .createFromURL(imageURL); - setImageDescriptor(imageDescriptor); - - return; - } - - /** - * The function called whenever the action is clicked. - */ - @Override - public void run() { - - // Get the Shell of the workbench - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - - // Open the file system exploration dialog. Use SWT.OPEN for an open - // file dialog and SWT.MULTI to allow multi-selection of files. - FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI); - - // Filter files by *.h5 or all files. - String[] filterNames = new String[] { ".h5 Files", "All Files (*)" }; - String[] filterExtensions = new String[] { "*.h5", "*" }; - - // Check the OS and adjust if on Windows. - String platform = SWT.getPlatform(); - if ("win32".equals(platform) || "wpf".equals(platform)) { - filterNames[1] = "All Files (*.*)"; - filterExtensions[1] = "*.*"; - } - - // Set the dialog's file filters. - dialog.setFilterNames(filterNames); - dialog.setFilterExtensions(filterExtensions); - - // Get the OS file separator character. - String separator = System.getProperty("file.separator"); - - // Set the default location. - String filterPath = System.getProperty("user.home") + separator - + "ICEFiles" + separator + "default" + separator; - dialog.setFilterPath(filterPath); - - // If a file was selected in the dialog, create an ICEResource for it - // and add it to the viewer. - if (dialog.open() != null) { - // Get a reference to the VizFileViewer. - ReactorViewer reactorViewer = (ReactorViewer) viewer; - - // Loop over the selected files and create an ICEResource for each - // one. The resources can be passed to the VizFileViewer. - for (String fileName : dialog.getFileNames()) { - // Construct a file from the fileName. The names are relative to - // the dialog's filter path. - String filePath = dialog.getFilterPath() + separator + fileName; - File file = new File(filePath); - - // Try to construct an ICEResource from the File, then add it to - // the viewer. - try { - ICEResource resource = new ICEResource(file); - reactorViewer.addReactorFile(resource); - } catch (IOException e) { - System.err.println("OpenReactorFileAction error: " - + "Failed to create an ICEResource for the file at" - + " \"" + filePath + "\"."); - logger.error(getClass().getName() + " Exception!",e); - } - } - } else { - logger.info("OpenReactorFileAction message: " + "No file selected."); - } - - return; - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorTreeContentProvider.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorTreeContentProvider.java deleted file mode 100644 index 5a209bc39..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorTreeContentProvider.java +++ /dev/null @@ -1,508 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ice.datastructures.ICEObject.Composite; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.ice.io.hdf.HdfIOFactory; -import org.eclipse.ice.reactor.ILWRComponentVisitor; -import org.eclipse.ice.reactor.LWRComponent; -import org.eclipse.ice.reactor.LWRRod; -import org.eclipse.ice.reactor.Ring; -import org.eclipse.ice.reactor.Tube; -import org.eclipse.ice.reactor.bwr.BWReactor; -import org.eclipse.ice.reactor.pwr.ControlBank; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.IncoreInstrument; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.eclipse.ice.reactor.pwr.RodClusterAssembly; -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.core.Material; -import org.eclipse.ice.reactor.sfr.core.MaterialBlock; -import org.eclipse.ice.reactor.sfr.core.SFReactor; -import org.eclipse.ice.reactor.sfr.core.assembly.PinAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.ReflectorAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRPin; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRRod; -import org.eclipse.ice.reactorAnalyzer.ReactorReaderFactory; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; - -/** - * This class fills out the tree in the {@link ReactorViewer}. Top level - * elements are {@link ICEResource}s for HDF5 reactor files. Their children are - * {@link IReactorComponent}s in the reactor file. - * - * @author Jordan H. Deyton, Taylor Patterson - * - */ -public class ReactorTreeContentProvider implements ITreeContentProvider { - - /** - * A ParentVisitor is used to get the parent object for an - * IReactorComponent. - * - * @author Jordan H. Deyton - * - */ - private interface ParentVisitor extends ILWRComponentVisitor, - ISFRComponentVisitor { - - // TODO This visitor may need to be implemented at some point. - - /** - * Get the parent object for an IReactorComponent. - * - * @param component - * The child IReactorComponent. - * @return An object for use in the ReactorTreeContentProvider, or null - * if a parent could not be found. - */ - public Object getParent(IReactorComponent component); - } - - /** - * A ChildrenVisitor is used to get the children of an IReactorComponent. - * - * @author Jordan H. Deyton - * - */ - private interface ChildrenVisitor extends ILWRComponentVisitor, - ISFRComponentVisitor { - /** - * Get the child objects for an IReactorComponent. - * - * @param component - * The parent IReactorComponent. - * @return An array of objects corresponding to children of the - * IReactorComponent. - */ - public Object[] getChildren(IReactorComponent component); - } - - /** - * A visitor that determines the parent object for a particular - * IReactorComponent. - */ - private final ParentVisitor parentVisitor = new ParentVisitor() { - - /** - * The parent object. This should be set to null before visiting, and - * the visit operations should set it. - */ - private IReactorComponent parent; - - /** - * Gets the parent object for the IReactorComponent. It may be an - * LWRComponent or an SFRComponent. - */ - @Override - public Object getParent(IReactorComponent component) { - parent = null; - - // Visit the component if possible. - if (component instanceof LWRComponent) { - ((LWRComponent) component).accept(this); - } else if (component instanceof SFRComponent) { - ((SFRComponent) component).accept(this); - } - - return parent; - } - - // ---- Implements ILWRComponentVisitor ---- // - @Override - public void visit(PressurizedWaterReactor lwrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(BWReactor lwrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(FuelAssembly lwrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(RodClusterAssembly lwrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(LWRRod lwrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(ControlBank lwrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(IncoreInstrument lwrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(Tube lwrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(Ring lwrComp) { - // TODO Auto-generated method stub - - } - - // ----------------------------------------- // - - // ---- Implements ISFRComponentVisitor ---- // - @Override - public void visit(SFReactor sfrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(SFRAssembly sfrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(PinAssembly sfrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(ReflectorAssembly sfrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(SFRPin sfrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(SFRRod sfrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(MaterialBlock sfrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(Material sfrComp) { - // TODO Auto-generated method stub - - } - - @Override - public void visit(org.eclipse.ice.reactor.sfr.core.assembly.Ring sfrComp) { - // TODO Auto-generated method stub - - } - // ----------------------------------------- // - }; - - /** - * A visitor that determines the child objects for a particular - * IReactorComponent. - */ - private final ChildrenVisitor childrenVisitor = new ChildrenVisitor() { - - /** - * The array of children of the current IReactorComponent. This should - * be set to null before visiting, and the visit operations should - * change it. - */ - private Object[] children; - - /** - * Gets the child objects for the IReactorComponent. If there are no - * children, the array will be empty. - */ - @Override - public Object[] getChildren(IReactorComponent component) { - - children = null; - - // Visit the component if possible. - if (component instanceof LWRComponent) { - ((LWRComponent) component).accept(this); - } else if (component instanceof SFRComponent) { - ((SFRComponent) component).accept(this); - } - - // Make sure the return value is not null. If we have a Composite - // implementation, we can get the children. This catches - // LWRComposites and SFRComposites, which are not part of their - // respective visitor interfaces. - if (children == null) { - if (component instanceof Composite) { - children = ((Composite) component).getComponents() - .toArray(); - } else { - children = new Object[] {}; - } - } - - return children; - } - - // ---- Implements ILWRComponentVisitor ---- // - @Override - public void visit(PressurizedWaterReactor lwrComp) { - children = lwrComp.getComponents().toArray(); - } - - @Override - public void visit(BWReactor lwrComp) { - children = lwrComp.getComponents().toArray(); - } - - @Override - public void visit(FuelAssembly lwrComp) { - children = lwrComp.getComponents().toArray(); - } - - @Override - public void visit(RodClusterAssembly lwrComp) { - children = lwrComp.getComponents().toArray(); - } - - @Override - public void visit(LWRRod lwrComp) { - // Nothing to do... yet. - } - - @Override - public void visit(ControlBank lwrComp) { - // Nothing to do... yet. - } - - @Override - public void visit(IncoreInstrument lwrComp) { - // Nothing to do... yet. - } - - @Override - public void visit(Tube lwrComp) { - // Nothing to do... yet. - } - - @Override - public void visit(Ring lwrComp) { - // Nothing to do... yet. - } - - // ----------------------------------------- // - - // ---- Implements ISFRComponentVisitor ---- // - @Override - public void visit(SFReactor sfrComp) { - children = sfrComp.getComponents().toArray(); - } - - @Override - public void visit(SFRAssembly sfrComp) { - children = sfrComp.getComponents().toArray(); - } - - @Override - public void visit(PinAssembly sfrComp) { - children = sfrComp.getComponents().toArray(); - } - - @Override - public void visit(ReflectorAssembly sfrComp) { - children = sfrComp.getComponents().toArray(); - } - - @Override - public void visit(SFRPin sfrComp) { - // Nothing to do... yet. - } - - @Override - public void visit(SFRRod sfrComp) { - // Nothing to do... yet. - } - - @Override - public void visit(MaterialBlock sfrComp) { - // Nothing to do... yet. - } - - @Override - public void visit(Material sfrComp) { - // Nothing to do... yet. - } - - @Override - public void visit(org.eclipse.ice.reactor.sfr.core.assembly.Ring sfrComp) { - // Nothing to do... yet. - } - // ----------------------------------------- // - }; - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - return; - } - - @Override - public void dispose() { - return; - } - - /** - * Returns true if the element in the tree should have children, false - * otherwise. ICEResources and some IReactorComponents (plants, reactors, - * and assemblies) should have children. - */ - @Override - public boolean hasChildren(Object element) { - - boolean hasChildren = false; - - // Right now, only ICEResources and Composites have children. - if (element instanceof Composite || element instanceof ICEResource) { - hasChildren = true; - } - - return hasChildren; - } - - /** - * Returns the parent object so that this element's node can be expanded. - * For instance, an assembly's parent might be a reactor core. - */ - @Override - public Object getParent(Object element) { - - Object parent = null; - - if (element instanceof IReactorComponent) { - parent = parentVisitor.getParent((IReactorComponent) element); - } - - return parent; - } - - /** - * Gets an array of elements to display for the given input. The input to - * this tree should be a list of {@link ICEResource}s. - */ - @Override - public Object[] getElements(Object inputElement) { - - // Local Declaration - Object[] elements; - - // Convert the element to an ArrayList (it should be an - // ArrayList) and then get an Object array. - if (inputElement instanceof ArrayList) { - elements = ((ArrayList) inputElement).toArray(); - } else { - elements = new Object[] {}; - } - - return elements; - } - - /** - * Gets the child elements for the given object. ICEResources should have - * IReactorComponents, and some IReactorComponents will have other - * IReactorComponents as children (e.g., assemblies have pins). - */ - @Override - public Object[] getChildren(Object parentElement) { - - Object[] children; - - // If the parent is an ICEResource, we need to try to open the resource - // and pull out any IReactorComponents. - if (parentElement instanceof ICEResource) { - ArrayList childComponents = new ArrayList<>(); - - // Get the the ICEResource - ICEResource resource = (ICEResource) parentElement; - - // Create an IO factory to try to read in the file. Supported - // objects in the file will be read into a list of objects. - HdfIOFactory factory = new HdfIOFactory(); - List objects = factory.readObjects(resource.getPath()); - - if (!objects.isEmpty()) { - // Add all IReactorComponents read in from the file to the - // tree viewer. - for (Object object : objects) { - if (object instanceof IReactorComponent) { - childComponents.add((IReactorComponent) object); - } - } - } - // FIXME Temporary fall-back to the original method that uses direct - // references to the LWR and SFR readers. - else { - // Read the first structure from the reactor file. - ReactorReaderFactory reader = new ReactorReaderFactory(); - IReactorComponent parentRC = reader.readReactor(resource - .getPath()); - - // Add the parent component to the return structure - childComponents.add(parentRC); - } - - children = childComponents.toArray(); - } - // If the parent is an IReactorComponent, we need to get all child - // components by using an ISFRComponentVisitor or ILWRComponentVisitor. - else if (parentElement instanceof IReactorComponent) { - children = childrenVisitor - .getChildren((IReactorComponent) parentElement); - } - // Ensure non-null result for something else. - else { - children = new Object[] {}; - } - - return children; - } -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorTreeLabelProvider.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorTreeLabelProvider.java deleted file mode 100644 index 18cc69b4e..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorTreeLabelProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import org.eclipse.ice.datastructures.ICEObject.Identifiable; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.jface.viewers.LabelProvider; - -/** - * This class provides the labels for the {@link ReactorViewer}'s TreeView. It - * uses the visitor pattern for reactor components to generate the labels and - * displays their names and IDs. For other objects, it returns uses the object's - * toString() method. - * - * @author Jordan H. Deyton - * - */ -public class ReactorTreeLabelProvider extends LabelProvider { - - // TODO When we have a visitor for the reactor components, we might need to - // revisit this interface. - - /** - * Creates a String that represents an object in the tree constructed by - * {@link ReactorTreeContentProvider}. - */ - @Override - public String getText(Object element) { - - // Get a String from the ICEResource if possible. - String text = null; - if (element instanceof ICEResource) { - text = ((ICEResource) element).getName(); - } - // Get a String for Identifiables. - else if (element instanceof Identifiable) { - text = getLabel((Identifiable) element); - } - // If the element isn't an ICEResource, convert it to a String. - else { - text = element.toString(); - } - - return text; - } - - /** - * Gets a standard label for an {@link Identifiable} object. Most--if not - * all--reactor components should implement the interface, usually by - * extending ICEObject. If we want to change the default label, we should - * do that here. - * - * @param identifiable - * The identifiable object that needs a default label. - * @return A string containing the identifiable's name and ID, e.g. - * "Name 1". - */ - private String getLabel(Identifiable identifiable) { - return identifiable.getName() + " " + identifiable.getId(); - } -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorViewer.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorViewer.java deleted file mode 100644 index ce985f7af..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorViewer.java +++ /dev/null @@ -1,502 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.ice.client.widgets.reactoreditor.DataSource; -import org.eclipse.ice.datastructures.ICEObject.IUpdateable; -import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener; -import org.eclipse.ice.datastructures.form.ResourceComponent; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.ice.reactor.perspective.internal.ReactorEditorRegistry; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.part.WorkbenchPart; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class extends the ViewPart class to display opened reactor files and - * their components. - * - * @author Taylor Patterson, Jordan H. Deyton - */ -public class ReactorViewer extends ViewPart implements - ISelectionChangedListener, IUpdateableListener { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(ReactorViewer.class); - - /** - * The id for this view - */ - public static final String ID = "org.eclipse.ice.reactors.perspective.ReactorViewer"; - - /** - * The active ResourceComponent. - */ - private ResourceComponent resourceComponent; - - /** - * A TreeViewer that shows opened reactor files. This is created in - * {@link #createPartControl(Composite)}. - */ - private TreeViewer reactorTreeViewer; - - /** - * This action provides the user a means to select a reactor file to open. - */ - private OpenReactorFileAction openReactorFileAction; - - /** - * This action lets the user save any changes made to an opened reactor - * file. - */ - private SaveReactorFileAction saveReactorFileAction; - - /** - * This action opens a dialog for selecting reactor components. - */ - private AddReactorPartAction addReactorPartAction; - - /** - * This action calls {@link #removeSelection()} to remove all selected - * resources from this viewer. - */ - private DeleteReactorPartAction deleteReactorPartAction; - - /** - * This action provides a drop down menu to select the Reactor Editor to - * open the current selection in. - */ - private AnalyzeInReactorEditorAction showInReactorEditorAction; - - /** - * This action provides a drop down menu to select the Reactor Editor whose - * contents should be compared with the selection from the TreeViewer. - */ - private CompareAction compareAction; - - /** - * The default constructor. - */ - public ReactorViewer() { - - // Set a default ResourceComponent. - setResourceComponent(new ResourceComponent()); - - return; - } - - /** - * Creates the widgets and controls for the ReactorViewer. - * - * @param parent - * The parent Composite that will contain this ReactorViewer. - */ - @Override - public void createPartControl(Composite parent) { - - // Create the tool bar buttons for this view. - createActions(); - - // Initialize the TreeViewer. Disable multi-selection by not including - // SWT.MULTI in the constructor parameters. - reactorTreeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.BORDER); - reactorTreeViewer.addSelectionChangedListener(this); - - // Set the tree's content provider. - reactorTreeViewer.setContentProvider(new ReactorTreeContentProvider()); - - // Set the tree's label provider. - reactorTreeViewer.setLabelProvider(new ReactorTreeLabelProvider()); - - // Create a MenuManager that will enable a context menu in the - // TreeViewer. The context menu will provide access to the same actions - // that are on the viewer's ToolBar. - MenuManager menuManager = new MenuManager(); - menuManager.setRemoveAllWhenShown(true); - menuManager.addMenuListener(new IMenuListener() { - @Override - public void menuAboutToShow(IMenuManager manager) { - fillContextMenu(manager); - } - }); - Control control = reactorTreeViewer.getControl(); - Menu menu = menuManager.createContextMenu(control); - control.setMenu(menu); - - return; - } - - /** - * Not used at this time. - * - * @see WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - return; - } - - /** - * This listens for selection change events in the reactorTreeViewer and - * updates the actions depending on the selection type. - * - * @param event - * The SelectionChangedEvent that fired this method. - * - * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent) - */ - @Override - public void selectionChanged(SelectionChangedEvent event) { - - // Enable the actions if the selection is not empty, disable otherwise. - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection) { - boolean nonEmpty = !selection.isEmpty(); - addReactorPartAction.setEnabled(nonEmpty); - deleteReactorPartAction.setEnabled(nonEmpty); - showInReactorEditorAction.setEnabled(nonEmpty); - compareAction.setEnabled(nonEmpty); - } - - return; - } - - /** - * Updates the ReactorViewer (specifically, the {@link #reactorTreeViewer}) - * when the ResourceComponent is updated. - * - * @param component - * The ResourceComponent that was just updated. - * - * @see IUpdateableListener#update(IUpdateable) - */ - @Override - public void update(IUpdateable component) { - - logger.info("ReactorViewer Message: Incoming resource update."); - - // Sync with the display. - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - // If possible, reset the reactorTreeViewer's input. - if (reactorTreeViewer != null) { - - // Reset the input for the reactorTreeViewer. It should be - // built on the ResourceComponent's ArrayList of - // ICEResources. - reactorTreeViewer.setInput(resourceComponent.getResources()); - - logger.info("ReactorViewer Message: " - + "Updating resource table."); - reactorTreeViewer.refresh(); - reactorTreeViewer.getTree().redraw(); - - // Set the selection to the newly added file - int lastIndex = resourceComponent.getResources().size() - 1; - if (lastIndex > -1) { - ICEResource resource = resourceComponent.getResources() - .get(lastIndex); - reactorTreeViewer.setSelection(new StructuredSelection( - resource), true); - } - - } - } - }); - - return; - } - - /** - * This operation sets the ResourceComponent that should be used by this - * view. It also registers this view with the ResourceComponent so that it - * can be notified of state changes through the IUpdateableListener - * interface. - * - * @param component - * The ResourceComponent - */ - private void setResourceComponent(ResourceComponent component) { - - // Make sure the ResourceComponent exists. - if (component != null) { - // If there was an associated ResourceComponent, unregister from it. - if (resourceComponent != null) { - resourceComponent.unregister(this); - } - - // Set the component reference. - resourceComponent = component; - - // Register this view with the Component to receive updates. - component.register(this); - - // Update the view. - update(component); - } - - return; - } - - /** - * This operation retrieves the active ResourceComponent of this view or - * null if the component does not exist. - * - * @return The ResourceComponent or null if the component was not previously - * set. - */ - public ResourceComponent getResourceComponent() { - return resourceComponent; - } - - /** - * Creates the JFace Actions associated with this ReactorViewer. - */ - private void createActions() { - - // Get the IToolBarManager. - IActionBars actionBars = getViewSite().getActionBars(); - IToolBarManager toolBarManager = actionBars.getToolBarManager(); - - // Create an open button and add it to the tool bar. - openReactorFileAction = new OpenReactorFileAction(this); - toolBarManager.add(openReactorFileAction); - - // TODO Re-incorporate the save button when we can edit reactors! - // // Create a save button and add it to the tool bar. - // saveReactorFileAction = new SaveReactorFileAction(this); - // toolBarManager.add(saveReactorFileAction); - // saveReactorFileAction.setEnabled(false); - - // Create an add button and add it to the tool bar. - addReactorPartAction = new AddReactorPartAction(this); - toolBarManager.add(addReactorPartAction); - addReactorPartAction.setEnabled(false); - - // Create a delete button and add it to the tool bar. - deleteReactorPartAction = new DeleteReactorPartAction(this); - toolBarManager.add(deleteReactorPartAction); - deleteReactorPartAction.setEnabled(false); - - // Create an open in Reactor Editor button and add it to the tool bar. - showInReactorEditorAction = new AnalyzeInReactorEditorAction(this); - toolBarManager.add(showInReactorEditorAction); - showInReactorEditorAction.setEnabled(false); - - // Create the compare with Reactor Editor button and add it to the tool - // bar. - compareAction = new CompareAction(this); - toolBarManager.add(compareAction); - compareAction.setEnabled(false); - - return; - } - - /** - * Removes all ICEResources selected in {@link #reactorTreeViewer} from the - * {@link #resourceComponent}. - */ - public void removeSelection() { - - // Make sure the viewer's controls have been created. - if (reactorTreeViewer != null) { - // Get the selection from the reactorTreeViewer. It should at least - // be - // an IStructuredSelection (a parent interface of TreeSelections). - ISelection selection = reactorTreeViewer.getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = (IStructuredSelection) selection; - - // Get the resources from the ResourceComponent. - ArrayList resources = resourceComponent - .getResources(); - - // Remove each ICEResource in the selection from the - // ResourceComponent. - for (Iterator iter = structuredSelection.iterator(); iter - .hasNext();) { - ICEResource resource = (ICEResource) iter.next(); - logger.info("ReactorViewer message: " - + "Removing the resource \"" + resource.getName() - + "\"."); - resources.remove(resource); - } - } - - // Update the reactorTreeViewer now that the ResourceComponent has - // changed. - update(resourceComponent); - } - - return; - } - - /** - * Add an ICEResource to the ReactorViewer. - * - * @param resource - * an ICEResource for the reactor (.h5) file to add to the - * ReactorViewer. - */ - public void addReactorFile(ICEResource resource) { - - if (resource != null) { - logger.info("ReactorViewer message: Getting ICEResource " - + "for file at \"" + resource.getPath().getPath() + "\"."); - - // Only add the resource to the ResourceComponent if a resource for - // the same file does not already exist in the ResourceComponent. - ArrayList resources = resourceComponent.getResources(); - if (!resources.contains(resource)) { - resourceComponent.addResource(resource); - } - } - return; - } - - /** - * Shows the current selection in {@link #reactorTreeViewer} in a Reactor - * Analyzer. - * - * @param reactorEditorId - * The ID of the target Reactor Analyzer. - */ - public void showSelection(int reactorEditorId) { - - logger.info("ReactorViewer message: Showing selection in" - + " Reactor Editor " + reactorEditorId); - - // Get the current selection from the TreeViewer. - ITreeSelection treeSelection = (ITreeSelection) reactorTreeViewer - .getSelection(); - - // If the selection is not empty, try to set it for the specified - // reactor editor. - if (!treeSelection.isEmpty()) { - ReactorEditorRegistry.setInput(reactorEditorId, treeSelection, - DataSource.Input); - } - return; - } - - /** - * Compares the current selection in {@link #reactorTreeViewer} with an - * existing Reactor Analyzer. - * - * @param reactorEditorId - * The ID of the target Reactor Analyzer. - */ - public void compareSelection(int reactorEditorId) { - // TODO Change it to do some actual comparison rather than just setting - // the reference! - - logger.info("ReactorViewer message: Showing selection in" - + " Reactor Editor " + reactorEditorId); - - // Get the current selection from the TreeViewer. - ITreeSelection treeSelection = (ITreeSelection) reactorTreeViewer - .getSelection(); - - // If the selection is not empty, try to set it for the specified - // reactor editor. - if (!treeSelection.isEmpty()) { - ReactorEditorRegistry.setInput(reactorEditorId, treeSelection, - DataSource.Reference); - } - return; - } - - /** - * Retrieve the current selection in the {@link #reactorTreeViewer} for - * access by external classes. - * - * @return The current selection in the {@link #reactorTreeViewer} - */ - public Object getSelectedElement() { - return ((ITreeSelection) reactorTreeViewer.getSelection()) - .getFirstElement(); - } - - /** - * Fills the context menu for the {@link #reactorTreeViewer}. This method is - * called when the context menu is about to appear. It fills out the - * MenuManager with the appropriate, available actions from the ToolBar. - * - * @param menuManager - * The IMenuManager responsible for the context menu. - */ - protected void fillContextMenu(IMenuManager menuManager) { - - // Force the menu to update. This needs to be called for the context - // menu to update when the set of Reactor Analyzers has changed. - menuManager.update(true); - - ISelection iSelection = reactorTreeViewer.getSelection(); - if (!iSelection.isEmpty() && iSelection instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection) iSelection; - - Object object = selection.getFirstElement(); - // If an ICEResource was clicked, expose the save, add, and delete - // actions. - if (object instanceof ICEResource) { - menuManager.add(saveReactorFileAction); - menuManager.add(new Separator()); - menuManager.add(addReactorPartAction); - menuManager.add(deleteReactorPartAction); - } - // If an IReactorComponent was clicked, expose the add, delete, and - // show actions. - else { - menuManager.add(addReactorPartAction); - menuManager.add(deleteReactorPartAction); - menuManager.add(new Separator()); - menuManager.add(showInReactorEditorAction); - menuManager.add(compareAction); - } - } - // If the selection was empty, expose the open action. - else { - menuManager.add(openReactorFileAction); - } - - return; - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorsPerspective.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorsPerspective.java deleted file mode 100644 index d22fb64e9..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/ReactorsPerspective.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; - -/** - * This class implements IPerspectiveFactory to create the Visualization - * Perspective. - * - * @author Taylor Patterson - * - */ -public class ReactorsPerspective implements IPerspectiveFactory { - - /** - * The ID of this perspective. - */ - public static final String ID = "org.eclipse.ice.reactors.perspective.ReactorsPerspective"; - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout) - */ - @Override - public void createInitialLayout(IPageLayout layout) { - - // Add the perspective to the layout - layout.addPerspectiveShortcut(ReactorsPerspective.ID); - - return; - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/SaveReactorFileAction.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/SaveReactorFileAction.java deleted file mode 100644 index af03fd5e3..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/SaveReactorFileAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective; - -import org.eclipse.jface.action.Action; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.ViewPart; - -/** - * This action is used to save an individual reactor file in the - * {@link ReactorViewer}. - * - * @author Jordan H. Deyton - * - */ -public class SaveReactorFileAction extends Action { - /** - * The ViewPart that owns an object of this class. - */ - private final ViewPart viewer; - - /** - * The constructor - * - * @param parent - * The ViewPart to whom the object of this class belongs. - */ - public SaveReactorFileAction(ViewPart parent) { - viewer = parent; - - // Set the action's tool tip text. - setText("Save reactor file"); - setToolTipText("Save an edited reactor file"); - - // Set the action's image (the save button). - setImageDescriptor(PlatformUI.getWorkbench().getSharedImages() - .getImageDescriptor(ISharedImages.IMG_ETOOL_SAVE_EDIT)); - - return; - } - - /** - * The function called whenever the action is clicked. - */ - @Override - public void run() { - // TODO Get the selected resource and try to save it. - } -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/internal/IORegistryHolder.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/internal/IORegistryHolder.java deleted file mode 100644 index 8368bce23..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/internal/IORegistryHolder.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective.internal; - -import org.eclipse.ice.io.hdf.IHdfIORegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class grabs the currently available {@link IHdfIORegistry} - * implementation from the OSGi Declarative Services. This enables classes in - * this bundle to fetch IO factories for writing and reading reactor files. - * - * @author Jordan H. Deyton - * - */ -public class IORegistryHolder { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(IORegistryHolder.class); - - /** - * The currently available {@link IHdfIORegistry} implementation, which runs - * via OSGi DS. - */ - private static IHdfIORegistry registry; - - /** - * Gets the currently available {@link IHdfIORegistry} implementation, which - * runs via OSGi DS. - * - * @return ICE's current IHdfIORegistry implementation, or null if the - * service is not running. - */ - public static IHdfIORegistry getRegistry() { - return registry; - } - - /** - * Sets the currently available {@link IHdfIORegistry} implementation, which - * runs via OSGi DS. This method should only be called via the OSGi - * framework. - * - * @param registry - * The registry implementation. - */ - public static void setHdfIORegistry(IHdfIORegistry registry) { - - if (registry != null) { - IORegistryHolder.registry = registry; - logger.info("ICE Reactor Perspective Message: " - + "IO registry set successfully!"); - } else { - logger.info("ICE Reactor Perspective Message:" - + "Framework attempted to set IO registry, but the " - + "reference was null."); - } - - return; - } - - /** - * Unsets the currently available {@link IHdfIORegistry} implementation, - * which runs via OSGi DS. This method should only be called via the OSGi - * framework. - * - * @param registry - * The registry implementation. - */ - public static void unsetHdfIORegistry(IHdfIORegistry registry) { - if (registry == IORegistryHolder.registry) { - IORegistryHolder.registry = null; - } - } -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/internal/ReactorClientHolder.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/internal/ReactorClientHolder.java deleted file mode 100644 index abd7bccf0..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/internal/ReactorClientHolder.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective.internal; - -import org.eclipse.ice.iclient.IClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReactorClientHolder { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(ReactorClientHolder.class); - - /** - * The reference to the ICEClient provided by the OSGi. - */ - private static IClient client = null; - - /** - * Retrieve the reference to the client - */ - public static IClient getClient() { - return client; - } - - /** - * Retrieve the reference to the client - */ - public static void setClient(IClient iceClient) { - - // Set the reference and do some reporting - if (iceClient != null) { - client = iceClient; - logger.info("ICE Reactor Perspective Message: " - + "Client set successfully!"); - } else { - logger.info("ICE Reactor Perspective Message:" - + "Framework attempted to set client, but the " - + "reference was null."); - } - - return; - } - - /** - * "Unset" the reference to the client. That is, notify the Common bundle - * that the client has shutdown. - */ - public static void unsetClient(IClient iceClient) { - if (iceClient == client) { - client = null; - } - } - -} diff --git a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/internal/ReactorEditorRegistry.java b/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/internal/ReactorEditorRegistry.java deleted file mode 100644 index 558726964..000000000 --- a/org.eclipse.ice.reactor.perspective/src/org/eclipse/ice/reactor/perspective/internal/ReactorEditorRegistry.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.perspective.internal; - -import java.util.ArrayList; -import java.util.List; -import java.util.TreeMap; - -import org.eclipse.ice.client.widgets.reactoreditor.DataSource; -import org.eclipse.ice.client.widgets.reactoreditor.IAnalysisWidgetRegistry; -import org.eclipse.ice.client.widgets.reactoreditor.IReactorEditorRegistry; -import org.eclipse.ice.client.widgets.reactoreditor.ReactorFormEditor; -import org.eclipse.ice.client.widgets.reactoreditor.ReactorFormInput; -import org.eclipse.ice.client.widgets.reactoreditor.ReactorFormInputFactory; -import org.eclipse.ice.reactor.perspective.ReactorViewer; -import org.eclipse.jface.viewers.ITreeSelection; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class implements {@link IReactorEditorRegistry} so that classes in the - * bundle can access the currently-available Reactor Editors.
- *
- * This class provides the IReactorEditorRegistry interface and is referenced by - * the main Reactor Editor bundle via OSGi. The {@link ReactorFormEditor}s are - * registered with this registry when constructed.
- *
- * The IDs of available editors and the ability to set their input are exposed - * in this implementation. - * - * @author Jordan - * - */ -public class ReactorEditorRegistry implements IReactorEditorRegistry { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(ReactorEditorRegistry.class); - - /** - * An ordered Map of all current Reactor Editors, keyed on their associated - * Item/Form ID. - */ - private static final TreeMap editors = new TreeMap(); - - /** - * The IAnalysisWidgetRegistry that is used to get IAnalysisWidgetFactories - * for different component types. - */ - private static IAnalysisWidgetRegistry widgetRegistry; - - // ---- Implements IReactorEditorRegistry ---- // - /** - * Updates {@link #editors} with the new Reactor Editor. - */ - @Override - public void addReactorEditor(ReactorFormEditor editor, int id) { - editors.put(id, editor); - - logger.info("ICE Reactor Perspective Message: " - + "Added new reactor analyzer with ID " + id); - } - - /** - * Removes the {@link ReactorFormEditor} associated with the ID from - * {@link #editors}. - */ - @Override - public void removeReactorEditor(int id) { - editors.remove(id); - - logger.info("ICE Reactor Perspective Message: " - + "Removed reactor analyzer with ID " + id); - } - - // ------------------------------------------- // - - /** - * Gets a List of IDs for all currently available Reactor Editors. - * - * @return A List of integer IDs. - */ - public static List getEditorIds() { - return new ArrayList(editors.keySet()); - } - - /** - * Sets the input for a particular Reactor Editor based on an - * {@link ITreeSelection} from the {@link ReactorViewer}. - * - * @param id - * The ID of the editor. - * @param selection - * The ITreeSelection from the ReactorViewer's TreeView. - * @param dataSource - * the DataSource that the selection is being sent to, e.g., - * Input or Reference. - */ - public static void setInput(int id, ITreeSelection selection, - DataSource dataSource) { - - // Get the editor corresponding to the ID. - ReactorFormEditor editor = editors.get(id); - - // If the editor and selection are not null, try to set the input for - // the editor. - if (editor != null && selection != null) { - - // We need to use a ReactorFormInputFactory to create the proper - // input based on the tree selection. We also need to get the - // editor's previous input for values that will not change. - ReactorFormInputFactory factory = new ReactorFormInputFactory(); - ReactorFormInput oldInput = (ReactorFormInput) ((IEditorPart) editor) - .getEditorInput(); - ReactorFormInput input = factory.createInput(oldInput, selection, - dataSource); - - // Set the input for the editor. - editor.setInput(input); - } - - return; - } - - /** - * Gets the current {@link IAnalysisWidgetRegistry} that is used to get - * IAnalysisWidgetFactories for different component types - * - * @return An IAnalysisWidgetRegistry, or null if it is not set. - */ - public static IAnalysisWidgetRegistry getAnalysisWidgetRegistry() { - return widgetRegistry; - } - - /** - * Sets {@link #widgetRegistry} if the provided value is not null. - * - * @param registry - * The new IAnalysisWidgetRegistry. - */ - public static void setAnalysisWidgetRegistry( - IAnalysisWidgetRegistry registry) { - if (registry != null) { - widgetRegistry = registry; - logger.info("ICE Reactor Perspective Message: " - + "Analysis widget registry set successfully!"); - } else { - logger.info("ICE Reactor Perspective Message:" - + "Framework attempted to set analysis widget registry, " - + "but the reference was null."); - } - return; - } - - /** - * Unsets {@link #widgetRegistry}. This notifies the bundle that the - * registry has been shut down. - * - * @param registry - * The new IAnalysisWidgetRegistry. - */ - public static void unsetAnalysisWidgetRegistry( - IAnalysisWidgetRegistry registry) { - if (registry == widgetRegistry) { - widgetRegistry = null; - } - } - -} diff --git a/org.eclipse.ice.reactor.plant.test/src/org/eclipse/ice/reactor/plant/test/PlantIOFactoryTester.java b/org.eclipse.ice.reactor.plant.test/src/org/eclipse/ice/reactor/plant/test/PlantIOFactoryTester.java deleted file mode 100644 index ac58006ba..000000000 --- a/org.eclipse.ice.reactor.plant.test/src/org/eclipse/ice/reactor/plant/test/PlantIOFactoryTester.java +++ /dev/null @@ -1,765 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.plant.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ice.io.hdf.HdfIOFactory; -import org.eclipse.ice.io.hdf.HdfIORegistry; -import org.eclipse.ice.reactor.plant.Boundary; -import org.eclipse.ice.reactor.plant.Branch; -import org.eclipse.ice.reactor.plant.CoreChannel; -import org.eclipse.ice.reactor.plant.DownComer; -import org.eclipse.ice.reactor.plant.FlowJunction; -import org.eclipse.ice.reactor.plant.GeometricalComponent; -import org.eclipse.ice.reactor.plant.HeatExchanger; -import org.eclipse.ice.reactor.plant.IdealPump; -import org.eclipse.ice.reactor.plant.Inlet; -import org.eclipse.ice.reactor.plant.Junction; -import org.eclipse.ice.reactor.plant.MassFlowInlet; -import org.eclipse.ice.reactor.plant.OneInOneOutJunction; -import org.eclipse.ice.reactor.plant.Outlet; -import org.eclipse.ice.reactor.plant.Pipe; -import org.eclipse.ice.reactor.plant.PipeToPipeJunction; -import org.eclipse.ice.reactor.plant.PipeWithHeatStructure; -import org.eclipse.ice.reactor.plant.PlantComponent; -import org.eclipse.ice.reactor.plant.PlantComposite; -import org.eclipse.ice.reactor.plant.PlantIOFactory; -import org.eclipse.ice.reactor.plant.PointKinetics; -import org.eclipse.ice.reactor.plant.Pump; -import org.eclipse.ice.reactor.plant.Reactor; -import org.eclipse.ice.reactor.plant.SeparatorDryer; -import org.eclipse.ice.reactor.plant.SolidWall; -import org.eclipse.ice.reactor.plant.SpecifiedDensityAndVelocityInlet; -import org.eclipse.ice.reactor.plant.Subchannel; -import org.eclipse.ice.reactor.plant.SubchannelBranch; -import org.eclipse.ice.reactor.plant.TDM; -import org.eclipse.ice.reactor.plant.TimeDependentJunction; -import org.eclipse.ice.reactor.plant.TimeDependentVolume; -import org.eclipse.ice.reactor.plant.Turbine; -import org.eclipse.ice.reactor.plant.Valve; -import org.eclipse.ice.reactor.plant.VolumeBranch; -import org.eclipse.ice.reactor.plant.WetWell; -import org.junit.AfterClass; -import org.junit.Test; - -/** - * Tests the {@link PlantIOFactory} and its ability to write and read - * {@link PlantComponent}s to and from a file. - * - * @author Jordan H. Deyton - * - */ -public class PlantIOFactoryTester { - - /** - * Creates one of each type of PlantComponent to make sure they can all be - * written to and read from HDF5 files properly. - */ - @Test - public void checkComponents() { - - // ---- Create the IO registry and factory. ---- // - // Create the factory to test. - PlantIOFactory factory = new PlantIOFactory(); - - // Create a registry that contains the factory. - HdfIORegistry registry = new HdfIORegistry(); - registry.registerHdfIOFactory(factory); - - // Set the registry for the base ReactorIOFactory class. - HdfIOFactory.setHdfIORegistry(registry); - // --------------------------------------------- // - - // ---- Create the URI and objects for writing. ---- // - // Create an output file for this test. - String s = System.getProperty("file.separator"); - String directory = System.getProperty("user.dir") + s - + "ICEIOTestDirectory" + s; - String path = directory + "fromJava.h5"; - - // Create a URI for a file to write/read for the test. - URI uri = new File(path).toURI(); - - // Create the list of components to write. - List objects = new ArrayList(); - // ------------------------------------------------- // - - // ---- Create several PlantComponents. ---- // - PlantComponent component; - - // -- Add a pipe. -- // - Pipe pipe = new Pipe(5.0, 3.14159); - pipe.setName("Smash the beetles!"); - pipe.setNumElements(7); - pipe.setPosition(new double[] { 1.0, 2.0, 3.0 }); - objects.add(pipe); - // ----------------- // - - // -- Add a HeatExchanger. -- // - HeatExchanger heatExchanger = new HeatExchanger(); - heatExchanger.setInnerRadius(5.1); - objects.add(heatExchanger); - // -------------------------- // - - // -- Add a PlantComposite. -- // - PlantComposite plant = new PlantComposite(); - plant.setName("King's Landing"); - plant.setDescription("In King's Landing, there are two sorts of people. The players and the pieces."); - objects.add(plant); - - int id = 2; - // Add some components to the plant. - plant.addPlantComponent(pipe); - - // Add each type of pipe. - pipe = new Pipe(); - pipe.setId(id++); - pipe.setOrientation(new double[] { 6, 28, 496 }); - plant.addPlantComponent(pipe); - - pipe = new Subchannel(); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setName("Gregor Clegane, aka The Mountain"); - - pipe = new PipeWithHeatStructure(); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setName("Sandor Clegane, aka The Hound"); - - CoreChannel coreChannel = new CoreChannel(); - coreChannel.setId(id++); - plant.addPlantComponent(coreChannel); - coreChannel.setName("Oberyn Martell, aka The Red Viper"); - coreChannel.setDescription("Probably has a major headache."); - - // Add a reactor. - Reactor reactor = new Reactor(); - reactor.setId(id++); - plant.addPlantComponent(reactor); - reactor.setName("Daenerys Targaryen"); - reactor.setDescription("dragons dragons dragons dragons... my dragons"); - ArrayList coreChannels = new ArrayList(1); - coreChannels.add(coreChannel); - reactor.setCoreChannels(coreChannels); - - // Add a heat exchanger. - heatExchanger = new HeatExchanger(); - heatExchanger.setId(id++); - plant.addPlantComponent(heatExchanger); - heatExchanger.setName("Joffrey Baratheon"); - heatExchanger.setDescription("The character everyone loves to hate."); - heatExchanger.setLength(0.1); - - // Add some generic components. - GeometricalComponent geometry = new GeometricalComponent(); - geometry.setId(id++); - plant.addPlantComponent(geometry); - geometry.setName("Sansa Stark"); - geometry.setRotation(-1.0); - - component = new PointKinetics(); - component.setId(id++); - plant.addPlantComponent(component); - component.setName("Tyrion Lannister"); - component.setDescription("Everybody's favorite"); - - // Add each type of junction. - Junction junction = new Junction(); - junction.setId(id++); - plant.addPlantComponent(junction); - - junction = new Branch(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Jamie Lannister"); - - junction = new SubchannelBranch(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Cersei Lannister"); - - junction = new VolumeBranch(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Tywin Lannister"); - - junction = new FlowJunction(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Eddard Stark"); - junction.setDescription("He dies. Sean Bean always dies."); - - junction = new WetWell(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Arya Stark, and her trusty blade, Needle"); - - junction = new Boundary(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Jon Snow. He's Jon Snow."); - - junction = new OneInOneOutJunction(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Theon Greyjoy, aka Reek"); - - junction = new Turbine(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Bran Stark, a warg"); - - junction = new IdealPump(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Petyr Baelish, aka Little-finger"); - - junction = new Pump(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Brienne of Tarth"); - - junction = new Valve(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Stannis Baratheon"); - - junction = new PipeToPipeJunction(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Robert Baratheon"); - - junction = new Inlet(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Khal Drogo, played by Conan the Barbarian"); - - junction = new MassFlowInlet(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Daario Naharis"); - - junction = new SpecifiedDensityAndVelocityInlet(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Margaery Tyrell, played by Anne Boleyn"); - - junction = new Outlet(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Davos Seaworth, a former pirate... arrr"); - - junction = new SolidWall(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Ygritte, and her accent"); - - junction = new TDM(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Bronn, a sell-sword"); - - junction = new TimeDependentJunction(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Jorah Mormont"); - - junction = new TimeDependentVolume(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Robb Stark"); - - junction = new DownComer(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Catelyn Stark"); - - junction = new SeparatorDryer(); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.setName("Jeor Mormont, Jorah's father"); - // --------------------------- // - // ----------------------------------------- // - - // Write the objects. - factory.writeObjects(uri, objects); - - // Read the objects. - List loadedObjects = factory.readObjects(uri); - - // Compare the objects with the ones read from the file. They should be - // equivalent. - assertNotNull(loadedObjects); - assertEquals(objects.size(), loadedObjects.size()); - // for (int i = 0; i < objects.size(); i++) { - // // Each object should be unique but equivalent. - // assertNotSame(objects.get(i), loadedObjects.get(i)); - // assertEquals(objects.get(i), loadedObjects.get(i)); - // } - - // The order in which objects are stored in the h5 file are not the same - // as the write order. For now, just do a brute force search. - for (Object object : objects) { - boolean found = false; - for (Object loadedObject : loadedObjects) { - found = object.equals(loadedObject); - if (found) { - if (object == loadedObject) { - fail("PlantIOFactoryTester failure: " - + loadedObject.toString() - + " is not a new instance after reading."); - } - break; - } - } - - if (!found) { - fail("PlantIOFactoryTester failure: " - + object.toString() - + " was not found in the list of objects read from the file."); - } - } - - return; - } - - /** - * Creates a generic plant with several different types of components, - * writes it to a file, reads it in, and compares the custom plant with the - * plant loaded from the file. - */ - @Test - public void checkPlant() { - - // ---- Create the IO registry and factory. ---- // - // Create the factory to test. - PlantIOFactory factory = new PlantIOFactory(); - - // Create a registry that contains the factory. - HdfIORegistry registry = new HdfIORegistry(); - registry.registerHdfIOFactory(factory); - - // Set the registry for the base ReactorIOFactory class. - HdfIOFactory.setHdfIORegistry(registry); - // --------------------------------------------- // - - // ---- Create the URI and objects for writing. ---- // - // Create an output file for this test. - String s = System.getProperty("file.separator"); - String directory = System.getProperty("user.dir") + s - + "ICEIOTestDirectory" + s; - String path = directory + "testPlant.h5"; - - // Create a URI for a file to write/read for the test. - URI uri = new File(path).toURI(); - - // Create the list of components to write. - List objects = new ArrayList(); - // ------------------------------------------------- // - - Reactor reactor; - CoreChannel coreChannel; - Pipe pipe; - HeatExchanger hx; - Junction junction; - int id = 1; - - int numElements = 10; - double length; - double radius = 0.25; - double[] up = { 0, 1, 0 }; - double[] down = { 0, -1, 0 }; - double[] left = { -1, 0, 0 }; - double[] right = { 1, 0, 0 }; - - ArrayList components; - - // ---- Create the plant. ---- // - PlantComposite plant = new PlantComposite(); - plant.setName("Test Plant"); - plant.setDescription("This is a test plant modeled after TMI_2loop."); - objects.add(plant); - - // -- Create 3 core channels with an upper and lower plenum. -- // - ArrayList coreChannels = new ArrayList(); - - length = 10; - coreChannel = new CoreChannel(); - coreChannel.setId(id++); - plant.addPlantComponent(coreChannel); - coreChannels.add(coreChannel); - coreChannel.setNumElements(numElements); - coreChannel.setName("CoreChannel-L"); - coreChannel.setLength(length); - coreChannel.setRadius(radius); - coreChannel.setPosition(new double[] { -3, 0, -0.1 }); - coreChannel.setOrientation(up); - - coreChannel = new CoreChannel(); - coreChannel.setId(id++); - plant.addPlantComponent(coreChannel); - coreChannels.add(coreChannel); - coreChannel.setNumElements(numElements); - coreChannel.setName("CoreChannel-C"); - coreChannel.setLength(length); - coreChannel.setRadius(radius); - coreChannel.setPosition(new double[] { 0, 0, 0.1 }); - coreChannel.setOrientation(up); - - coreChannel = new CoreChannel(); - coreChannel.setId(id++); - plant.addPlantComponent(coreChannel); - coreChannels.add(coreChannel); - coreChannel.setNumElements(numElements); - coreChannel.setName("CoreChannel-R"); - coreChannel.setLength(length); - coreChannel.setRadius(radius); - coreChannel.setPosition(new double[] { 3, 0, -0.1 }); - coreChannel.setOrientation(up); - - Junction lowerPlenum = new Junction(); - lowerPlenum.setName("LowerPlenum"); - lowerPlenum.setId(id++); - plant.addPlantComponent(lowerPlenum); - components = new ArrayList(coreChannels); - lowerPlenum.setOutputs(components); - - Junction upperPlenum = new Junction(); - upperPlenum.setName("UpperPlenum"); - upperPlenum.setId(id++); - plant.addPlantComponent(upperPlenum); - components = new ArrayList(coreChannels); - upperPlenum.setInputs(components); - - // -- Create the reactor core view. -- // - reactor = new Reactor(); - reactor.setName("Reactor"); - reactor.setId(id++); - plant.addPlantComponent(reactor); - reactor.setCoreChannels(coreChannels); - - // -- Create the upper plenum's pipes and junctions. -- // - length = 6.75; - - pipe = new Pipe(); - pipe.setName("UpperPlenum-To-HX-L1"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { -1.75, 11, 0 }); - pipe.setOrientation(up); - // Connect the pipe to the upper plenum. - upperPlenum.addOutput(pipe); - Pipe upperPlenumToHXL1 = pipe; - - pipe = new Pipe(); - pipe.setName("UpperPlenum-To-HX-R1"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { 1.75, 11, 0 }); - pipe.setOrientation(up); - // Connect the pipe to the upper plenum. - upperPlenum.addOutput(pipe); - Pipe upperPlenumToHXR1 = pipe; - - length = 8; - - pipe = new Pipe(); - pipe.setName("UpperPlenum-To-HX-L2"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { -2, 18, 0 }); - pipe.setOrientation(left); - // // Connect the pipe to the upper plenum. - // upperPlenum.addOutput(pipe); - Pipe upperPlenumToHXL2 = pipe; - - pipe = new Pipe(); - pipe.setName("UpperPlenum-To-HX-R2"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { 2, 18, 0 }); - pipe.setOrientation(right); - // // Connect the pipe to the upper plenum. - // upperPlenum.addOutput(pipe); - Pipe upperPlenumToHXR2 = pipe; - - junction = new Junction(); - junction.setName("UpperPlenumJunction-L"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(upperPlenumToHXL1); - junction.addOutput(upperPlenumToHXL2); - - junction = new Junction(); - junction.setName("UpperPlenumJunction-R"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(upperPlenumToHXR1); - junction.addOutput(upperPlenumToHXR2); - - // -- Add the Heat Exchangers. -- // - length = 8.5; - - hx = new HeatExchanger(); - hx.setName("HX-L"); - hx.setId(id++); - plant.addPlantComponent(hx); - hx.setNumElements(numElements); - hx.setLength(length); - hx.setInnerRadius(radius); - hx.setPosition(new double[] { -10.25, 17.75, 0 }); - hx.setOrientation(down); - HeatExchanger HXL = hx; - - hx = new HeatExchanger(); - hx.setName("HX-R"); - hx.setId(id++); - plant.addPlantComponent(hx); - hx.setNumElements(numElements); - hx.setLength(length); - hx.setInnerRadius(radius); - hx.setPosition(new double[] { 10.25, 17.75, 0 }); - hx.setOrientation(down); - HeatExchanger HXR = hx; - - junction = new Junction(); - junction.setName("HX-L-In"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(upperPlenumToHXL2); - junction.addOutput(HXL.getPrimaryPipe()); - - junction = new Junction(); - junction.setName("HX-R-In"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(upperPlenumToHXR2); - junction.addOutput(HXR.getPrimaryPipe()); - - // -- Add the lower plenum's pipes and junctions. -- // - length = 4.75; - - pipe = new Pipe(); - pipe.setName("HX-L-To-LowerPlenum1"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { -10, 9, 0 }); - pipe.setOrientation(right); - Pipe HXLToLowerPlenum1 = pipe; - - pipe = new Pipe(); - pipe.setName("HX-R-To-LowerPlenum1"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { 10, 9, 0 }); - pipe.setOrientation(left); - Pipe HXRToLowerPlenum1 = pipe; - - junction = new Junction(); - junction.setName("HX-L-Out"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(HXL.getPrimaryPipe()); - junction.addOutput(HXLToLowerPlenum1); - - junction = new Junction(); - junction.setName("HX-R-Out"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(HXR.getPrimaryPipe()); - junction.addOutput(HXRToLowerPlenum1); - - length = 9.5; - - pipe = new Pipe(); - pipe.setName("HX-L-To-LowerPlenum2"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { -5, 8.75, 0 }); - pipe.setOrientation(down); - Pipe HXLToLowerPlenum2 = pipe; - - pipe = new Pipe(); - pipe.setName("HX-R-To-LowerPlenum2"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { 5, 8.75, 0 }); - pipe.setOrientation(down); - Pipe HXRToLowerPlenum2 = pipe; - - junction = new Junction(); - junction.setName("LowerPlenumJunction-L"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(HXLToLowerPlenum1); - junction.addOutput(HXLToLowerPlenum2); - - junction = new Junction(); - junction.setName("LowerPlenumJunction-R"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(HXRToLowerPlenum1); - junction.addOutput(HXRToLowerPlenum2); - - // -- Connect the lower plenum pipes to the lower plenum. -- // - lowerPlenum.addInput(HXLToLowerPlenum2); - lowerPlenum.addInput(HXRToLowerPlenum2); - - // -- Add water pipes to the left Heat Exchanger. -- // - length = 5; - - pipe = new Pipe(); - pipe.setName("HX-L-Water-In"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { -17, 18, 0 }); - pipe.setOrientation(new double[] { 1, -0.5, 0 }); - - junction = new Junction(); - junction.setName("HX-L-Water-In-Junction"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(pipe); - junction.addOutput(HXL); - - pipe = new Pipe(); - pipe.setName("HX-L-Water-Out"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { -12.5, 11, 0 }); - pipe.setOrientation(new double[] { -1, -0.5, 0 }); - - junction = new Junction(); - junction.setName("HX-L-Water-Out-Junction"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(HXL); - junction.addOutput(pipe); - - // -- Add water pipes to the right Heat Exchanger. -- // - length = 5; - - pipe = new Pipe(); - pipe.setName("HX-R-Water-In"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { 17, 18, 0 }); - pipe.setOrientation(new double[] { -1, -0.5, 0 }); - - junction = new Junction(); - junction.setName("HX-R-Water-In-Junction"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(pipe); - junction.addOutput(HXR); - - pipe = new Pipe(); - pipe.setName("HX-R-Water-Out"); - pipe.setId(id++); - plant.addPlantComponent(pipe); - pipe.setNumElements(numElements); - pipe.setLength(length); - pipe.setRadius(radius); - pipe.setPosition(new double[] { 12.5, 11, 0 }); - pipe.setOrientation(new double[] { 1, -0.5, 0 }); - - junction = new Junction(); - junction.setName("HX-R-Water-Out-Junction"); - junction.setId(id++); - plant.addPlantComponent(junction); - junction.addInput(HXR); - junction.addOutput(pipe); - // --------------------------- // - - // Write the objects. - factory.writeObjects(uri, objects); - - // Read the objects. - List loadedObjects = factory.readObjects(uri); - - assertNotNull(loadedObjects); - assertEquals(objects.size(), loadedObjects.size()); - assertEquals(objects.get(0), loadedObjects.get(0)); - - return; - } - - /** - * Deletes the ICEIOTestDirectory and all test files that are created in the - * above tests. - */ - @AfterClass - public static void deleteTestFiles() { - String s = System.getProperty("file.separator"); - String directory = System.getProperty("user.dir") + s - + "ICEIOTestDirectory" + s; - - // Create a file pointing at the ICEIOTestDirectory. - File testDirectory = new File(directory); - // Delete all of the test files in it. - for (File file : testDirectory.listFiles()) { - file.delete(); - } - // Then delete the directory itself. - if (testDirectory.delete()) { - System.out.println("PlantIOFactoryTester message: " - + "Deleted ICEIOTestDirectory."); - } else { - System.out.println("PlantIOFactoryTester message: " - + "Cannot delete ICEIOTestDirectory."); - } - - return; - } -} diff --git a/org.eclipse.ice.reactor.plant/META-INF/MANIFEST.MF b/org.eclipse.ice.reactor.plant/META-INF/MANIFEST.MF index a1476a0a1..0cf593f1d 100644 --- a/org.eclipse.ice.reactor.plant/META-INF/MANIFEST.MF +++ b/org.eclipse.ice.reactor.plant/META-INF/MANIFEST.MF @@ -6,9 +6,6 @@ Bundle-Version: 2.1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: org.eclipse.ice.datastructures Export-Package: org.eclipse.ice.reactor.plant -Import-Package: ncsa.hdf.hdf5lib, - ncsa.hdf.hdf5lib.exceptions, - org.eclipse.ice.io.hdf, - org.slf4j;version="1.7.2" +Import-Package: org.slf4j;version="1.7.2" Service-Component: OSGI-INF/PlantIOFactory.xml Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.reactor.plant/src/org/eclipse/ice/reactor/plant/PlantComponentReader.java b/org.eclipse.ice.reactor.plant/src/org/eclipse/ice/reactor/plant/PlantComponentReader.java deleted file mode 100644 index 2d9bb4203..000000000 --- a/org.eclipse.ice.reactor.plant/src/org/eclipse/ice/reactor/plant/PlantComponentReader.java +++ /dev/null @@ -1,577 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.plant; - -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; - -import ncsa.hdf.hdf5lib.HDF5Constants; -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; - -import org.eclipse.ice.datastructures.ICEObject.Composite; -import org.eclipse.ice.io.hdf.HdfIOFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - *

- * This class is used by the {@link PlantIOFactory} for reading PlantComponents - * from HDF5 files. It assumes an HDF5 Group is already opened (including the - * tag) and reads all of the attributes and datasets into the PlantComponent. - *

- *

- * This class uses the {@link IPlantComponentVisitor} interface to handle - * reading for each type of PlantComponent. - *

- * - * @author Jordan H. Deyton - * - */ -public class PlantComponentReader implements IPlantComponentVisitor { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(PlantComponentReader.class); - - /** - * The {@link PlantIOFactory} that is using this reader. We need access to - * it for its HDF5 reading methods. - */ - private final HdfIOFactory factory; - - /** - * A stack of opened group IDs in case the initial PlantComponent requires - * additional child PlantComponents to be read. - */ - private final Stack groupIds; - - /** - * The ancestor Composites containing the current Component being visited. - * There should always be at least one Composite in this stack (it has 0 - * children). - */ - private final Stack parents; - - /** - * The default constructor. - * - * @param factory - * The {@link PlantIOFactory} that is using this reader. We need - * access to it for its HDF5 reading methods. - */ - public PlantComponentReader(HdfIOFactory factory) { - - // Set the factory if possible. It should not be null. - this.factory = (factory != null ? factory : new HdfIOFactory()); - - // FIXME - Given the linear execution order required for this visitor, - // we *can* avoid using the stacks below. - - // Initialize the stack of HDF5 Group IDs. - groupIds = new Stack(); - - // Initialize the stack of parent Composites. - parents = new Stack(); - parents.push(new PlantComposite()); - - return; - } - - /** - * Reads a {@link PlantComponent}'s information from the specified HDF5 - * Group. - * - * @param component - * The PlantComponent whose information is being read from the - * file. - * @param groupId - * The HDF5 Group ID for the PlantComponent. - */ - public void readPlantComponent(PlantComponent component, int groupId) - throws NullPointerException, HDF5Exception { - // name:String - // description:String - // uniqueId:int - - if (component != null) { - - // Add the component's group ID to the top of the stack. - groupIds.push(groupId); - - // Write all of the component's ICEObject Attributes. - factory.readICEObjectInfo(component, groupId); - - // Visit the component to perform the proper read operations. - component.accept(this); - - // Remove the component's group ID from the top of the stack and - // check for any error. - int topGroup = groupIds.pop(); - if (groupId != topGroup) { - throw new HDF5Exception("PlantComponentReader error: " - + "Group mismatch! Expected group " + groupId - + " but found group " + topGroup); - } - } - return; - } - - @Override - public void visit(PlantComposite plantComp) { - - // Get the plant's HDF5 Group ID. - int plantId = groupIds.peek(); - - // Put the PlantComposite in the stack of parent Composites. - parents.push(plantComp); - - // The Pipes, Junctions, etc. are stored in different HDF5 Groups. - // Create a list of the names of these groups. - List groups = new ArrayList(5); - groups.add("Pipes"); - groups.add("HeatExchangers"); - groups.add("Junctions"); - groups.add("Reactors"); - groups.add("Other"); - - try { - // Read each major group of PlantComponents. - for (int i = 0; i < groups.size(); i++) { - String name = groups.get(i); - - // Open the major group of components. - int groupId = factory.openGroup(plantId, name); - - // Read each component from the open group of major components. - // Since the PlantIOFactory handles all PlantComponents, we do - // not need to look up the IO factory for the components. - for (String child : factory.getChildNames(groupId, - HDF5Constants.H5O_TYPE_GROUP)) { - // Open the component's group. - int componentId = factory.openGroup(groupId, child); - // Read the group's tag. - String tag = factory.readTag(componentId); - // Read the component (requires the tag). - Object object = factory.read(componentId, tag); - // Add the component to the PlantComposite. - plantComp.addPlantComponent((PlantComponent) object); - // Close the component's group. - factory.closeGroup(componentId); - } - - // Close the major group of components. - factory.closeGroup(groupId); - } - // ------------------------- // - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write PlantComposite " + plantComp.getName() - + " " + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write PlantComposite " + plantComp.getName() - + " " + plantComp.getId()); - } - - parents.pop(); - - return; - } - - // ---- Base classes ---- // - @Override - public void visit(GeometricalComponent plantComp) { - // super:PlantComponent - // position:double[3] - // orientation:double[3] - // rotation:double - // numElements:int - - int objectId = groupIds.peek(); - - try { - int H5T_NATIVE_INT = HDF5Constants.H5T_NATIVE_INT; - int H5T_NATIVE_DOUBLE = HDF5Constants.H5T_NATIVE_DOUBLE; - - // Read the rotation. - plantComp.setRotation((Double) factory.readAttribute(objectId, - "rotation", H5T_NATIVE_DOUBLE)); - - // Read the number of elements. - plantComp.setNumElements((Integer) factory.readAttribute(objectId, - "numElements", H5T_NATIVE_INT)); - - // ---- Position and orientation ---- // - // Combine the position and orientation into a single Dataset - // (rather, a 2x3 array of doubles). - - // The overall array containing position and orientation is 2x3. - int type = HDF5Constants.H5T_NATIVE_DOUBLE; - // Create the buffer that contains the position and orientation - // values. - double[] buffer = (double[]) factory.readDataset(objectId, - "vectors", type); - - double[] vector = new double[3]; - - System.arraycopy(buffer, 0, vector, 0, 3); - plantComp.setPosition(vector); - - System.arraycopy(buffer, 3, vector, 0, 3); - plantComp.setOrientation(vector); - // ---------------------------------- // - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentReader error: " - + "Failed to read GeometricalComponent " - + plantComp.getName() + " " + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentReader error: " - + "Failed to read GeometricalComponent " - + plantComp.getName() + " " + plantComp.getId()); - } - - return; - } - - @Override - public void visit(Junction plantComp) { - // super:PlantComponent - // inputs:List - // outputs:List - - // Get the junction's HDF5 Group ID. - int junctionId = groupIds.peek(); - // Get the parent Composite. - Composite parent = parents.peek(); - - try { - int type = HDF5Constants.H5T_NATIVE_INT; - int[] buffer; - - // Create a list of input PlantComponents. - ArrayList inputs = new ArrayList(); - // Read all IDs from the junction's "inputs" dataset. Query the - // parent Composite for the PlantComponents with the IDs and put - // the components into the list of inputs. - buffer = (int[]) factory.readDataset(junctionId, "inputs", type); - for (int i = 0; i < buffer.length;) { - int id = buffer[i++]; - PlantComponent component = (PlantComponent) parent - .getComponent(id); - if (buffer[i++] == 1 && component instanceof HeatExchanger) { - inputs.add(((HeatExchanger) component).getPrimaryPipe()); - } else { - inputs.add(component); - } - } - // Set the inputs for the junction. - plantComp.setInputs(inputs); - - // Create a list of output PlantComponents. - ArrayList outputs = new ArrayList(); - // Read all IDs from the junction's "outputs" dataset. Query the - // parent Composite for the PlantComponents with the IDs and put - // the components into the list of outputs. - buffer = (int[]) factory.readDataset(junctionId, "outputs", type); - for (int i = 0; i < buffer.length;) { - int id = buffer[i++]; - PlantComponent component = (PlantComponent) parent - .getComponent(id); - if (buffer[i++] == 1 && component instanceof HeatExchanger) { - outputs.add(((HeatExchanger) component).getPrimaryPipe()); - } else { - outputs.add(component); - } - } - // Set the outputs for the junction. - plantComp.setOutputs(outputs); - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Junction " + plantComp.getName() + " " - + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Junction " + plantComp.getName() + " " - + plantComp.getId()); - } - - return; - } - - @Override - public void visit(Reactor plantComp) { - // super:PlantComponent - // coreChannels:List - - // Get the junction's HDF5 Group ID. - int reactorId = groupIds.peek(); - // Get the parent Composite. - Composite parent = parents.peek(); - - try { - int type = HDF5Constants.H5T_NATIVE_INT; - int[] buffer; - - // Create a list of . - ArrayList coreChannels = new ArrayList(); - // Read all IDs from the reactor's "coreChannels" dataset. Query the - // parent Composite for the PlantComponents with the IDs and put - // the components into the list of core channels. - buffer = (int[]) factory.readDataset(reactorId, "coreChannels", - type); - for (int i = 0; i < buffer.length; i++) { - coreChannels.add((CoreChannel) parent.getComponent(buffer[i])); - } - // Set the core channels for the reactor. - plantComp.setCoreChannels(coreChannels); - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Junction " + plantComp.getName() + " " - + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Junction " + plantComp.getName() + " " - + plantComp.getId()); - } - - return; - } - - @Override - public void visit(PointKinetics plantComp) { - // super:PlantComponent - - // Nothing to do. - } - - @Override - public void visit(HeatExchanger plantComp) { - // super:GeometricalComponent - // innerRadius:double - // length:double - // primaryPipe:Pipe - // secondaryPipe:Pipe - - // Write the GeometricalComponent properties. - visit((GeometricalComponent) plantComp); - - int objectId = groupIds.peek(); - - try { - - int H5T_NATIVE_DOUBLE = HDF5Constants.H5T_NATIVE_DOUBLE; - - // Read the radius. - plantComp.setInnerRadius((Double) factory.readAttribute(objectId, - "innerRadius", H5T_NATIVE_DOUBLE)); - - // Read the length. - plantComp.setLength((Double) factory.readAttribute(objectId, - "length", H5T_NATIVE_DOUBLE)); - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentReader error: " - + "Failed to read HeatExchanger " + plantComp.getName() - + " " + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentReader error: " - + "Failed to read HeatExchanger " + plantComp.getName() - + " " + plantComp.getId()); - } - - return; - } - - @Override - public void visit(Pipe plantComp) { - // super:GeometricalComponent - // radius:double - // length:double - - // Write the GeometricalComponent properties. - visit((GeometricalComponent) plantComp); - - int objectId = groupIds.peek(); - - try { - - int H5T_NATIVE_DOUBLE = HDF5Constants.H5T_NATIVE_DOUBLE; - - // Read the radius. - plantComp.setRadius((Double) factory.readAttribute(objectId, - "radius", H5T_NATIVE_DOUBLE)); - - // Read the length. - plantComp.setLength((Double) factory.readAttribute(objectId, - "length", H5T_NATIVE_DOUBLE)); - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentReader error: " + "Failed to read Pipe " - + plantComp.getName() + " " + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentReader error: " + "Failed to read Pipe " - + plantComp.getName() + " " + plantComp.getId()); - } - - return; - } - - // ---- Pipe subclasses ---- // - @Override - public void visit(CoreChannel plantComp) { - visit((Pipe) plantComp); - } - - @Override - public void visit(Subchannel plantComp) { - visit((Pipe) plantComp); - - } - - @Override - public void visit(PipeWithHeatStructure plantComp) { - visit((Pipe) plantComp); - - } - - // ---- Junction subclasses ---- // - @Override - public void visit(Branch plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SubchannelBranch plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(VolumeBranch plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(FlowJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(WetWell plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Boundary plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(OneInOneOutJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Turbine plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(IdealPump plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Pump plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Valve plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(PipeToPipeJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Inlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(MassFlowInlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SpecifiedDensityAndVelocityInlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Outlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SolidWall plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(TDM plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(TimeDependentJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(TimeDependentVolume plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(DownComer plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SeparatorDryer plantComp) { - visit((Junction) plantComp); - } - -} diff --git a/org.eclipse.ice.reactor.plant/src/org/eclipse/ice/reactor/plant/PlantComponentWriter.java b/org.eclipse.ice.reactor.plant/src/org/eclipse/ice/reactor/plant/PlantComponentWriter.java deleted file mode 100644 index 0054ab03f..000000000 --- a/org.eclipse.ice.reactor.plant/src/org/eclipse/ice/reactor/plant/PlantComponentWriter.java +++ /dev/null @@ -1,770 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.plant; - -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; - -import ncsa.hdf.hdf5lib.HDF5Constants; -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; - -import org.eclipse.ice.datastructures.ICEObject.Composite; -import org.eclipse.ice.io.hdf.HdfIOFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - *

- * This class is used by the {@link PlantIOFactory} for writing PlantComponents - * to HDF5 files. It assumes an HDF5 Group is already created (including the - * tag) and adds all of the attributes and datasets for the information stored - * in the PlantComponent. - *

- *

- * This class uses the {@link IPlantComponentVisitor} interface to handle - * writing for each type of PlantComponent. - *

- * - * @author Jordan H. Deyton - * - */ -public class PlantComponentWriter implements IPlantComponentVisitor { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(PlantComponentWriter.class); - - /** - * The {@link PlantIOFactory} that is using this writer. We need access to - * it for its HDF5 writing methods. - */ - private final HdfIOFactory factory; - - /** - * A stack of opened group IDs in case the initial PlantComponent requires - * additional child PlantComponents to be written. - */ - private final Stack groupIds; - - /** - * The ancestor Composites containing the current Component being visited. - * There should always be at least one Composite in this stack (it has 0 - * children). - */ - private final Stack parents; - - /** - * The default constructor. - * - * @param factory - * The {@link PlantIOFactory} that is using this writer. We need - * access to it for its HDF5 writing methods. - */ - public PlantComponentWriter(HdfIOFactory factory) { - - // Set the factory if possible. It should not be null. - this.factory = (factory != null ? factory : new HdfIOFactory()); - - // FIXME - Given the linear execution order required for this visitor, - // we *can* avoid using the stacks below. - - // Initialize the stack of HDF5 Group IDs. - groupIds = new Stack(); - - // Initialize the stack of parent Composites. - parents = new Stack(); - parents.push(new PlantComposite()); - - return; - } - - /** - * Writes a {@link PlantComponent}'s information to the specified HDF5 Group - * ID. - * - * @param component - * The PlantComponent to write to the file. - * @param groupId - * The HDF5 Group ID for the PlantComponent. - */ - public void writePlantComponent(PlantComponent component, int groupId) - throws NullPointerException, HDF5Exception { - // name:String - // description:String - // uniqueId:int - - if (component != null) { - - // Add the component's group ID to the top of the stack. - groupIds.push(groupId); - - // Write all of the component's ICEObject Attributes. - factory.writeICEObjectInfo(component, groupId); - - // Visit the component to perform the proper write operations. - component.accept(this); - - // Remove the component's group ID from the top of the stack and - // check for any error. - int topGroup = groupIds.pop(); - if (groupId != topGroup) { - throw new HDF5Exception("PlantComponentWriter error: " - + "Group mismatch! Expected group " + groupId - + " but found group " + topGroup); - } - } - return; - } - - @Override - public void visit(PlantComposite plantComp) { - - // This method writes a PlantComposite in the following way: - // Pipes, HeatExchangers, Junctions, Reactors, and other PlantComponents - // are split into separate groups. This is done so that Pipes and - // HeatExchangers can be read in first (Junctions and Reactors use - // Pipes and HeatExchangers). - - // Create the lists of components for each major group listed above. - final List pipes = new ArrayList(); - final List heatExchangers = new ArrayList(); - final List junctions = new ArrayList(); - final List reactors = new ArrayList(); - final List others = new ArrayList(); - - // Create a visitor that puts components into the above lists depending - // on its base type, e.g. Pipe sub-classes go in the pipes list. - IPlantComponentVisitor visitor = new IPlantComponentVisitor() { - - @Override - public void visit(PlantComposite plantComp) { - // Do nothing. - } - - @Override - public void visit(GeometricalComponent plantComp) { - others.add(plantComp); - } - - @Override - public void visit(Junction plantComp) { - junctions.add(plantComp); - } - - @Override - public void visit(Reactor plantComp) { - reactors.add(plantComp); - } - - @Override - public void visit(PointKinetics plantComp) { - others.add(plantComp); - } - - @Override - public void visit(HeatExchanger plantComp) { - heatExchangers.add(plantComp); - } - - @Override - public void visit(Pipe plantComp) { - pipes.add(plantComp); - } - - @Override - public void visit(CoreChannel plantComp) { - visit((Pipe) plantComp); - } - - @Override - public void visit(Subchannel plantComp) { - visit((Pipe) plantComp); - } - - @Override - public void visit(PipeWithHeatStructure plantComp) { - visit((Pipe) plantComp); - } - - @Override - public void visit(Branch plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SubchannelBranch plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(VolumeBranch plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(FlowJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(WetWell plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Boundary plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(OneInOneOutJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Turbine plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(IdealPump plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Pump plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Valve plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(PipeToPipeJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Inlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(MassFlowInlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SpecifiedDensityAndVelocityInlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Outlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SolidWall plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(TDM plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(TimeDependentJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(TimeDependentVolume plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(DownComer plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SeparatorDryer plantComp) { - visit((Junction) plantComp); - } - - }; - // Use the visitor to sort all of the plant's components. - for (PlantComponent component : plantComp.getPlantComponents()) { - if (component != null) { - component.accept(visitor); - } - } - - // Get the plant's HDF5 Group ID. - int plantId = groupIds.peek(); - - // Put the PlantComposite in the stack of parent Composites. - parents.push(plantComp); - - // We want to write the Pipes, Junctions, etc. in different groups. - // Create a list of the names of these groups. - List groups = new ArrayList(5); - groups.add("Pipes"); - groups.add("HeatExchangers"); - groups.add("Junctions"); - groups.add("Reactors"); - groups.add("Other"); - - // Associate a the lists used by the visitor with the group names. We - // use an implied association by using the same index for this list and - // the list of group names above. - List> lists = new ArrayList>( - 5); - lists.add(pipes); - lists.add(heatExchangers); - lists.add(junctions); - lists.add(reactors); - lists.add(others); - - try { - // Write each major group of PlantComponents. - for (int i = 0; i < groups.size(); i++) { - // Get the group's name and its list of PlantComponents. - String name = groups.get(i); - List list = lists.get(i); - - // Create the major group of components. - int groupId = factory.createGroup(plantId, name); - - // Write a new group for each PlantComponent in this major - // group. Since the PlantIOFactory handles all PlantComponents, - // we do not need to look up the IO factory for the components. - for (PlantComponent component : list) { - // Create a group for the component. - int componentId = factory.createGroup(groupId, - component.toString()); - // Write the tag Attribute for the component. - String tag = factory.getTag(component.getClass()); - factory.writeTag(tag, componentId); - // Write the object's data to its new group. - factory.writeObjectData(componentId, component); - // Close the component's group. - factory.closeGroup(componentId); - } - - // Close the major group of components. - factory.closeGroup(groupId); - } - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write PlantComposite " + plantComp.getName() - + " " + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write PlantComposite " + plantComp.getName() - + " " + plantComp.getId()); - } - - // Remove the PlantComposite from the stack of parent Composites. - parents.pop(); - - return; - } - - // ---- Base classes ---- // - @Override - public void visit(GeometricalComponent plantComp) { - // super:PlantComponent - // position:double[3] - // orientation:double[3] - // rotation:double - // numElements:int - - int objectId = groupIds.peek(); - - try { - // Write the rotation. - factory.writeAttribute(objectId, "rotation", - HDF5Constants.H5T_NATIVE_DOUBLE, plantComp.getRotation()); - // Write the number of elements. - factory.writeAttribute(objectId, "numElements", - HDF5Constants.H5T_NATIVE_INT, plantComp.getNumElements()); - - // ---- Position and orientation ---- // - // Combine the position and orientation into a single Dataset - // (rather, a 2x3 array of doubles). - - // The overall array containing position and orientation is 2x3. - long[] dims = new long[] { 2, 3 }; - int type = HDF5Constants.H5T_NATIVE_DOUBLE; - // Create the buffer that contains the position and orientation - // values. - double[] buffer = new double[6]; - System.arraycopy(plantComp.getPosition(), 0, buffer, 0, 3); - System.arraycopy(plantComp.getOrientation(), 0, buffer, 3, 3); - // Write the Dataset. - factory.writeDataset(objectId, "vectors", 2, dims, type, buffer); - // ---------------------------------- // - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write GeometricalComponent " - + plantComp.getName() + " " + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write GeometricalComponent " - + plantComp.getName() + " " + plantComp.getId()); - } - - return; - } - - @Override - public void visit(Junction plantComp) { - // super:PlantComponent - // inputs:List - // outputs:List - - // Get the junction's HDF5 Group ID. - int junctionId = groupIds.peek(); - - try { - // Get the junction's inputs. - List inputs = plantComp.getInputs(); - int size = inputs.size(); - - // Set up the parameters required to write a 1-D dataset containing - // the IDs of all input components. - - // The number of dimensions is 1. - int rank = 2; - // The size of each dimension (in this case, the number of inputs). - long[] dims = new long[] { size, 2 }; - // The type of data stored in the dataset (integers). - int type = HDF5Constants.H5T_NATIVE_INT; - // Create the buffer that contains the dataset's raw information. We - // need to put the IDs of all the inputs in this buffer. - int bufferSize = size * 2; - int[] buffer = new int[bufferSize]; - for (int i = 0, j = 0; i < bufferSize; j++) { - PlantComponent component = inputs.get(j); - buffer[i++] = component.getId(); - buffer[i++] = (component instanceof HeatExchanger ? 0 : 1); - } - // Write the inputs dataset. - factory.writeDataset(junctionId, "inputs", rank, dims, type, buffer); - - // Get the junction's outputs. - List outputs = plantComp.getOutputs(); - size = outputs.size(); - - // Set up the parameters required to write a 1-D dataset containing - // the IDs of all input components. - - // Update the dimensions and the buffer. - dims[0] = size; - bufferSize = size * 2; - buffer = new int[bufferSize]; - for (int i = 0, j = 0; i < bufferSize; j++) { - PlantComponent component = outputs.get(j); - buffer[i++] = component.getId(); - buffer[i++] = (component instanceof HeatExchanger ? 0 : 1); - } - // Write the outputs dataset. - factory.writeDataset(junctionId, "outputs", rank, dims, type, - buffer); - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Junction " + plantComp.getName() + " " - + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Junction " + plantComp.getName() + " " - + plantComp.getId()); - } - - return; - } - - @Override - public void visit(Reactor plantComp) { - // super:PlantComponent - // coreChannels:List - - // Get the junction's HDF5 Group ID. - int reactorId = groupIds.peek(); - - try { - // Get the reactor's core channels. - List coreChannels = plantComp.getCoreChannels(); - int size = coreChannels.size(); - - // Set up the parameters required to write a 1-D dataset containing - // the IDs of all input components. - - // The number of dimensions is 1. - int rank = 1; - // The size of each dimension (in this case, the number of inputs). - long[] dims = new long[] { size }; - // The type of data stored in the dataset (integers). - int type = HDF5Constants.H5T_NATIVE_INT; - // Create the buffer that contains the dataset's raw information. We - // need to put the IDs of all the inputs in this buffer. - int[] buffer = new int[size]; - for (int i = 0; i < size; i++) { - buffer[i] = coreChannels.get(i).getId(); - } - // Write the coreChannels dataset. - factory.writeDataset(reactorId, "coreChannels", rank, dims, type, - buffer); - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Junction " + plantComp.getName() + " " - + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Junction " + plantComp.getName() + " " - + plantComp.getId()); - } - - return; - } - - @Override - public void visit(PointKinetics plantComp) { - // super:PlantComponent - - // Nothing to do. - } - - @Override - public void visit(HeatExchanger plantComp) { - // super:GeometricalComponent - // innerRadius:double - // length:double - // primaryPipe:Pipe - // secondaryPipe:Pipe - - // Write the GeometricalComponent properties. - visit((GeometricalComponent) plantComp); - - int objectId = groupIds.peek(); - - try { - - // Write the radius. - factory.writeAttribute(objectId, "innerRadius", - HDF5Constants.H5T_NATIVE_DOUBLE, plantComp.getInnerRadius()); - // Write the length. - factory.writeAttribute(objectId, "length", - HDF5Constants.H5T_NATIVE_DOUBLE, plantComp.getLength()); - - // There is currently no need to write the pipe information since - // they are tied directly to the HeatExchanger's properties. - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write HeatExchanger " + plantComp.getName() - + " " + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write HeatExchanger " + plantComp.getName() - + " " + plantComp.getId()); - } - - return; - } - - @Override - public void visit(Pipe plantComp) { - // super:GeometricalComponent - // radius:double - // length:double - - // Write the GeometricalComponent properties. - visit((GeometricalComponent) plantComp); - - int objectId = groupIds.peek(); - - try { - - // Write the radius. - factory.writeAttribute(objectId, "radius", - HDF5Constants.H5T_NATIVE_DOUBLE, plantComp.getRadius()); - // Write the length. - factory.writeAttribute(objectId, "length", - HDF5Constants.H5T_NATIVE_DOUBLE, plantComp.getLength()); - - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Pipe " + plantComp.getName() + " " - + plantComp.getId()); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - logger.info("PlantComponentWriter error: " - + "Failed to write Pipe " + plantComp.getName() + " " - + plantComp.getId()); - } - - return; - } - - // ---- Pipe subclasses ---- // - @Override - public void visit(CoreChannel plantComp) { - visit((Pipe) plantComp); - } - - @Override - public void visit(Subchannel plantComp) { - visit((Pipe) plantComp); - } - - @Override - public void visit(PipeWithHeatStructure plantComp) { - visit((Pipe) plantComp); - } - - // ---- Junction subclasses ---- // - @Override - public void visit(Branch plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SubchannelBranch plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(VolumeBranch plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(FlowJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(WetWell plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Boundary plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(OneInOneOutJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Turbine plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(IdealPump plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Pump plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Valve plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(PipeToPipeJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Inlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(MassFlowInlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SpecifiedDensityAndVelocityInlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(Outlet plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SolidWall plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(TDM plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(TimeDependentJunction plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(TimeDependentVolume plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(DownComer plantComp) { - visit((Junction) plantComp); - } - - @Override - public void visit(SeparatorDryer plantComp) { - visit((Junction) plantComp); - } - -} diff --git a/org.eclipse.ice.reactor.plant/src/org/eclipse/ice/reactor/plant/PlantIOFactory.java b/org.eclipse.ice.reactor.plant/src/org/eclipse/ice/reactor/plant/PlantIOFactory.java deleted file mode 100644 index cfeef8131..000000000 --- a/org.eclipse.ice.reactor.plant/src/org/eclipse/ice/reactor/plant/PlantIOFactory.java +++ /dev/null @@ -1,628 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.plant; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; -import ncsa.hdf.hdf5lib.exceptions.HDF5LibraryException; - -import org.eclipse.ice.io.hdf.HdfIOFactory; - -/** - * This class provides an implementation of {@link HdfIOFactory} geared toward - * {@link PlantComponent}s. - * - * @author Jordan H. Deyton - * - */ -public class PlantIOFactory extends HdfIOFactory { - - /** - * The writer is responsible for writing an individual PlantComponent. - */ - private final PlantComponentWriter writer; - /** - * The reader is responsible for creating and reading a PlantComponent from - * an HDF5 Group. - */ - private final PlantComponentReader reader; - - /** - * A simple interface for creating {@link PlantComponent}s. - * - * @author Jordan H. Deyton - * - */ - private interface IComponentCreator { - /** - * Gets a tag associated with the PlantComponent type. - */ - public String getTag(); - - /** - * Creates a new PlantComponent of the desired type. - */ - public PlantComponent createComponent(); - } - - /** - * A Map of the tag Attributes to {@link IComponentCreator}s. - */ - private Map tagMap; - /** - * A Map of the supported classes to {@link IComponentCreator}s. - */ - private Map, IComponentCreator> classMap; - - /** - * The default constructor. - */ - public PlantIOFactory() { - - // Create the component writer and reader. - writer = new PlantComponentWriter(this); - reader = new PlantComponentReader(this); - - // Create the two maps of classes, tags, and component creators. - tagMap = new HashMap(); - classMap = new HashMap, IComponentCreator>(); - - IComponentCreator creator; - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.composite"; - } - - @Override - public PlantComponent createComponent() { - return new PlantComposite(); - } - }; - tagMap.put(creator.getTag(), creator); - classMap.put(PlantComposite.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.pipe"; - } - - @Override - public PlantComponent createComponent() { - return new Pipe(); - } - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Pipe.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.heatExchanger"; - } - - @Override - public PlantComponent createComponent() { - return new HeatExchanger(); - } - }; - tagMap.put(creator.getTag(), creator); - classMap.put(HeatExchanger.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.junction"; - } - - @Override - public PlantComponent createComponent() { - return new Junction(); - } - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Junction.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.reactor"; - } - - @Override - public PlantComponent createComponent() { - return new Reactor(); - } - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Reactor.class, creator); - - // TODO Add the other classes. - - // Generic classes. - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.GeometricalComponent"; - } - - @Override - public PlantComponent createComponent() { - return new GeometricalComponent(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(GeometricalComponent.class, creator); - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.PointKinetics"; - } - - @Override - public PlantComponent createComponent() { - return new PointKinetics(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(PointKinetics.class, creator); - - // Pipe sub-classes - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.CoreChannel"; - } - - @Override - public PlantComponent createComponent() { - return new CoreChannel(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(CoreChannel.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.Subchannel"; - } - - @Override - public PlantComponent createComponent() { - return new Subchannel(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Subchannel.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.PipeWithHeatStructure"; - } - - @Override - public PlantComponent createComponent() { - return new PipeWithHeatStructure(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(PipeWithHeatStructure.class, creator); - - // Junction sub-classes. - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.Branch"; - } - - @Override - public PlantComponent createComponent() { - return new Branch(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Branch.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.SubchannelBranch"; - } - - @Override - public PlantComponent createComponent() { - return new SubchannelBranch(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(SubchannelBranch.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.VolumeBranch"; - } - - @Override - public PlantComponent createComponent() { - return new VolumeBranch(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(VolumeBranch.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.FlowJunction"; - } - - @Override - public PlantComponent createComponent() { - return new FlowJunction(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(FlowJunction.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.WetWell"; - } - - @Override - public PlantComponent createComponent() { - return new WetWell(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(WetWell.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.Boundary"; - } - - @Override - public PlantComponent createComponent() { - return new Boundary(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Boundary.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.OneInOneOutJunction"; - } - - @Override - public PlantComponent createComponent() { - return new OneInOneOutJunction(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(OneInOneOutJunction.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.Turbine"; - } - - @Override - public PlantComponent createComponent() { - return new Turbine(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Turbine.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.IdealPump"; - } - - @Override - public PlantComponent createComponent() { - return new IdealPump(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(IdealPump.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.Pump"; - } - - @Override - public PlantComponent createComponent() { - return new Pump(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Pump.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.Valve"; - } - - @Override - public PlantComponent createComponent() { - return new Valve(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Valve.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.PipeToPipeJunction"; - } - - @Override - public PlantComponent createComponent() { - return new PipeToPipeJunction(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(PipeToPipeJunction.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.Inlet"; - } - - @Override - public PlantComponent createComponent() { - return new Inlet(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Inlet.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.MassFlowInlet"; - } - - @Override - public PlantComponent createComponent() { - return new MassFlowInlet(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(MassFlowInlet.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.SpecifiedDensityAndVelocityInlet"; - } - - @Override - public PlantComponent createComponent() { - return new SpecifiedDensityAndVelocityInlet(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(SpecifiedDensityAndVelocityInlet.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.Outlet"; - } - - @Override - public PlantComponent createComponent() { - return new Outlet(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(Outlet.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.SolidWall"; - } - - @Override - public PlantComponent createComponent() { - return new SolidWall(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(SolidWall.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.TDM"; - } - - @Override - public PlantComponent createComponent() { - return new TDM(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(TDM.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.TimeDependentJunction"; - } - - @Override - public PlantComponent createComponent() { - return new TimeDependentJunction(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(TimeDependentJunction.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.TimeDependentVolume"; - } - - @Override - public PlantComponent createComponent() { - return new TimeDependentVolume(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(TimeDependentVolume.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.DownComer"; - } - - @Override - public PlantComponent createComponent() { - return new DownComer(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(DownComer.class, creator); - - creator = new IComponentCreator() { - @Override - public String getTag() { - return "plant.SeparatorDryer"; - } - - @Override - public PlantComponent createComponent() { - return new SeparatorDryer(); - } - - }; - tagMap.put(creator.getTag(), creator); - classMap.put(SeparatorDryer.class, creator); - - return; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.io.hdf.IHdfIOFactory#getSupportedClasses() - */ - @Override - public List> getSupportedClasses() { - return new ArrayList>(classMap.keySet()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.io.hdf.IHdfIOFactory#getTag(java.lang.Class) - */ - @Override - public String getTag(Class supportedClass) { - IComponentCreator creator = classMap.get(supportedClass); - return (creator != null ? creator.getTag() : null); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.io.hdf.HdfIOFactory#writeObjectData(int, - * java.lang.Object) - */ - @Override - public void writeObjectData(int groupId, Object object) - throws NullPointerException, HDF5Exception, HDF5LibraryException { - - // Use the writer to write any PlantComponents. - if (object != null && object instanceof PlantComponent) { - writer.writePlantComponent((PlantComponent) object, groupId); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ice.io.hdf.IHdfIOFactory#read(int, java.lang.String) - */ - @Override - public Object read(int groupId, String tag) throws NullPointerException, - HDF5Exception, HDF5LibraryException { - - Object object = null; - - // We need to create a new PlantComponent based on the tag. Then, use - // the reader to load the component with the data from the file. - IComponentCreator creator = tagMap.get(tag); - if (creator != null) { - PlantComponent component = creator.createComponent(); - reader.readPlantComponent(component, groupId); - object = component; - } - - return object; - } - -} diff --git a/org.eclipse.ice.reactor.sfr.test/.classpath b/org.eclipse.ice.reactor.sfr.test/.classpath deleted file mode 100644 index 2889fb373..000000000 --- a/org.eclipse.ice.reactor.sfr.test/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/org.eclipse.ice.reactor.sfr.test/.gitignore b/org.eclipse.ice.reactor.sfr.test/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.reactor.sfr.test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.reactor.sfr.test/.project b/org.eclipse.ice.reactor.sfr.test/.project deleted file mode 100644 index 587f4f9b6..000000000 --- a/org.eclipse.ice.reactor.sfr.test/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.ice.reactor.sfr.test - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.reactor.sfr.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.reactor.sfr.test/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 095702d2e..000000000 --- a/org.eclipse.ice.reactor.sfr.test/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Mon Oct 21 10:01:48 EDT 2013 -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/org.eclipse.ice.reactor.sfr.test/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.reactor.sfr.test/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 2016fe2a4..000000000 --- a/org.eclipse.ice.reactor.sfr.test/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Oct 21 10:01:48 EDT 2013 -eclipse.preferences.version=1 -resolve.requirebundle=false -pluginProject.extensions=false diff --git a/org.eclipse.ice.reactor.sfr.test/ICEIOTestDirectory/fromCPP.h5 b/org.eclipse.ice.reactor.sfr.test/ICEIOTestDirectory/fromCPP.h5 deleted file mode 100644 index a62fd0fac..000000000 Binary files a/org.eclipse.ice.reactor.sfr.test/ICEIOTestDirectory/fromCPP.h5 and /dev/null differ diff --git a/org.eclipse.ice.reactor.sfr.test/META-INF/MANIFEST.MF b/org.eclipse.ice.reactor.sfr.test/META-INF/MANIFEST.MF deleted file mode 100644 index a820945d3..000000000 --- a/org.eclipse.ice.reactor.sfr.test/META-INF/MANIFEST.MF +++ /dev/null @@ -1,16 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: org.eclipse.ice.reactor.sfr.test -Bundle-SymbolicName: org.eclipse.ice.reactor.sfr.test -Bundle-Version: 2.1.8 -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: org.eclipse.ice.datastructures, - org.junit -Import-Package: org.eclipse.ice.analysistool, - org.eclipse.ice.datastructures.test, - org.eclipse.ice.reactor.sfr.base, - org.eclipse.ice.reactor.sfr.core, - org.eclipse.ice.reactor.sfr.core.assembly, - org.eclipse.ice.viz.service.datastructures, - org.eclipse.ice.viz.service.mesh.datastructures -Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.reactor.sfr.test/about.html b/org.eclipse.ice.reactor.sfr.test/about.html deleted file mode 100644 index b47b18406..000000000 --- a/org.eclipse.ice.reactor.sfr.test/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

July 1, 2014

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/build.properties b/org.eclipse.ice.reactor.sfr.test/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/org.eclipse.ice.reactor.sfr.test/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/org.eclipse.ice.reactor.sfr.test/pom.xml b/org.eclipse.ice.reactor.sfr.test/pom.xml deleted file mode 100644 index 2ff4fbf1b..000000000 --- a/org.eclipse.ice.reactor.sfr.test/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.reactor.sfr.test - eclipse-test-plugin - - true - - diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/FeatureSetTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/FeatureSetTester.java deleted file mode 100644 index 279b1f25f..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/FeatureSetTester.java +++ /dev/null @@ -1,351 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; - -import org.eclipse.ice.analysistool.IData; -import org.eclipse.ice.reactor.sfr.base.FeatureSet; -import org.eclipse.ice.reactor.sfr.base.SFRData; -import org.junit.Test; - -/** - *

- * Tests the operations of the FeatureSet class. - *

- * - * @author Anna Wojtowicz - */ -public class FeatureSetTester { - /** - *

- * Tests the constructors and default values of the FeatureSet container - * class. - *

- * - */ - @Test - public void checkConstruction() { - - FeatureSet featureSet; - String defaultFeature = null; - String feature = "Infinite Improbability Drive"; - ArrayList data = new ArrayList(); - - // Check the defaults for the constructor with an invalid String. - featureSet = new FeatureSet(null); - assertEquals(defaultFeature, featureSet.getName()); - assertEquals(data, featureSet.getData()); - - // Check the values for a constructor with an invalid empty String. - featureSet = new FeatureSet(""); - assertEquals(defaultFeature, featureSet.getName()); - assertEquals(data, featureSet.getData()); - - // Check the values for a constructor with an invalid whitespace String. - featureSet = new FeatureSet(" "); - assertEquals(defaultFeature, featureSet.getName()); - assertEquals(data, featureSet.getData()); - - // Check the values for a constructor with a valid name. - featureSet = new FeatureSet(feature); - assertEquals(feature, featureSet.getName()); - assertEquals(data, featureSet.getData()); - - return; - } - - /** - *

- * Tests the getter and addition of IData to a FeatureSet. - *

- * - */ - @Test - public void checkData() { - - // Some features. - String sameFeature = "Slartibartfast"; - String diffFeature = "Almighty Bob"; - - // Some data using the features. - SFRData sameData1 = new SFRData(sameFeature); - SFRData sameData2 = new SFRData(sameFeature); - SFRData diffData = new SFRData(diffFeature); - - sameData1.setValue(3.1415926); - diffData.setUncertainty(1.41421); - - /* ---- Test a normal FeatureSet. ---- */ - // Construct a normal FeatureSet. - FeatureSet featureSet = new FeatureSet(sameFeature); - - // Add some data for that feature. - assertTrue(featureSet.addIData(sameData1)); - // Check the contents. - assertEquals(1, featureSet.getData().size()); - assertTrue(sameData1.equals(featureSet.getData().get(0))); - - // Add some more data. - assertTrue(featureSet.addIData(sameData2)); - // Check the contents. - assertEquals(2, featureSet.getData().size()); - assertTrue(sameData1.equals(featureSet.getData().get(0))); - assertTrue(sameData2.equals(featureSet.getData().get(1))); - - // Try adding the same data again. - assertTrue(featureSet.addIData(sameData1)); - // Check the contents. - assertEquals(3, featureSet.getData().size()); - assertTrue(sameData1.equals(featureSet.getData().get(0))); - assertTrue(sameData2.equals(featureSet.getData().get(1))); - assertTrue(sameData1.equals(featureSet.getData().get(2))); - - // Add some data for a different feature. - assertFalse(featureSet.addIData(diffData)); - // Check the contents. - assertEquals(3, featureSet.getData().size()); - assertTrue(sameData1.equals(featureSet.getData().get(0))); - assertTrue(sameData2.equals(featureSet.getData().get(1))); - assertTrue(sameData1.equals(featureSet.getData().get(2))); - - // Try adding a null IData. - assertFalse(featureSet.addIData(null)); - // Check the contents. - assertEquals(3, featureSet.getData().size()); - assertTrue(sameData1.equals(featureSet.getData().get(0))); - assertTrue(sameData2.equals(featureSet.getData().get(1))); - assertTrue(sameData1.equals(featureSet.getData().get(2))); - - // Show that we can manipulate the data List directly. - ArrayList dataList = featureSet.getData(); - dataList.remove(dataList.size() - 1); - // Check the contents. - assertEquals(2, featureSet.getData().size()); - assertTrue(sameData1.equals(featureSet.getData().get(0))); - assertTrue(sameData2.equals(featureSet.getData().get(1))); - /* ----------------------------------- */ - - /* ---- Test a FeatureSet with an invalid name. ---- */ - // Construct an invalid FeatureSet. - featureSet = new FeatureSet(null); - - // Add some data for that feature. - assertFalse(featureSet.addIData(sameData1)); - // Check the contents. - assertTrue(featureSet.getData().isEmpty()); - - // Add some more data. - assertFalse(featureSet.addIData(sameData2)); - // Check the contents. - assertTrue(featureSet.getData().isEmpty()); - - // Try adding the same data again. - assertFalse(featureSet.addIData(sameData1)); - // Check the contents. - assertTrue(featureSet.getData().isEmpty()); - - // Add some data for a different feature. - assertFalse(featureSet.addIData(diffData)); - // Check the contents. - assertTrue(featureSet.getData().isEmpty()); - - // Try adding a null IData. - assertFalse(featureSet.addIData(null)); - // Check the contents. - assertTrue(featureSet.getData().isEmpty()); - - // Try adding a new SFRData based off the FeatureSet's name. - sameData1 = new SFRData(featureSet.getName()); - assertFalse(featureSet.addIData(sameData1)); - // Check the contents. - assertTrue(featureSet.getData().isEmpty()); - - // We shouldn't be able to add data to it manually. - dataList = featureSet.getData(); - dataList.add(sameData1); - // Check the contents. - assertTrue(featureSet.getData().isEmpty()); - /* ------------------------------------------------- */ - - return; - } - - /** - *

- * Tests the equality and hashCode operations. - *

- */ - @Test - public void checkEquality() { - - // Feature names to use. - String feature = "Deep Thought"; - String equalFeature = " Deep Thought "; - String unequalFeature = "Answer to the Ultimate Question of Life, the Universe, and Everything"; - - // FeatureSets to test. - FeatureSet object = new FeatureSet(feature); - FeatureSet equalObject = new FeatureSet(equalFeature); - FeatureSet unequalObject = new FeatureSet(unequalFeature); - FeatureSet invalidObject = new FeatureSet(null); - FeatureSet invalidObject2 = new FeatureSet(null); - - // Populate the data Lists with some IData. - SFRData iData; - for (int i = 0; i < 10; i++) { - // Data added to the featureSet and invalidFeatureSet. - iData = new SFRData(feature); - iData.setValue((double) i); - iData.setUncertainty(i / 10.0); - object.addIData(iData); - invalidObject.addIData(iData); - - // Data added to the equalFeatureSet. - iData = new SFRData(equalFeature); - iData.setValue((double) i); - iData.setUncertainty(i / 10.0); - equalObject.addIData(iData); - - // Data added to the unequalFeatureSet. - iData = new SFRData(unequalFeature); - iData.setValue((double) i); - iData.setUncertainty(i / 10.0); - unequalObject.addIData(iData); - } - - // Test reflexivity and symmetry. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Test hash code equality. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - - // Test inequality. - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Test hash code inequality. - assertFalse(object.hashCode() == unequalObject.hashCode()); - - // Test inequality with invalid objects. - assertFalse(object.equals(invalidObject)); - assertFalse(invalidObject.equals(object)); - - // Two invalid objects should be equal! - assertTrue(invalidObject.equals(invalidObject)); - assertTrue(invalidObject.equals(invalidObject2)); - assertTrue(invalidObject2.equals(invalidObject)); - - // Test inequality with null values - assertFalse(object==null); - assertFalse(equalObject==null); - assertFalse(unequalObject==null); - assertFalse(invalidObject==null); - - // Test inequality with invalid values. - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - - return; - } - - /** - *

- * Tests the copying and cloning operations. - *

- */ - @Test - public void checkCopying() { - - // Some feature names. - String feature = "Blart Versenwald III"; - String otherFeature = "Not Blart Versenwald III"; - - // Some objects to test copying/cloning. - FeatureSet object = new FeatureSet(feature); - FeatureSet copiedObject = new FeatureSet(otherFeature); - FeatureSet clonedObject = null; - - // A List to keep track of the original object's data. - ArrayList data = new ArrayList(); - - // Populate the data Lists with some IData. - SFRData iData; - for (int i = 0; i < 10; i++) { - // Data added to the featureSet and invalidFeatureSet. - iData = new SFRData(feature); - iData.setValue((double) i); - iData.setUncertainty(i / 10.0); - object.addIData(iData); - data.add(iData); - - // Data added to the unequalFeatureSet. - iData = new SFRData(otherFeature); - iData.setValue((double) i / 10.0); - iData.setUncertainty(i); - copiedObject.addIData(iData); - } - - /* ---- Test passing in bad arguments to copy. ---- */ - object.copy(null); - - // Make sure we didn't clobber the old contents of object. - assertTrue(object.getName().equals(feature)); - assertTrue(object.getData().equals(data)); - /* ------------------------------------------------ */ - - /* ---- Test copying. ---- */ - // Make sure these are different objects beforehand! - assertFalse(object == copiedObject); - assertFalse(object.equals(copiedObject)); - - // Copy the contents of object into copiedObject. - copiedObject.copy(object); - - // Make sure they are still different references but have the same info. - assertFalse(object == copiedObject); - assertTrue(object.equals(copiedObject)); - - // Make sure we didn't clobber the old contents of object. - assertTrue(object.getName().equals(feature)); - assertTrue(object.getData().equals(data)); - /* ----------------------- */ - - /* ---- Test cloning. ---- */ - // Make sure these are different objects beforehand! - assertFalse(object.equals(clonedObject)); - - // Clone the object. - clonedObject = (FeatureSet) object.clone(); - - // Make sure they are still different references but have the same info. - assertFalse(object == clonedObject); - assertTrue(object.equals(clonedObject)); - assertFalse(copiedObject == clonedObject); - assertTrue(copiedObject.equals(clonedObject)); - - // Make sure we didn't clobber the old contents of object. - assertTrue(object.getName().equals(feature)); - assertTrue(object.getData().equals(data)); - /* ----------------------- */ - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/GridDataManagerTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/GridDataManagerTester.java deleted file mode 100644 index fe65b0061..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/GridDataManagerTester.java +++ /dev/null @@ -1,526 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.eclipse.ice.reactor.sfr.base.GridDataManager; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.base.SFRData; -import org.junit.Test; - -public class GridDataManagerTester { - - @Test - public void checkConstruction() { - - // Some size values. - int defaultSize = Integer.MAX_VALUE; - int size = 42; - int location; - - // A manager to test and a component for adding. - GridDataManager manager; - String name = "Sir Digby Chicken Caesar"; - - SFRComponent defaultProvider = new SFRComponent(); - - /* ---- Test the manager with a valid size. ---- */ - // Initialize the manager. - manager = new GridDataManager(size); - - // Test the lower bound on the list of positions. - for (location = -10; location < 0; location++) { - assertFalse(manager.addComponent(name, location)); - assertNull(manager.getComponentName(location)); - assertTrue(manager.getComponentLocations(name).isEmpty()); - assertNull(manager.getDataProvider(location)); - } - - // Test the possible positions. - for (location = 0; location < size; location++) { - assertNull(manager.getDataProvider(location)); - assertTrue(manager.addComponent(name, location)); - assertEquals(name, manager.getComponentName(location)); - assertEquals(location + 1, manager.getComponentLocations(name) - .size()); - assertEquals(defaultProvider, manager.getDataProvider(location)); - } - - // Test the upper bound on the list of positions. - for (location = size; location < size + 10; location++) { - assertFalse(manager.addComponent(name, location)); - assertNull(manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(name).size()); - assertNull(manager.getDataProvider(location)); - } - /* --------------------------------------------- */ - - /* ---- Test the manager with an invalid size. ---- */ - // Initialize the manager. - manager = new GridDataManager(0); - - // Test the lower bound on the list of positions. - for (location = -10; location < 0; location++) { - assertFalse(manager.addComponent(name, location)); - assertNull(manager.getComponentName(location)); - assertTrue(manager.getComponentLocations(name).isEmpty()); - assertNull(manager.getDataProvider(location)); - } - - // Test the possible positions. - for (location = 0; location < size + 10; location++) { - assertNull(manager.getDataProvider(location)); - assertTrue(manager.addComponent(name, location)); - assertEquals(name, manager.getComponentName(location)); - assertEquals(location + 1, manager.getComponentLocations(name) - .size()); - assertEquals(defaultProvider, manager.getDataProvider(location)); - } - - // We should not be able to add anything to the largest location. - location = defaultSize; - size = manager.getComponentLocations(name).size(); - - assertFalse(manager.addComponent(name, location)); - assertNull(manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(name).size()); - assertNull(manager.getDataProvider(location)); - - // We should be able to add to the next largest location, though. - location--; - size++; - - assertTrue(manager.addComponent(name, location)); - assertEquals(name, manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(name).size()); - assertEquals(defaultProvider, manager.getDataProvider(location)); - /* --------------------------------------------- */ - - return; - } - - @Test - public void checkComponentAddRem() { - - // Some size values. - int size = 42; - int location; - - // A GridDataManager to test. - GridDataManager manager = new GridDataManager(size); - - // Some components to test adding/removing. - String component1 = "Arthur"; - String component2 = "Ford Prefect"; - String component3 = "Marvin"; - - SFRData data1 = new SFRData("one"); - SFRData data2 = new SFRData("two"); - SFRData data3 = new SFRData("three"); - SFRComponent provider = new SFRComponent(); - provider.addData(data1, 0.0); - provider.addData(data1, 1.0); - provider.addData(data2, 0.0); - provider.addData(data3, 0.0); - SFRComponent defaultProvider = new SFRComponent(); - - SFRComponent managedProvider; - - List locations; - - /* ---- Test adding a Component. ---- */ - // Test the lower bound on the list of positions. - for (location = -10; location < 0; location++) { - assertFalse(manager.addComponent(component1, location)); - assertNull(manager.getComponentName(location)); - assertTrue(manager.getComponentLocations(component1).isEmpty()); - assertNull(manager.getDataProvider(location)); - } - - // Test the possible positions. - for (location = 0; location < size; location++) { - assertNull(manager.getDataProvider(location)); - assertTrue(manager.addComponent(component1, location)); - assertEquals(component1, manager.getComponentName(location)); - assertEquals(location + 1, manager - .getComponentLocations(component1).size()); - - managedProvider = manager.getDataProvider(location); - assertEquals(defaultProvider, managedProvider); - managedProvider.addData(data1, 0.0); - managedProvider.addData(data1, 1.0); - managedProvider.addData(data2, 0.0); - managedProvider.addData(data3, 0.0); - assertEquals(provider, managedProvider); - } - - // Test the upper bound on the list of positions. - for (location = size; location < size + 10; location++) { - assertFalse(manager.addComponent(component1, location)); - assertNull(manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(component1).size()); - assertNull(manager.getDataProvider(location)); - } - - // Check the contents of the List of locations. - locations = manager.getComponentLocations(component1); - for (location = 0; location < size; location++) { - locations.contains(location); - } - /* ---------------------------------- */ - - /* ---- Test adding the same Component to the same location. ---- */ - location = 15; - - assertFalse(manager.addComponent(component1, location)); - - // Nothing should change! - assertEquals(component1, manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(component1).size()); - assertTrue(manager.getComponentLocations(component1).contains(location)); - - managedProvider = manager.getDataProvider(location); - assertEquals(provider, managedProvider); - /* -------------------------------------------------------------- */ - - /* ---- Test removing a Component. ---- */ - // Test the lower bound on the list of positions. - for (location = -10; location < 0; location++) { - assertFalse(manager.removeComponent(location)); - assertEquals(size, manager.getComponentLocations(component1).size()); - } - - // Test the upper bound on the list of positions. - for (location = size; location < size + 10; location++) { - assertFalse(manager.removeComponent(location)); - assertEquals(size, manager.getComponentLocations(component1).size()); - } - - // Try removing some from the inside. - int newSize = size; - for (location = 10; location < 20; location++) { - assertTrue(manager.removeComponent(location)); - - // Make sure there is no data provider anymore. - assertNull(manager.getDataProvider(location)); - - // Make sure there is no Component there. - assertNull(manager.getComponentName(location)); - - // Make sure the List of locations for that Component was updated. - locations = manager.getComponentLocations(component1); - assertEquals(--newSize, locations.size()); - assertFalse(locations.contains(location)); - } - - // Try removing the Component entirely. - assertTrue(manager.removeComponent(component1)); - - // Try removing the Component entirely again. - assertFalse(manager.removeComponent(component1)); - - // Make sure no location has that Component. - for (location = 0; location < size; location++) { - assertFalse(component1.equals(manager.getComponentName(location))); - assertNull(manager.getDataProvider(location)); - } - - // Add the component a few times, and remove all of them manually. - assertTrue(manager.addComponent(component1, 0)); - assertTrue(manager.addComponent(component1, 1)); - assertTrue(manager.removeComponent(0)); - // Can't remove from an empty location! - assertFalse(manager.removeComponent(0)); - assertTrue(manager.removeComponent(1)); - // Can't remove from an empty location! - assertFalse(manager.removeComponent(1)); - - // Try removing the component entirely. Since it's already been removed, - // it should return false. - assertFalse(manager.removeComponent(component1)); - - // Make sure no location has that Component. - for (location = 0; location < size; location++) { - assertFalse(component1.equals(manager.getComponentName(location))); - } - - // Make sure the Component has no listed locations. - assertTrue(manager.getComponentLocations(component1).isEmpty()); - /* ------------------------------------ */ - - /* ---- Test overwriting a location. ---- */ - - // Add component1 in a few locations. - for (location = 10; location < 20; location++) { - assertTrue(manager.addComponent(component1, location)); - - managedProvider = manager.getDataProvider(location); - assertEquals(defaultProvider, managedProvider); - managedProvider.addData(data1, 0.0); - managedProvider.addData(data1, 1.0); - managedProvider.addData(data2, 0.0); - managedProvider.addData(data3, 0.0); - } - - // Verify the addition of component1. - locations = manager.getComponentLocations(component1); - assertEquals(10, locations.size()); - for (location = 10; location < 20; location++) { - assertEquals(component1, manager.getComponentName(location)); - locations.contains(location); - - assertEquals(provider, manager.getDataProvider(location)); - } - - // Overwrite the the last half of those positions. - for (location = 15; location < 25; location++) { - assertTrue(manager.addComponent(component2, location)); - } - - // Verify the removal of component1. - locations = manager.getComponentLocations(component1); - assertEquals(5, locations.size()); - for (location = 10; location < 15; location++) { - assertEquals(component1, manager.getComponentName(location)); - locations.contains(location); - } - - // Verify the addition of component2. - locations = manager.getComponentLocations(component2); - assertEquals(10, locations.size()); - for (location = 15; location < 25; location++) { - assertEquals(component2, manager.getComponentName(location)); - locations.contains(location); - - assertEquals(defaultProvider, manager.getDataProvider(location)); - } - - // Overwrite the last half of those positions. - for (location = 20; location < 25; location++) { - assertTrue(manager.addComponent(component3, location)); - } - - // Verify that component1 was not touched. - locations = manager.getComponentLocations(component1); - assertEquals(5, locations.size()); - for (location = 10; location < 15; location++) { - assertEquals(component1, manager.getComponentName(location)); - locations.contains(location); - } - - // Verify the removal of component2. - locations = manager.getComponentLocations(component2); - assertEquals(5, locations.size()); - for (location = 15; location < 20; location++) { - assertEquals(component2, manager.getComponentName(location)); - locations.contains(location); - } - - // Verify the addition of component3. - locations = manager.getComponentLocations(component3); - assertEquals(5, locations.size()); - for (location = 20; location < 25; location++) { - assertEquals(component3, manager.getComponentName(location)); - locations.contains(location); - } - /* -------------------------------------- */ - - /* ---- Remove some more. ---- */ - // Make sure we know how many locations are in each Component's List. - assertEquals(5, manager.getComponentLocations(component1).size()); - assertEquals(5, manager.getComponentLocations(component2).size()); - assertEquals(5, manager.getComponentLocations(component3).size()); - - // Remove component2 manually. - for (location = 15; location < 20; location++) { - assertTrue(manager.removeComponent(location)); - } - - // Verify removal of component2. - assertEquals(5, manager.getComponentLocations(component1).size()); - assertTrue(manager.getComponentLocations(component2).isEmpty()); - assertEquals(5, manager.getComponentLocations(component3).size()); - for (location = 0; location < 10; location++) { - assertNull(manager.getComponentName(location)); - } - for (location = 10; location < 15; location++) { - assertEquals(component1, manager.getComponentName(location)); - } - for (location = 15; location < 20; location++) { - assertNull(manager.getComponentName(location)); - } - for (location = 20; location < 25; location++) { - assertEquals(component3, manager.getComponentName(location)); - } - for (location = 25; location < size; location++) { - assertNull(manager.getComponentName(location)); - } - - // Remove component3 at once. - assertTrue(manager.removeComponent(component3)); - assertEquals(5, manager.getComponentLocations(component1).size()); - assertTrue(manager.getComponentLocations(component2).isEmpty()); - assertTrue(manager.getComponentLocations(component3).isEmpty()); - for (location = 0; location < 10; location++) { - assertNull(manager.getComponentName(location)); - } - for (location = 10; location < 15; location++) { - assertEquals(component1, manager.getComponentName(location)); - } - for (location = 15; location < size; location++) { - assertNull(manager.getComponentName(location)); - } - - // Remove component1. - assertTrue(manager.removeComponent(component1)); - assertTrue(manager.getComponentLocations(component1).isEmpty()); - assertTrue(manager.getComponentLocations(component2).isEmpty()); - assertTrue(manager.getComponentLocations(component3).isEmpty()); - for (location = 0; location < size; location++) { - assertNull(manager.getComponentName(location)); - } - /* --------------------------- */ - - return; - } - - /** - *

- * Tests the equality and hashCode operations. - *

- */ - @Test - public void checkEquality() { - - int size = 257; - - // Initialize objects for testing. - GridDataManager object = new GridDataManager(size); - GridDataManager equalObject = new GridDataManager(size); - GridDataManager unequalObject = new GridDataManager(size); - - // Set up the object and equalObject. - String component = "Marvin"; - SFRData data = new SFRData("Fictional character"); - data.setValue(42.0); - - object.addComponent("Ford", 50); - object.addComponent("Zaphod", 3); - object.addComponent(component, 84); - object.addComponent(component, 37); - object.getDataProvider(3).addData(data, 0.0); - object.getDataProvider(37).addData(data, 0.0); - - equalObject.addComponent("Ford", 50); - equalObject.addComponent("Zaphod", 3); - equalObject.addComponent(component, 84); - equalObject.addComponent(component, 37); - equalObject.getDataProvider(3).addData(data, 0.0); - equalObject.getDataProvider(37).addData(data, 0.0); - - // Set up the unequalObject. - unequalObject.addComponent("Ford", 50); - unequalObject.addComponent("Zaphod", 3); - unequalObject.addComponent(component, 84); - unequalObject.addComponent(component, 37); - unequalObject.getDataProvider(3).addData(data, 0.0); - unequalObject.getDataProvider(50).addData(data, 0.0); // Different! - - // Make sure the references are different. - assertFalse(object == equalObject); - assertFalse(object == unequalObject); - assertFalse(equalObject == unequalObject); - - // Check that equality is reflexive and symmetric. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Check that equals will fail when it should. - assertFalse(object==null); - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Check the hash codes. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - assertFalse(object.hashCode() == unequalObject.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations. - *

- */ - @Test - public void checkCopying() { - - int size = 720; - - // Initialize objects for testing. - GridDataManager object = new GridDataManager(size); - GridDataManager copy = new GridDataManager(size); - GridDataManager clone = null; - - // Set up the object. - String component = "Marvin"; - SFRData data = new SFRData("Fictional character"); - data.setValue(42.0); - - object.addComponent("Ford", 50); - object.addComponent("Zaphod", 3); - object.addComponent(component, 84); - object.addComponent(component, 37); - object.getDataProvider(84).addData(data, 1.0); - object.getDataProvider(37).addData(data, 1.0); - object.getDataProvider(37).addData(data, 0.0); - - // Make sure the objects are not equal before copying. - assertFalse(object == copy); - assertFalse(object.equals(copy)); - - // Copy the object. - copy.copy(object); - - // Make sure the references are different but contents the same. - assertFalse(object == copy); - assertTrue(object.equals(copy)); - - // Do the same for the clone operation. - - // Make sure the objects are not equal before copying. - assertFalse(object == clone); - assertFalse(object.equals(clone)); - - // Copy the object. - clone = (GridDataManager) object.clone(); - - // Make sure the references are different but contents the same. - assertFalse(object == clone); - assertTrue(object.equals(clone)); - assertFalse(copy == clone); - assertTrue(copy.equals(clone)); - - return; - } -} diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/GridManagerTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/GridManagerTester.java deleted file mode 100644 index 694a9f932..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/GridManagerTester.java +++ /dev/null @@ -1,459 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.eclipse.ice.reactor.sfr.base.GridManager; -import org.junit.Test; - -public class GridManagerTester { - - @Test - public void checkConstruction() { - - // Some size values. - int defaultSize = Integer.MAX_VALUE; - int size = 42; - int location; - - // A manager to test and a component for adding. - GridManager manager; - String name = "Sir Digby Chicken Caesar"; - - /* ---- Test the manager with a valid size. ---- */ - // Initialize the manager. - manager = new GridManager(size); - - // Test the lower bound on the list of positions. - for (location = -10; location < 0; location++) { - assertFalse(manager.addComponent(name, location)); - assertNull(manager.getComponentName(location)); - assertTrue(manager.getComponentLocations(name).isEmpty()); - } - - // Test the possible positions. - for (location = 0; location < size; location++) { - assertTrue(manager.addComponent(name, location)); - assertEquals(name, manager.getComponentName(location)); - assertEquals(location + 1, manager.getComponentLocations(name) - .size()); - } - - // Test the upper bound on the list of positions. - for (location = size; location < size + 10; location++) { - assertFalse(manager.addComponent(name, location)); - assertNull(manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(name).size()); - } - /* --------------------------------------------- */ - - /* ---- Test the manager with an invalid size. ---- */ - // Initialize the manager. - manager = new GridManager(0); - - // Test the lower bound on the list of positions. - for (location = -10; location < 0; location++) { - assertFalse(manager.addComponent(name, location)); - assertNull(manager.getComponentName(location)); - assertTrue(manager.getComponentLocations(name).isEmpty()); - } - - // Test the possible positions. - for (location = 0; location < size + 10; location++) { - assertTrue(manager.addComponent(name, location)); - assertEquals(name, manager.getComponentName(location)); - assertEquals(location + 1, manager.getComponentLocations(name) - .size()); - } - - // We should not be able to add anything to the largest location. - location = defaultSize; - size = manager.getComponentLocations(name).size(); - - assertFalse(manager.addComponent(name, location)); - assertNull(manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(name).size()); - - // We should be able to add to the next largest location, though. - location--; - size++; - - assertTrue(manager.addComponent(name, location)); - assertEquals(name, manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(name).size()); - /* --------------------------------------------- */ - - return; - } - - @Test - public void checkComponentAddRem() { - - // Some size values. - int size = 42; - int location; - - // A GridManager to test. - GridManager manager = new GridManager(size); - - // Some components to test adding/removing. - String component1 = "Arthur"; - String component2 = "Ford Prefect"; - String component3 = "Marvin"; - - List locations; - - /* ---- Test adding a Component. ---- */ - // Test the lower bound on the list of positions. - for (location = -10; location < 0; location++) { - assertFalse(manager.addComponent(component1, location)); - assertNull(manager.getComponentName(location)); - assertTrue(manager.getComponentLocations(component1).isEmpty()); - } - - // Test the possible positions. - for (location = 0; location < size; location++) { - assertTrue(manager.addComponent(component1, location)); - assertEquals(component1, manager.getComponentName(location)); - assertEquals(location + 1, manager - .getComponentLocations(component1).size()); - } - - // Test the upper bound on the list of positions. - for (location = size; location < size + 10; location++) { - assertFalse(manager.addComponent(component1, location)); - assertNull(manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(component1).size()); - } - - // Check the contents of the List of locations. - locations = manager.getComponentLocations(component1); - for (location = 0; location < size; location++) { - locations.contains(location); - } - /* ---------------------------------- */ - - /* ---- Test adding the same Component to the same location. ---- */ - location = 15; - - assertFalse(manager.addComponent(component1, location)); - - // Nothing should change! - assertEquals(component1, manager.getComponentName(location)); - assertEquals(size, manager.getComponentLocations(component1).size()); - assertTrue(manager.getComponentLocations(component1).contains(location)); - /* -------------------------------------------------------------- */ - - /* ---- Test removing a Component. ---- */ - // Test the lower bound on the list of positions. - for (location = -10; location < 0; location++) { - assertFalse(manager.removeComponent(location)); - assertEquals(size, manager.getComponentLocations(component1).size()); - } - - // Test the upper bound on the list of positions. - for (location = size; location < size + 10; location++) { - assertFalse(manager.removeComponent(location)); - assertEquals(size, manager.getComponentLocations(component1).size()); - } - - // Try removing some from the inside. - int newSize = size; - for (location = 10; location < 20; location++) { - assertTrue(manager.removeComponent(location)); - - // Make sure there is no Component there. - assertNull(manager.getComponentName(location)); - - // Make sure the List of locations for that Component was updated. - locations = manager.getComponentLocations(component1); - assertEquals(--newSize, locations.size()); - assertFalse(locations.contains(location)); - } - - // Try removing the Component entirely. - assertTrue(manager.removeComponent(component1)); - - // Try removing the Component entirely again. - assertFalse(manager.removeComponent(component1)); - - // Make sure no location has that Component. - for (location = 0; location < size; location++) { - assertFalse(component1.equals(manager.getComponentName(location))); - } - - // Add the component a few times, and remove all of them manually. - assertTrue(manager.addComponent(component1, 0)); - assertTrue(manager.addComponent(component1, 1)); - assertTrue(manager.removeComponent(0)); - // Can't remove from an empty location! - assertFalse(manager.removeComponent(0)); - assertTrue(manager.removeComponent(1)); - // Can't remove from an empty location! - assertFalse(manager.removeComponent(1)); - - // Try removing the component entirely. Since it's already been removed, - // it should return false. - assertFalse(manager.removeComponent(component1)); - - // Make sure no location has that Component. - for (location = 0; location < size; location++) { - assertFalse(component1.equals(manager.getComponentName(location))); - } - - // Make sure the Component has no listed locations. - assertTrue(manager.getComponentLocations(component1).isEmpty()); - /* ------------------------------------ */ - - /* ---- Test overwriting a location. ---- */ - - // Add component1 in a few locations. - for (location = 10; location < 20; location++) { - assertTrue(manager.addComponent(component1, location)); - } - - // Verify the addition of component1. - locations = manager.getComponentLocations(component1); - assertEquals(10, locations.size()); - for (location = 10; location < 20; location++) { - assertEquals(component1, manager.getComponentName(location)); - locations.contains(location); - } - - // Overwrite the the last half of those positions. - for (location = 15; location < 25; location++) { - assertTrue(manager.addComponent(component2, location)); - } - - // Verify the removal of component1. - locations = manager.getComponentLocations(component1); - assertEquals(5, locations.size()); - for (location = 10; location < 15; location++) { - assertEquals(component1, manager.getComponentName(location)); - locations.contains(location); - } - - // Verify the addition of component2. - locations = manager.getComponentLocations(component2); - assertEquals(10, locations.size()); - for (location = 15; location < 25; location++) { - assertEquals(component2, manager.getComponentName(location)); - locations.contains(location); - } - - // Overwrite the last half of those positions. - for (location = 20; location < 25; location++) { - assertTrue(manager.addComponent(component3, location)); - } - - // Verify that component1 was not touched. - locations = manager.getComponentLocations(component1); - assertEquals(5, locations.size()); - for (location = 10; location < 15; location++) { - assertEquals(component1, manager.getComponentName(location)); - locations.contains(location); - } - - // Verify the removal of component2. - locations = manager.getComponentLocations(component2); - assertEquals(5, locations.size()); - for (location = 15; location < 20; location++) { - assertEquals(component2, manager.getComponentName(location)); - locations.contains(location); - } - - // Verify the addition of component3. - locations = manager.getComponentLocations(component3); - assertEquals(5, locations.size()); - for (location = 20; location < 25; location++) { - assertEquals(component3, manager.getComponentName(location)); - locations.contains(location); - } - /* -------------------------------------- */ - - /* ---- Remove some more. ---- */ - // Make sure we know how many locations are in each Component's List. - assertEquals(5, manager.getComponentLocations(component1).size()); - assertEquals(5, manager.getComponentLocations(component2).size()); - assertEquals(5, manager.getComponentLocations(component3).size()); - - // Remove component2 manually. - for (location = 15; location < 20; location++) { - assertTrue(manager.removeComponent(location)); - } - - // Verify removal of component2. - assertEquals(5, manager.getComponentLocations(component1).size()); - assertTrue(manager.getComponentLocations(component2).isEmpty()); - assertEquals(5, manager.getComponentLocations(component3).size()); - for (location = 0; location < 10; location++) { - assertNull(manager.getComponentName(location)); - } - for (location = 10; location < 15; location++) { - assertEquals(component1, manager.getComponentName(location)); - } - for (location = 15; location < 20; location++) { - assertNull(manager.getComponentName(location)); - } - for (location = 20; location < 25; location++) { - assertEquals(component3, manager.getComponentName(location)); - } - for (location = 25; location < size; location++) { - assertNull(manager.getComponentName(location)); - } - - // Remove component3 at once. - assertTrue(manager.removeComponent(component3)); - assertEquals(5, manager.getComponentLocations(component1).size()); - assertTrue(manager.getComponentLocations(component2).isEmpty()); - assertTrue(manager.getComponentLocations(component3).isEmpty()); - for (location = 0; location < 10; location++) { - assertNull(manager.getComponentName(location)); - } - for (location = 10; location < 15; location++) { - assertEquals(component1, manager.getComponentName(location)); - } - for (location = 15; location < size; location++) { - assertNull(manager.getComponentName(location)); - } - - // Remove component1. - assertTrue(manager.removeComponent(component1)); - assertTrue(manager.getComponentLocations(component1).isEmpty()); - assertTrue(manager.getComponentLocations(component2).isEmpty()); - assertTrue(manager.getComponentLocations(component3).isEmpty()); - for (location = 0; location < size; location++) { - assertNull(manager.getComponentName(location)); - } - /* --------------------------- */ - - return; - } - - /** - *

- * Tests the equality and hashCode operations. - *

- */ - @Test - public void checkEquality() { - - int size = 257; - - // Initialize objects for testing. - GridManager object = new GridManager(size); - GridManager equalObject = new GridManager(size); - GridManager unequalObject = new GridManager(size); - - // Set up the object and equalObject. - String component = "Marvin"; - - object.addComponent("Ford", 50); - object.addComponent("Zaphod", 3); - object.addComponent(component, 84); - object.addComponent(component, 37); - - equalObject.addComponent("Ford", 50); - equalObject.addComponent("Zaphod", 3); - equalObject.addComponent(component, 84); - equalObject.addComponent(component, 37); - - // Set up the unequalObject. - unequalObject.addComponent("Ford", 50); - unequalObject.addComponent("Zaphod", 3); - unequalObject.addComponent(component, 84); - unequalObject.addComponent(component, 36); // Different! - - // Make sure the references are different. - assertFalse(object == equalObject); - assertFalse(object == unequalObject); - assertFalse(equalObject == unequalObject); - - // Check that equality is reflexive and symmetric. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Check that equals will fail when it should. - assertFalse(object==null); - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Check the hash codes. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - assertFalse(object.hashCode() == unequalObject.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations. - *

- */ - @Test - public void checkCopying() { - - int size = 720; - - // Initialize objects for testing. - GridManager object = new GridManager(size); - GridManager copy = new GridManager(size); - GridManager clone = null; - - // Set up the object. - String component = "Marvin"; - - object.addComponent("Ford", 50); - object.addComponent("Zaphod", 3); - object.addComponent(component, 84); - object.addComponent(component, 37); - - // Make sure the objects are not equal before copying. - assertFalse(object == copy); - assertFalse(object.equals(copy)); - - // Copy the object. - copy.copy(object); - - // Make sure the references are different but contents the same. - assertFalse(object == copy); - assertTrue(object.equals(copy)); - - // Do the same for the clone operation. - - // Make sure the objects are not equal before copying. - assertFalse(object == clone); - assertFalse(object.equals(clone)); - - // Copy the object. - clone = (GridManager) object.clone(); - - // Make sure the references are different but contents the same. - assertFalse(object == clone); - assertTrue(object.equals(clone)); - assertFalse(copy == clone); - assertTrue(copy.equals(clone)); - - return; - } -} diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/MaterialBlockTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/MaterialBlockTester.java deleted file mode 100644 index 0bb423c09..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/MaterialBlockTester.java +++ /dev/null @@ -1,406 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.ice.reactor.sfr.core.MaterialBlock; -import org.eclipse.ice.reactor.sfr.core.assembly.Ring; -import org.junit.Test; - -/** - *

- * Tests the operations of the MaterialBlock class. - *

- * - * @author Anna Wojtowicz - */ -public class MaterialBlockTester { - /** - *

- * Tests the constructors and default values for the MaterialBlock class. - *

- * - */ - @Test - public void checkConstruction() { - - // Create new MaterialBlock for testing - MaterialBlock block = new MaterialBlock(); - - // Test nullary constructor default values - assertEquals("MaterialBlock 1", block.getName()); - assertEquals("MaterialBlock 1 Description", block.getDescription()); - assertEquals(1, block.getId()); - assertEquals(0.0, block.getVertPosition(), 0.0); - - } - - /** - *

- * Tests the getter and setter for the vertPosition attribute. - *

- * - */ - @Test - public void checkVertPosition() { - - // Initialize new material block - MaterialBlock block = new MaterialBlock(); - - // Try setting z-displacement to illegal value, should remain unchanged - block.setVertPosition(-1.0); - assertEquals(0, block.getVertPosition(), 0.0); - - // Try changing z-displacement to a legal non-zero value - block.setVertPosition(42.0); - assertEquals(42.0, block.getVertPosition(), 0.0); - - } - - /** - *

- * Tests the getters of rings in the MaterialBlock. - *

- * - */ - @Test - public void checkRing() { - - // Initialize a material block for testing - MaterialBlock block = new MaterialBlock(); - - // Initialize rings for testing - Ring ringOne = new Ring(); - Ring ringTwo = new Ring(); - - // Set the name, inner radius, and outer radius of a ring - ringOne.setName("Slartibartfast"); - ringOne.setInnerRadius(10.5); - ringOne.setOuterRadius(12.5); - - // Set the name, inner radius and outer radius of another ring - ringTwo.setName("Bartislartfast"); - ringTwo.setInnerRadius(12.6); - ringTwo.setOuterRadius(13.25); - - // Add the rings to the material block, make sure they added - assertTrue(block.addRing(ringOne)); - assertTrue(block.addRing(ringTwo)); - - // Try to add ringOne again, should not take - assertFalse(block.addRing(ringOne)); - - /* --- Test getting rings from a material block by name ------------ */ - - // Try getting a ring by a valid name - assertEquals(ringOne, block.getRing("Slartibartfast")); - - // Try getting a ring by a name that doesn't exist - assertNull(block.getRing("Bob")); - - // Try getting a ring with a null name - assertNull(block.getRing(null)); - - /* --- Test getting rings from a material block by radius ----------- */ - - // Try getting a ring by a valid inner radius - assertEquals(ringOne, block.getRing(10.5)); - assertEquals(ringTwo, block.getRing(12.6)); - - // Try getting a ring by a valid outer radius - assertEquals(ringOne, block.getRing(12.5)); - assertEquals(ringTwo, block.getRing(13.25)); - - // Try getting a ring by a radius that does not exist - assertNull(block.getRing(9000)); - - // Try getting a ring by a null radius - assertNull(block.getRing(null)); - - /* --- Test getting the list of rings in a material block ---------- */ - - // Check the list of rings contained in block - assertEquals(2, block.getRings().size()); - assertEquals(ringOne, block.getRings().get(0)); - assertEquals(ringTwo, block.getRings().get(1)); - - } - - /** - *

- * Tests the addition and removal of Rings in the MaterialBlock. - *

- * - */ - @Test - public void checkRingAddRem() { - - // Initialize a material block for testing - MaterialBlock block = new MaterialBlock(); - - // Initialize rings for testing - Ring ringOne = new Ring(); - Ring ringTwo = new Ring(); - - // Set ringOne to be inside ringTwo without overlap - ringOne.setInnerRadius(3.2); - ringOne.setOuterRadius(3.7); - ringTwo.setInnerRadius(3.99); - ringTwo.setOuterRadius(4.0); - - // Initialize a boolean flags for addition/removal of rings - boolean ringAdded = false; - boolean ringRemoved = false; - - // Set the name of a ring - ringOne.setName("Agrajag"); - - /* --- Test the addition of rings to a material block -------------- */ - - // Add ringOne to block and check if ringAdded flagged as true - ringAdded = block.addRing(ringOne); - assertTrue(ringAdded); - - // Try to add a null ring from block, ringAdded becomes false - ringAdded = block.addRing(null); - assertFalse(ringAdded); - - // Set the name, description of another ring - ringTwo.setName("Pot of petunias"); - - // Add ringTwo to block and check if ringAdded flagged as true - ringAdded = block.addRing(ringTwo); - assertTrue(ringAdded); - - /* --- Test the removal of rings from a material block ------------- */ - - // Remove ringOne from block and check if ringRemoved flagged - ringRemoved = block.removeRing("Agrajag"); - assertTrue(ringRemoved); - - // Try to remove a null ring from block, ringRemoved becomes false - ringRemoved = block.removeRing(null); - assertFalse(ringRemoved); - - // Remove ringTwo from block and check if ringRemoved flagged - ringRemoved = block.removeRing("Pot of petunias"); - assertTrue(ringRemoved); - } - - /** - *

- * Tests the equality operation of MaterialBlocks. - *

- */ - @Test - public void checkEquality() { - - /* --- Check equality between like material blocks ----------------- */ - - // Construct a material block to test against - MaterialBlock block = new MaterialBlock(); - block.setName("Infinite Improbability Drive"); - block.setDescription("Probably Improbable"); - block.setId(30); - block.setVertPosition(19.62); - - // Create rings to add to the material block - Ring ringOne = new Ring(); - Ring ringTwo = new Ring(); - ringOne.setInnerRadius(3.4); - ringOne.setOuterRadius(3.785); - ringTwo.setInnerRadius(5.21); - ringTwo.setOuterRadius(7.99); - - // Add the rings to the the material block - block.addRing(ringOne); - block.addRing(ringTwo); - - // Construct a material block equal to the first - MaterialBlock equalBlock = new MaterialBlock(); - equalBlock.setName("Infinite Improbability Drive"); - equalBlock.setDescription("Probably Improbable"); - equalBlock.setId(30); - equalBlock.setVertPosition(19.62); - - // Create rings identical to the previous ones - Ring ringOneCopy = new Ring(); - Ring ringTwoCopy = new Ring(); - ringOneCopy.setInnerRadius(3.4); - ringOneCopy.setOuterRadius(3.785); - ringTwoCopy.setInnerRadius(5.21); - ringTwoCopy.setOuterRadius(7.99); - - // Add the rings to the the equal material block - equalBlock.addRing(ringOneCopy); - equalBlock.addRing(ringTwoCopy); - - // Check that equals() is reflexive and symmetric - assertTrue(block.equals(block)); - assertTrue(block.equals(equalBlock) && equalBlock.equals(block)); - - // Check equals() fails with illegal material blocks - assertFalse(block==null); - - /* --- Check transitivity with similar material blocks ------------- */ - - // Construct another material block equal to the first, for testing - // transitivity - MaterialBlock transBlock = new MaterialBlock(); - transBlock.setName("Infinite Improbability Drive"); - transBlock.setDescription("Probably Improbable"); - transBlock.setId(30); - transBlock.setVertPosition(19.62); - - // Create another set of rings identical to the first ones - Ring ringOneCopy2 = new Ring(); - Ring ringTwoCopy2 = new Ring(); - ringOneCopy2.setInnerRadius(3.4); - ringOneCopy2.setOuterRadius(3.785); - ringTwoCopy2.setInnerRadius(5.21); - ringTwoCopy2.setOuterRadius(7.99); - - // Add the rings to the transitive material block - transBlock.addRing(ringOneCopy2); - transBlock.addRing(ringTwoCopy2); - - // Check for transitivity - if (block.equals(transBlock) && transBlock.equals(equalBlock)) { - assertTrue(block.equals(equalBlock)); - } else { - fail(); - } - - /* --- Check inequality between two dissimilar material blocks ----- */ - - // Construct a material block unequal to the first one - MaterialBlock unequalBlock = new MaterialBlock(); - unequalBlock.setName("Finite Probability Drive"); - unequalBlock.setDescription("Improbably Probable"); - unequalBlock.setId(31); - unequalBlock.setVertPosition(18.424242); - - // Create rings not identical to the first - Ring ringThree = new Ring(); - Ring ringFour = new Ring(); - ringThree.setInnerRadius(17.0); - ringThree.setOuterRadius(54.33); - ringFour.setInnerRadius(55.0); - ringFour.setOuterRadius(55.01); - - // Add the rings to the unequal material block - unequalBlock.addRing(ringThree); - unequalBlock.addRing(ringFour); - - // Check that block and unequalBlock are not the same - assertFalse(block.equals(unequalBlock)); - - /* --- Check hash values between equal and unequal material blocks - */ - - assertEquals(block.hashCode(), block.hashCode()); - assertEquals(block.hashCode(), equalBlock.hashCode()); - assertFalse(block.hashCode() == unequalBlock.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations of MaterialBlocks. - *

- */ - @Test - public void checkCopying() { - - /* --- Testing the copy operation ---------------------------------- */ - - // Create a material block to copy from - MaterialBlock block = new MaterialBlock(); - block.setName("Prosteetnic Vogon Jeltz"); - block.setDescription("Vogon ship captain"); - block.setId(7); - block.setVertPosition(42.4242); - - // Create a ring to add to the MaterialBlock - Ring ring = new Ring(); - ring.setInnerRadius(24); - ring.setOuterRadius(42); - - // Add the ring to the block's TreeSet - block.addRing(ring); - - // Create an empty material block to copy to - MaterialBlock blockCopy = new MaterialBlock(); - - // Copy the contents of block to blockCopy - blockCopy.copy(block); - - // Check block and blockCopy are identical - assertTrue(block.equals(blockCopy)); - - // Try copying the contents of a null material block - blockCopy.copy(null); - - // Check to see that blockCopy remains unchanged - assertTrue(blockCopy.equals(block)); - - /* --- Testing the cloning operation ------------------------------- */ - - // Clone the first material block - Object blockClone = block.clone(); - - // Check that blockClone isn't null - assertNotNull(blockClone); - - // Check that block and blockClone are identical - assertTrue(blockClone.equals(block)); - - return; - } - - /** - *

- * Tests the compareTo method of MaterialBlocks. - *

- */ - @Test - public void checkComparison() { - - // Create a material block for testing - MaterialBlock blockOne = new MaterialBlock(); - blockOne.setVertPosition(1.007); - - // Create a material block at a different vertical position (higher) - MaterialBlock blockTwo = new MaterialBlock(); - blockTwo.setVertPosition(1.34); - - // Check that blockOne is below blockTwo (and vice versa) - assertEquals(-1, blockOne.compareTo(blockTwo)); - assertEquals(1, blockTwo.compareTo(blockOne)); - - // Create a third block that overlaps one of the others (blockOne - // chosen arbitrarily) - MaterialBlock blockThree = new MaterialBlock(); - blockThree.setVertPosition(1.007); - - // Check that blockOne and blockThree overlap - assertEquals(0, blockOne.compareTo(blockThree)); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/MaterialTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/MaterialTester.java deleted file mode 100644 index 013138eb2..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/MaterialTester.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.ice.reactor.sfr.core.Material; -import org.junit.Test; - -/** - *

- * Tests the operations of the Material class. - *

- * - * @author Anna Wojtowicz - */ -public class MaterialTester { - /** - *

- * Tests the constructors and default values of the Material class. - *

- * - */ - @Test - public void checkConstruction() { - - // Initialize a Material for testing with nullary constructor - Material materialOne = new Material(); - - // Check the default name, description and ID - assertEquals("Material 1", materialOne.getName()); - assertEquals("Material 1 Description", materialOne.getDescription()); - assertEquals(1, materialOne.getId()); - - // Initialize a Material for testing with parameterized constructor - Material materialTwo = new Material("Fjords"); - assertEquals("Fjords", materialTwo.getName()); - assertEquals("Material 1 Description", materialTwo.getDescription()); - assertEquals(1, materialTwo.getId()); - - - } - - /** - *

- * Tests the equality operation of Materials. - *

- */ - @Test - public void checkEquality() { - - /* --- Check equality between like materials ----------------------- */ - - // Construct a material to test against - Material material = new Material("Towel"); - material.setDescription("The most massively useful thing any interstellar Hitchhiker can carry"); - material.setId(42); - - // Construct a material equal to the first - Material equalMaterial = new Material("Towel"); - equalMaterial - .setDescription("The most massively useful thing any interstellar Hitchhiker can carry"); - equalMaterial.setId(42); - - // Check that equals() is reflexive and symmetric - assertTrue(material.equals(material)); - assertTrue(material.equals(equalMaterial) - && equalMaterial.equals(material)); - - // Check equals() fails with illegal rings - assertFalse(material==null); - - /* --- Check transitivity with similar materials ------------------- */ - - // Construct another material equal to the first, for testing - // transitivity - Material transMaterial = new Material("Towel"); - transMaterial - .setDescription("The most massively useful thing any interstellar Hitchhiker can carry"); - transMaterial.setId(42); - - // Check for transitivity - if (material.equals(transMaterial) - && transMaterial.equals(equalMaterial)) { - assertTrue(material.equals(equalMaterial)); - } else { - fail(); - } - - /* --- Check inequality between two dissimilar materials ----------- */ - - // Construct a material unequal to the first - Material unequalMaterial = new Material("Dish rag"); - unequalMaterial - .setDescription("Not terribly useful for interstellar travel"); - unequalMaterial.setId(24); - - // Check that material and unequalMaterial are not the same - assertFalse(material.equals(unequalMaterial)); - - /* --- Check hash values between equal and unequal materials ------- */ - - assertEquals(material.hashCode(), material.hashCode()); - assertEquals(material.hashCode(), equalMaterial.hashCode()); - assertFalse(material.hashCode() == unequalMaterial.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations of Materials. - *

- */ - @Test - public void checkCopying() { - - /* --- Testing the copy operation ---------------------------------- */ - - // Create a material to copy from - Material material = new Material("Small Lump of Green Putty"); - material.setDescription("Found in my armpit one midsummer morning"); - material.setId(5496); - - // Create an empty material to copy to - Material materialCopy = new Material(); - - // Copy the contents of material to materialCopy - materialCopy.copy(material); - - // Check material and materialCopy are identical - assertTrue(material.equals(materialCopy)); - - // Try copying the contents of a null material - materialCopy.copy(null); - - // Check to see that materialCopy remains unchanged - assertTrue(materialCopy.equals(material)); - - /* --- Testing the cloning operation ------------------------------- */ - - // Clone the first material - Object materialClone = material.clone(); - - // Check that materialClone isn't null - assertNotNull(materialClone); - - // Check that material and materialClone are identical - assertTrue(materialClone.equals(material)); - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/PinAssemblyTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/PinAssemblyTester.java deleted file mode 100644 index ec8bdcff2..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/PinAssemblyTester.java +++ /dev/null @@ -1,1100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.base.SFRComposite; -import org.eclipse.ice.reactor.sfr.base.SFRData; -import org.eclipse.ice.reactor.sfr.core.AssemblyType; -import org.eclipse.ice.reactor.sfr.core.assembly.PinAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.PinType; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRPin; -import org.junit.Test; - -/** - *

- * Tests the operations of the PinAssembly class. - *

- * - * @author Anna Wojtowicz - */ -public class PinAssemblyTester { - - /** - *

- * Tests the constructors and default values of the PinAssembly class. - *

- * - */ - @Test - public void checkConstruction() { - - // An assembly to test. - PinAssembly assembly; - - // Invalid, default, and valid values to use in the constructor. - int invalidSize = 0; - int defaultSize = 1; - int size = 31; - - String nullName = null; - String emptyName = " "; - String defaultName = "SFR Pin Assembly 1"; - String name = "Tricia"; - - PinType invalidPinType = null; - PinType defaultPinType = PinType.InnerFuel; - PinType pinType = PinType.BlanketFuel; - - // Other defaults. - AssemblyType defaultType = AssemblyType.Fuel; - String defaultDescription = "SFR Pin Assembly 1's Description"; - int defaultId = 1; - double defaultDuctThickness = 0.0; - double defaultPinPitch = 1.0; - double defaultInnerDuctFlatToFlat = 0.0; - double defaultInnerDuctThickness = 0.0; - - /* ---- Test the basic constructor. ---- */ - // Invalid parameters. - assembly = new PinAssembly(invalidSize); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultPinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - - // Valid parameters. - assembly = new PinAssembly(size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultPinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - /* ------------------------------------- */ - - /* ---- Test the second constructor. ---- */ - // Invalid parameters. - - // All invalid. - assembly = new PinAssembly(nullName, invalidPinType, invalidSize); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultPinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - - // Name invalid. - assembly = new PinAssembly(emptyName, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - - // Pin type invalid. - assembly = new PinAssembly(name, invalidPinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultPinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - - // Size invalid. - assembly = new PinAssembly(name, pinType, invalidSize); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - - // Valid parameters. - assembly = new PinAssembly(name, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - /* -------------------------------------- */ - - /* ---- Test all PinTypes. ---- */ - // InnerFuel - AssemblyType assemblyType = AssemblyType.Fuel; - pinType = PinType.InnerFuel; - - assembly = new PinAssembly(name, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(assemblyType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - - // OuterFuel - assemblyType = AssemblyType.Fuel; - pinType = PinType.OuterFuel; - - assembly = new PinAssembly(name, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(assemblyType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - - // BlanketFuel - assemblyType = AssemblyType.Fuel; - pinType = PinType.BlanketFuel; - - assembly = new PinAssembly(name, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(assemblyType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - - // PrimaryControl - assemblyType = AssemblyType.Control; - pinType = PinType.PrimaryControl; - - assembly = new PinAssembly(name, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(assemblyType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(0.75, assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(0.05, assembly.getInnerDuctThickness(), 0); - - // SecondaryControl - assemblyType = AssemblyType.Control; - pinType = PinType.SecondaryControl; - - assembly = new PinAssembly(name, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(assemblyType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(0.75, assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(0.05, assembly.getInnerDuctThickness(), 0); - /* ------------------------------ */ - - // Shield - assemblyType = AssemblyType.Shield; - pinType = PinType.Shield; - - assembly = new PinAssembly(name, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(assemblyType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - /* ------------------------------ */ - - // MaterialTest - assemblyType = AssemblyType.Test; - pinType = PinType.MaterialTest; - - assembly = new PinAssembly(name, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(assemblyType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - /* ------------------------------ */ - - // FuelTest - assemblyType = AssemblyType.Test; - pinType = PinType.FuelTest; - - assembly = new PinAssembly(name, pinType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(assemblyType, assembly.getAssemblyType()); - assertEquals(pinType, assembly.getPinType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - /* ------------------------------ */ - - return; - } - - /** - *

- * Tests the getter and setter for the pinPitch attribute. - *

- * - */ - @Test - public void checkPinPitch() { - PinAssembly assembly = new PinAssembly(1); - double defaultPinPitch = 1.0; - - // Check the default. - assertEquals(defaultPinPitch, assembly.getPinPitch(), 0); - - // Set it to 1 and check it. - assembly.setPinPitch(1.0); - assertEquals(1.0, assembly.getPinPitch(), 0); - - // Set it to an invalid number. - assembly.setPinPitch(-1.0); - assertEquals(1.0, assembly.getPinPitch(), 0); - - // Set it to a valid number. - assembly.setPinPitch(500); - assertEquals(500, assembly.getPinPitch(), 0); - - return; - } - - /** - *

- * Tests the getter and setter for the inner duct attributes. - *

- * - */ - @Test - public void checkInnerDuct() { - PinAssembly assembly = new PinAssembly(1); - double defaultInnerDuctFlatToFlat = 0.0; - double defaultInnerDuctThickness = 0.0; - - // Check the default. - assertEquals(defaultInnerDuctFlatToFlat, - assembly.getInnerDuctFlatToFlat(), 0); - assertEquals(defaultInnerDuctThickness, - assembly.getInnerDuctThickness(), 0); - - // Set inner duct flat-to-flat to 1 and check it. - assembly.setInnerDuctFlatToFlat(1.0); - assertEquals(1.0, assembly.getInnerDuctFlatToFlat(), 0); - - // Set inner duct flat-to-flat to an invalid number. - assembly.setInnerDuctFlatToFlat(-1.0); - assertEquals(1.0, assembly.getInnerDuctFlatToFlat(), 0); - - // Set inner duct flat-to-flat to a valid number. - assembly.setInnerDuctFlatToFlat(500); - assertEquals(500, assembly.getInnerDuctFlatToFlat(), 0); - - // Set inner duct thickness to 1 and check it. - assembly.setInnerDuctThickness(1.0); - assertEquals(1.0, assembly.getInnerDuctThickness(), 0); - - // Set inner duct thickness to to an invalid number. - assembly.setInnerDuctThickness(-1.0); - assertEquals(1.0, assembly.getInnerDuctThickness(), 0); - - // Set inner duct thickness to a valid number. - assembly.setInnerDuctThickness(500); - assertEquals(500, assembly.getInnerDuctThickness(), 0); - - return; - } - - /** - *

- * Tests the addition and removal of SFRPins to the PinAssembly. - *

- * - */ - @Test - public void checkPinAddRem() { - - // Note: I only check assembly.getPinLocations() in a few spots - // below since it's a late addition. Further testing may be required. - - int size = 10; - - // An assembly to test. - PinAssembly assembly = new PinAssembly(10); - - // Initialize some pins to add/remove from the assembly. - SFRPin pin1 = new SFRPin(); - pin1.setName("Anjie"); - SFRPin pin2 = new SFRPin(); - pin2.setName("Colin"); - SFRPin pin3 = new SFRPin(); - pin3.setName("Dish of the Day"); - - // A List of boundary indexes to test. - List boundaryIndexes = new ArrayList(); - boundaryIndexes.add(-1); - boundaryIndexes.add(0); - boundaryIndexes.add(size - 1); - boundaryIndexes.add(size); - - // A set of indexes that will be empty. This makes it easier to check - // pin locations. - Set emptyIndexes = new HashSet(); - for (int i = 0; i < size * size; i++) { - emptyIndexes.add(i); - } - String name; - - // Methods to test: - // public boolean addPin(SFRPin pin) - // public boolean removePin(String name) - // public boolean removePinFromLocation(int row, int column) - // public ArrayList getPinNames() - // public SFRPin getPinByName(String name) - // public SFRPin getPinByLocation(int row, int column) - // public boolean setPinLocation(String name, int row, int column) - - /* ---- Make sure the assembly is empty. ---- */ - // Check invalid locations. - for (int row : boundaryIndexes) { - for (int column : boundaryIndexes) { - if (row < 0 || row == size || column < 0 || column == size) { - assertNull(assembly.getPinByLocation(row, column)); - } - } - } - - // Check all valid locations. - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - /* ------------------------------------------ */ - - /* ---- Try various argument combinations for each method. ---- */ - name = pin1.getName(); - - // Verify that there is no pin set. - assertNull(assembly.getPinByName(name)); - assertEquals(0, assembly.getNumberOfPins()); - assertEquals(0, assembly.getPinNames().size()); - assertFalse(assembly.getPinNames().contains(name)); - - // Check all the locations. - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - // addPin - assertFalse(assembly.addPin(null)); - - // addPin (successful) - assertTrue(assembly.addPin(pin1)); - - // setPinLocation - assertFalse(assembly.setPinLocation(null, -1, -1)); - assertFalse(assembly.setPinLocation(null, 0, 0)); - assertFalse(assembly.setPinLocation("Vogons", 0, 0)); - assertFalse(assembly.setPinLocation(name, -1, 0)); - assertFalse(assembly.setPinLocation(name, 0, size)); - - // Check setting invalid locations. - for (int row : boundaryIndexes) { - for (int column : boundaryIndexes) { - if (row < 0 || row >= size || column < 0 || column >= size) { - assertFalse(assembly.setPinLocation(name, row, column)); - assertNull(assembly.getPinByLocation(row, column)); - } - } - } - - // setPinLocation (successful) - assertTrue(assembly.setPinLocation(name, 0, 0)); - - // getNumberOfPins (successful) - assertEquals(1, assembly.getNumberOfPins()); - - // getPinNames (successful) - assertEquals(1, assembly.getPinNames().size()); - assertTrue(assembly.getPinNames().contains(name)); - - // getPinByName - assertNull(assembly.getPinByName(null)); - assertNull(assembly.getPinByName("Vogons")); - - // getPinByName (successful) - assertEquals(pin1, assembly.getPinByName(name)); - - // getPinByLocation - assertNull(assembly.getPinByLocation(-1, -1)); - assertNull(assembly.getPinByLocation(-1, 0)); - assertNull(assembly.getPinByLocation(0, size)); - - // getPinByLocation (successful) - assertEquals(pin1, assembly.getPinByLocation(0, 0)); - - // getPinLocations - assertTrue(assembly.getPinLocations(null).isEmpty()); - assertTrue(assembly.getPinLocations("Vogons").isEmpty()); - - // getPinLocations (successful) - assertEquals(1, assembly.getPinLocations(name).size()); - assertTrue(assembly.getPinLocations(name).contains(0)); - - // removePinFromLocation - assertFalse(assembly.removePinFromLocation(-1, -1)); - assertFalse(assembly.removePinFromLocation(-1, 0)); - assertFalse(assembly.removePinFromLocation(0, size)); - - // removePinFromLocation (successful) - assertTrue(assembly.removePinFromLocation(0, 0)); - - // removePin - assertFalse(assembly.removePin(null)); - assertFalse(assembly.removePin("Vogons")); - - // removePin (successful) - assertTrue(assembly.removePin(name)); - - // Verify that the pin has been completely removed. - assertNull(assembly.getPinByName(name)); - assertEquals(0, assembly.getNumberOfPins()); - assertEquals(0, assembly.getPinNames().size()); - assertFalse(assembly.getPinNames().contains(name)); - - // Check all the locations. - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - /* ------------------------------------------------------------ */ - - /* ---- Add an pin and set some locations. ---- */ - name = pin1.getName(); - assertTrue(assembly.addPin(pin1)); - assertFalse(assembly.addPin(pin1)); - - // Verify that the pin was added. - assertEquals(pin1, assembly.getPinByName(name)); - assertEquals(1, assembly.getNumberOfPins()); - assertEquals(1, assembly.getPinNames().size()); - assertTrue(assembly.getPinNames().contains(name)); - - // All locations should be empty. - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - assertTrue(assembly.getPinLocations(name).isEmpty()); - - // The first attempt to set a location should succeed. Subsequent - // attempts to set the same pin in the same location should fail. - - // Put it in the first spot. - assertTrue(assembly.setPinLocation(name, 0, 0)); - assertFalse(assembly.setPinLocation(name, 0, 0)); - emptyIndexes.remove(0); - - // Put it in a middle spot. - assertTrue(assembly.setPinLocation(name, 0, 6)); - assertFalse(assembly.setPinLocation(name, 0, 6)); - emptyIndexes.remove(6); - - // Put it in a middle spot. - assertTrue(assembly.setPinLocation(name, 3, 7)); - assertFalse(assembly.setPinLocation(name, 3, 7)); - emptyIndexes.remove(3 * size + 7); - - // Put it in the last spot. - assertTrue(assembly.setPinLocation(name, size - 1, size - 1)); - assertFalse(assembly.setPinLocation(name, size - 1, size - 1)); - emptyIndexes.remove(size * size - 1); - - // Verify the pin locations. - assertEquals(pin1, assembly.getPinByLocation(0, 0)); - assertEquals(pin1, assembly.getPinByLocation(0, 6)); - assertEquals(pin1, assembly.getPinByLocation(3, 7)); - assertEquals(pin1, assembly.getPinByLocation(size - 1, size - 1)); - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - // We should still be able to get the pin by location. - assertEquals(pin1, assembly.getPinByLocation(0, 0)); - - // Verify the pin locations (getPinLocations()). - assertEquals(4, assembly.getPinLocations(name).size()); - assertTrue(assembly.getPinLocations(name).contains(0)); - assertTrue(assembly.getPinLocations(name).contains(0 * size + 6)); - assertTrue(assembly.getPinLocations(name).contains(3 * size + 7)); - assertTrue(assembly.getPinLocations(name).contains(size * size - 1)); - /* -------------------------------------------- */ - - /* ---- Test overriding a pin location. ---- */ - name = pin2.getName(); - assertTrue(assembly.addPin(pin2)); - assertFalse(assembly.addPin(pin2)); - - // Verify that the pin was added. - assertEquals(pin2, assembly.getPinByName(name)); - assertEquals(2, assembly.getNumberOfPins()); - assertEquals(2, assembly.getPinNames().size()); - assertTrue(assembly.getPinNames().contains(pin1.getName())); - assertTrue(assembly.getPinNames().contains(name)); - - // Verify the pin locations. - assertEquals(pin1, assembly.getPinByLocation(0, 0)); - assertEquals(pin1, assembly.getPinByLocation(0, 6)); - assertEquals(pin1, assembly.getPinByLocation(3, 7)); - assertEquals(pin1, assembly.getPinByLocation(size - 1, size - 1)); - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - // Put it in a new spot. - assertTrue(assembly.setPinLocation(name, 1, 1)); - assertFalse(assembly.setPinLocation(name, 1, 1)); - emptyIndexes.remove(size + 1); - - // Put it in a spot occupied by pin1. - assertTrue(assembly.setPinLocation(name, 3, 7)); - assertFalse(assembly.setPinLocation(name, 3, 7)); - - // Verify the pin locations. - assertEquals(pin1, assembly.getPinByLocation(0, 0)); - assertEquals(pin1, assembly.getPinByLocation(0, 6)); - assertEquals(pin1, assembly.getPinByLocation(size - 1, size - 1)); - assertEquals(pin2, assembly.getPinByLocation(1, 1)); - assertEquals(pin2, assembly.getPinByLocation(3, 7)); - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - /* ----------------------------------------- */ - - /* ---- Test adding yet another pin. ---- */ - name = pin3.getName(); - assertTrue(assembly.addPin(pin3)); - assertFalse(assembly.addPin(pin3)); - - // Verify that the pin was added. - assertEquals(pin3, assembly.getPinByName(name)); - assertEquals(3, assembly.getNumberOfPins()); - assertEquals(3, assembly.getPinNames().size()); - assertTrue(assembly.getPinNames().contains(pin1.getName())); - assertTrue(assembly.getPinNames().contains(pin2.getName())); - assertTrue(assembly.getPinNames().contains(name)); - - // Verify the pin locations. - assertEquals(pin1, assembly.getPinByLocation(0, 0)); - assertEquals(pin1, assembly.getPinByLocation(0, 6)); - assertEquals(pin1, assembly.getPinByLocation(size - 1, size - 1)); - assertEquals(pin2, assembly.getPinByLocation(1, 1)); - assertEquals(pin2, assembly.getPinByLocation(3, 7)); - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - - // Put it in a new spot. - assertTrue(assembly.setPinLocation(name, 3, 3)); - assertFalse(assembly.setPinLocation(name, 3, 3)); - emptyIndexes.remove(3 * size + 3); - - // Verify the pin locations. - assertEquals(pin1, assembly.getPinByLocation(0, 0)); - assertEquals(pin1, assembly.getPinByLocation(0, 6)); - assertEquals(pin1, assembly.getPinByLocation(size - 1, size - 1)); - assertEquals(pin2, assembly.getPinByLocation(1, 1)); - assertEquals(pin2, assembly.getPinByLocation(3, 7)); - assertEquals(pin3, assembly.getPinByLocation(3, 3)); - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - /* -------------------------------------- */ - - /* ---- Test removing a pin from a location. ---- */ - assertTrue(assembly.removePinFromLocation(0, 6)); - assertFalse(assembly.removePinFromLocation(0, 6)); - emptyIndexes.add(6); - - // Verify the pin locations. - assertEquals(pin1, assembly.getPinByLocation(0, 0)); - assertEquals(pin1, assembly.getPinByLocation(size - 1, size - 1)); - assertEquals(pin2, assembly.getPinByLocation(1, 1)); - assertEquals(pin2, assembly.getPinByLocation(3, 7)); - assertEquals(pin3, assembly.getPinByLocation(3, 3)); - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - // Remove pin2 entirely manually. - assertTrue(assembly.removePinFromLocation(1, 1)); - assertFalse(assembly.removePinFromLocation(1, 1)); - emptyIndexes.add(size + 1); - - assertTrue(assembly.removePinFromLocation(3, 7)); - assertFalse(assembly.removePinFromLocation(3, 7)); - emptyIndexes.add(3 * size + 7); - - // Verify the pin locations. - assertEquals(pin1, assembly.getPinByLocation(0, 0)); - assertEquals(pin1, assembly.getPinByLocation(size - 1, size - 1)); - assertEquals(pin3, assembly.getPinByLocation(3, 3)); - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - // Verify the pin locations (getPinLocations()). - assertEquals(2, assembly.getPinLocations(pin1.getName()).size()); - assertTrue(assembly.getPinLocations(pin1.getName()).contains(0)); - assertTrue(assembly.getPinLocations(pin1.getName()).contains( - size * size - 1)); - - // pin2 should still be in the assembly, though. - - // Verify the pins stored in the assembly. - assertEquals(pin1, assembly.getPinByName(pin1.getName())); - assertEquals(pin2, assembly.getPinByName(pin2.getName())); - assertEquals(pin3, assembly.getPinByName(pin3.getName())); - assertEquals(3, assembly.getNumberOfPins()); - assertEquals(3, assembly.getPinNames().size()); - assertTrue(assembly.getPinNames().contains(pin1.getName())); - assertTrue(assembly.getPinNames().contains(pin2.getName())); - assertTrue(assembly.getPinNames().contains(pin3.getName())); - /* ---------------------------------------------- */ - - /* ---- Test removing a pin completely. ---- */ - assertTrue(assembly.removePin(pin1.getName())); - assertFalse(assembly.removePin(pin1.getName())); - - emptyIndexes.add(0); - emptyIndexes.add(size * size - 1); - - // Verify the pin locations. - assertEquals(pin3, assembly.getPinByLocation(3, 3)); - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - // pin1 should not have any locations. In fact, since the pin is not in - // the assembly, this returns an empty List. - assertTrue(assembly.getPinLocations(pin1.getName()).isEmpty()); - - // Verify the pins stored in the assembly. - assertNull(assembly.getPinByName(pin1.getName())); - assertEquals(pin2, assembly.getPinByName(pin2.getName())); - assertEquals(pin3, assembly.getPinByName(pin3.getName())); - assertEquals(2, assembly.getNumberOfPins()); - assertEquals(2, assembly.getPinNames().size()); - assertFalse(assembly.getPinNames().contains(pin1.getName())); - assertTrue(assembly.getPinNames().contains(pin2.getName())); - assertTrue(assembly.getPinNames().contains(pin3.getName())); - /* ----------------------------------------- */ - - /* ---- Remove everything and verify. ---- */ - assertFalse(assembly.removePin(pin1.getName())); - assertTrue(assembly.removePin(pin2.getName())); - assertFalse(assembly.removePin(pin2.getName())); - assertTrue(assembly.removePin(pin3.getName())); - assertFalse(assembly.removePin(pin3.getName())); - - // Add the last pin location back to the empty index set. - emptyIndexes.add(size * 3 + 3); - - // Verify the pin locations. - for (int i : emptyIndexes) { - assertNull(assembly.getPinByLocation(i / size, i % size)); - } - // Verify the pins stored in the assembly. - assertNull(assembly.getPinByName(pin1.getName())); - assertNull(assembly.getPinByName(pin2.getName())); - assertNull(assembly.getPinByName(pin3.getName())); - assertEquals(0, assembly.getNumberOfPins()); - assertEquals(0, assembly.getPinNames().size()); - /* --------------------------------------- */ - - return; - } - - /** - *

- * Tests the methods inherited from SFRComposite. Users should not be able - * to add SFRComponents to a PinAssembly through these methods. - *

- * - */ - @Test - public void checkCompositeImplementation() { - - // Tests the following methods: - - // public Component getComponent(int childId) - // public SFRComponent getComponent(String name) - // public ArrayList getComponentNames() - // public int getNumberOfComponents() - // public ArrayList getComponents() - - // public void addComponent(Component child) - // public void removeComponent(int childId) - // public void removeComponent(String name) - - // Initialize an assembly to test. - PinAssembly assembly = new PinAssembly(15); - - SFRComposite composite; - SFRComponent component; - String name = "Ford"; - int id = 1; - int numberOfComponents = 0; - - /* ---- Check the initial state of the Composite. ---- */ - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertTrue(assembly.getComponents().isEmpty()); - assertTrue(assembly.getComponentNames().isEmpty()); - /* --------------------------------------------------- */ - - /* ---- Make sure we cannot add components directly. ---- */ - component = new SFRComponent(); - assembly.addComponent(component); - - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertTrue(assembly.getComponents().isEmpty()); - assertTrue(assembly.getComponentNames().isEmpty()); - assertNull(assembly.getComponent(component.getName())); - - // Try the same with a Composite. - composite = new SFRComposite(); - assembly.addComponent(composite); - - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertTrue(assembly.getComponents().isEmpty()); - assertTrue(assembly.getComponentNames().isEmpty()); - assertNull(assembly.getComponent(composite.getName())); - /* ------------------------------------------------------ */ - - /* ---- Add a component the proper way. ---- */ - // Create a valid component. - component = new SFRPin(); - component.setName(name); - - // Add it. - assertTrue(assembly.addPin((SFRPin) component)); - - numberOfComponents = 1; - - // Verify that it's there. - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertEquals(numberOfComponents, assembly.getComponents().size()); - assertTrue(assembly.getComponents().contains(component)); - assertEquals(numberOfComponents, assembly.getComponentNames().size()); - assertTrue(assembly.getComponentNames().contains(name)); - assertEquals(component, assembly.getComponent(name)); - /* ----------------------------------------- */ - - /* ---- Make sure we cannot remove components directly. ---- */ - id = component.getId(); - - // Try to remove it via ID. - assembly.removeComponent(id); - - // Verify that the component is still there. - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertEquals(numberOfComponents, assembly.getComponents().size()); - assertTrue(assembly.getComponents().contains(component)); - assertEquals(numberOfComponents, assembly.getComponentNames().size()); - assertTrue(assembly.getComponentNames().contains(name)); - assertEquals(component, assembly.getComponent(name)); - - // Try to remove it via name. - assembly.removeComponent(name); - - // Verify that the component is still there. - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertEquals(numberOfComponents, assembly.getComponents().size()); - assertTrue(assembly.getComponents().contains(component)); - assertEquals(numberOfComponents, assembly.getComponentNames().size()); - assertTrue(assembly.getComponentNames().contains(name)); - assertEquals(component, assembly.getComponent(name)); - - // Try removing an invalid component. - assembly.removeComponent(null); - - // Verify that the component is still there. - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertEquals(numberOfComponents, assembly.getComponents().size()); - assertTrue(assembly.getComponents().contains(component)); - assertEquals(numberOfComponents, assembly.getComponentNames().size()); - assertTrue(assembly.getComponentNames().contains(name)); - assertEquals(component, assembly.getComponent(name)); - /* --------------------------------------------------------- */ - - return; - } - - /** - *

- * Tests the equality and hashCode operations. - *

- */ - @Test - public void checkEquality() { - - int size = 78; - - // Initialize objects for testing. - PinAssembly object = new PinAssembly(size); - PinAssembly equalObject = new PinAssembly(size); - PinAssembly unequalObject = new PinAssembly(size); - - // Set up the object and equalObject. - SFRPin component = new SFRPin(); - component.setName("Marvin"); - SFRData subComponent = new SFRData("Depressed"); - subComponent.setValue(10); - component.addData(subComponent, 0); - - object.addPin(new SFRPin("Ford")); - object.addPin(new SFRPin("Zaphod")); - object.addPin(component); - - object.setPinLocation("Ford", 0, 0); - object.setPinLocation("Ford", 3, 4); - object.setPinLocation("Zaphod", 18, 35); - object.setPinLocation("Zaphod", 15, 36); - object.setPinLocation("Zaphod", 76, 77); - object.setPinLocation("Marvin", 13, 13); - object.setPinLocation("Marvin", 14, 14); - object.setPinLocation("Marvin", 15, 15); - - component = new SFRPin(); - component.setName("Marvin"); - subComponent = new SFRData("Depressed"); - subComponent.setValue(10); - component.addData(subComponent, 0); - - equalObject.addPin(new SFRPin("Ford")); - equalObject.addPin(new SFRPin("Zaphod")); - equalObject.addPin(component); - - equalObject.setPinLocation("Ford", 0, 0); - equalObject.setPinLocation("Ford", 3, 4); - equalObject.setPinLocation("Zaphod", 18, 35); - equalObject.setPinLocation("Zaphod", 15, 36); - equalObject.setPinLocation("Zaphod", 76, 77); - equalObject.setPinLocation("Marvin", 13, 13); - equalObject.setPinLocation("Marvin", 14, 14); - equalObject.setPinLocation("Marvin", 15, 15); - - // Set up the unequalObject. - component = new SFRPin(); - component.setName("Marvin"); - subComponent = new SFRData("Depressed"); - subComponent.setValue(9); // Different! - component.addData(subComponent, 0); - - unequalObject.addPin(new SFRPin("Ford")); - unequalObject.addPin(new SFRPin("Zaphod")); - unequalObject.addPin(component); - - unequalObject.setPinLocation("Ford", 0, 0); - unequalObject.setPinLocation("Ford", 3, 4); - unequalObject.setPinLocation("Zaphod", 18, 35); - unequalObject.setPinLocation("Zaphod", 15, 36); - unequalObject.setPinLocation("Zaphod", 76, 77); - unequalObject.setPinLocation("Marvin", 13, 13); - unequalObject.setPinLocation("Marvin", 14, 14); - unequalObject.setPinLocation("Marvin", 15, 15); - - // Make sure the references are different. - assertFalse(object == equalObject); - assertFalse(object == unequalObject); - assertFalse(equalObject == unequalObject); - - // Check that equality is reflexive and symmetric. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Check that equals will fail when it should. - assertFalse(object == null); - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Check the hash codes. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - assertFalse(object.hashCode() == unequalObject.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations. - *

- */ - @Test - public void checkCopying() { - - int size = 79; - - // Initialize objects for testing. - PinAssembly object = new PinAssembly(size); - PinAssembly copy = new PinAssembly(size); - PinAssembly clone = null; - - // Set up the object. - SFRPin component = new SFRPin(); - component.setName("Marvin"); - SFRData subComponent = new SFRData("Depressed"); - subComponent.setValue(10); - component.addData(subComponent, 0); - - object.addPin(new SFRPin("Ford")); - object.addPin(new SFRPin("Zaphod")); - object.addPin(component); - - object.setPinLocation("Ford", 0, 0); - object.setPinLocation("Ford", 3, 4); - object.setPinLocation("Zaphod", 18, 35); - object.setPinLocation("Zaphod", 15, 36); - object.setPinLocation("Zaphod", 76, 77); - object.setPinLocation("Marvin", 13, 13); - object.setPinLocation("Marvin", 14, 14); - object.setPinLocation("Marvin", 15, 15); - - // Make sure the objects are not equal before copying. - assertFalse(object == copy); - assertFalse(object.equals(copy)); - - // Copy the object. - copy.copy(object); - - // Make sure the references are different but contents the same. - assertFalse(object == copy); - assertTrue(object.equals(copy)); - - // Do the same for the clone operation. - - // Make sure the objects are not equal before copying. - assertFalse(object == clone); - assertFalse(object.equals(clone)); - - // Copy the object. - clone = (PinAssembly) object.clone(); - - // Make sure the references are different but contents the same. - assertFalse(object == clone); - assertTrue(object.equals(clone)); - assertFalse(copy == clone); - assertTrue(copy.equals(clone)); - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/ReflectorAssemblyTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/ReflectorAssemblyTester.java deleted file mode 100644 index 66df34740..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/ReflectorAssemblyTester.java +++ /dev/null @@ -1,854 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.base.SFRComposite; -import org.eclipse.ice.reactor.sfr.base.SFRData; -import org.eclipse.ice.reactor.sfr.core.AssemblyType; -import org.eclipse.ice.reactor.sfr.core.assembly.ReflectorAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRRod; -import org.junit.Test; - -/** - *

- * Tests the operations of the ReflectorAssembly class. - *

- * - * @author Anna Wojtowicz - */ -public class ReflectorAssemblyTester { - - // FIXME - removed checkRod - - /** - *

- * Tests constructors and default values of the ReflectorAssembly class. - *

- * - */ - @Test - public void checkConstruction() { - - // An assembly to test. - ReflectorAssembly assembly; - - // Invalid, default, and valid values to use in the constructor. - int invalidSize = 0; - int defaultSize = 1; - int size = 31; - - String nullName = null; - String emptyName = " "; - String defaultName = "SFR Reflector Assembly 1"; - String name = "Tricia"; - - // Other defaults. - AssemblyType defaultType = AssemblyType.Reflector; - String defaultDescription = "SFR Reflector Assembly 1's Description"; - int defaultId = 1; - double defaultDuctThickness = 0.0; - double defaultRodPitch = 1.0; - - /* ---- Test the basic constructor. ---- */ - // Invalid parameters. - assembly = new ReflectorAssembly(invalidSize); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0); - - // Valid parameters. - assembly = new ReflectorAssembly(size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0); - /* ------------------------------------- */ - - /* ---- Test the second constructor. ---- */ - // Invalid parameters. - - // All invalid. - assembly = new ReflectorAssembly(nullName, invalidSize); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0); - - // Name invalid. - assembly = new ReflectorAssembly(emptyName, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0); - - // Size invalid. - assembly = new ReflectorAssembly(name, invalidSize); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0); - - // Valid parameters. - assembly = new ReflectorAssembly(name, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0); - /* -------------------------------------- */ - - return; - } - - /** - *

- * Tests the getter and setter of the rodPitch attribute. - *

- * - */ - @Test - public void checkRodPitch() { - ReflectorAssembly assembly = new ReflectorAssembly(1); - double defaultRodPitch = 1.0; - - // Check the default. - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0); - - // Set it to 1 and check it. - assembly.setRodPitch(1.0); - assertEquals(1.0, assembly.getRodPitch(), 0); - - // Set it to an invalid number. - assembly.setRodPitch(-1.0); - assertEquals(1.0, assembly.getRodPitch(), 0); - - // Set it to a valid number. - assembly.setRodPitch(500); - assertEquals(500, assembly.getRodPitch(), 0); - - return; - } - - /** - *

- * Tests the addition and removal of SFRRods in the ReflectorAssembly. - *

- * - */ - @Test - public void checkRodAddRem() { - - // Note: I only check assembly.getRodLocations() in a few spots - // below since it's a late addition. Further testing may be required. - - int size = 10; - - // An assembly to test. - ReflectorAssembly assembly = new ReflectorAssembly(10); - - // Initialize some rods to add/remove from the assembly. - SFRRod rod1 = new SFRRod(); - rod1.setName("Anjie"); - SFRRod rod2 = new SFRRod(); - rod2.setName("Colin"); - SFRRod rod3 = new SFRRod(); - rod3.setName("Dish of the Day"); - - // A List of boundary indexes to test. - List boundaryIndexes = new ArrayList(); - boundaryIndexes.add(-1); - boundaryIndexes.add(0); - boundaryIndexes.add(size - 1); - boundaryIndexes.add(size); - - // A set of indexes that will be empty. This makes it easier to check - // rod locations. - Set emptyIndexes = new HashSet(); - for (int i = 0; i < size * size; i++) { - emptyIndexes.add(i); - } - String name; - - // Methods to test: - // public boolean addRod(SFRRod rod) - // public boolean removeRod(String name) - // public boolean removeRodFromLocation(int row, int column) - // public ArrayList getRodNames() - // public SFRRod getRodByName(String name) - // public SFRRod getRodByLocation(int row, int column) - // public boolean setRodLocation(String name, int row, int column) - - /* ---- Make sure the assembly is empty. ---- */ - // Check invalid locations. - for (int row : boundaryIndexes) { - for (int column : boundaryIndexes) { - if (row < 0 || row == size || column < 0 || column == size) { - assertNull(assembly.getRodByLocation(row, column)); - } - } - } - - // Check all valid locations. - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - /* ------------------------------------------ */ - - /* ---- Try various argument combinations for each method. ---- */ - name = rod1.getName(); - - // Verify that there is no rod set. - assertNull(assembly.getRodByName(name)); - assertEquals(0, assembly.getNumberOfRods()); - assertEquals(0, assembly.getRodNames().size()); - assertFalse(assembly.getRodNames().contains(name)); - - // Check all the locations. - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - // addRod - assertFalse(assembly.addRod(null)); - - // addRod (successful) - assertTrue(assembly.addRod(rod1)); - - // setRodLocation - assertFalse(assembly.setRodLocation(null, -1, -1)); - assertFalse(assembly.setRodLocation(null, 0, 0)); - assertFalse(assembly.setRodLocation("Vogons", 0, 0)); - assertFalse(assembly.setRodLocation(name, -1, 0)); - assertFalse(assembly.setRodLocation(name, 0, size)); - - // Check setting invalid locations. - for (int row : boundaryIndexes) { - for (int column : boundaryIndexes) { - if (row < 0 || row >= size || column < 0 || column >= size) { - assertFalse(assembly.setRodLocation(name, row, column)); - assertNull(assembly.getRodByLocation(row, column)); - } - } - } - - // setRodLocation (successful) - assertTrue(assembly.setRodLocation(name, 0, 0)); - - // getNumberOfRods (successful) - assertEquals(1, assembly.getNumberOfRods()); - - // getRodNames (successful) - assertEquals(1, assembly.getRodNames().size()); - assertTrue(assembly.getRodNames().contains(name)); - - // getRodByName - assertNull(assembly.getRodByName(null)); - assertNull(assembly.getRodByName("Vogons")); - - // getRodByName (successful) - assertEquals(rod1, assembly.getRodByName(name)); - - // getRodByLocation - assertNull(assembly.getRodByLocation(-1, -1)); - assertNull(assembly.getRodByLocation(-1, 0)); - assertNull(assembly.getRodByLocation(0, size)); - - // getRodByLocation (successful) - assertEquals(rod1, assembly.getRodByLocation(0, 0)); - - // getRodLocations - assertTrue(assembly.getRodLocations(null).isEmpty()); - assertTrue(assembly.getRodLocations("Vogons").isEmpty()); - - // getRodLocations (successful) - assertEquals(1, assembly.getRodLocations(name).size()); - assertTrue(assembly.getRodLocations(name).contains(0)); - - // removeRodFromLocation - assertFalse(assembly.removeRodFromLocation(-1, -1)); - assertFalse(assembly.removeRodFromLocation(-1, 0)); - assertFalse(assembly.removeRodFromLocation(0, size)); - - // removeRodFromLocation (successful) - assertTrue(assembly.removeRodFromLocation(0, 0)); - - // removeRod - assertFalse(assembly.removeRod(null)); - assertFalse(assembly.removeRod("Vogons")); - - // removeRod (successful) - assertTrue(assembly.removeRod(name)); - - // Verify that the rod has been completely removed. - assertNull(assembly.getRodByName(name)); - assertEquals(0, assembly.getNumberOfRods()); - assertEquals(0, assembly.getRodNames().size()); - assertFalse(assembly.getRodNames().contains(name)); - - // Check all the locations. - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - /* ------------------------------------------------------------ */ - - /* ---- Add an rod and set some locations. ---- */ - name = rod1.getName(); - assertTrue(assembly.addRod(rod1)); - assertFalse(assembly.addRod(rod1)); - - // Verify that the rod was added. - assertEquals(rod1, assembly.getRodByName(name)); - assertEquals(1, assembly.getNumberOfRods()); - assertEquals(1, assembly.getRodNames().size()); - assertTrue(assembly.getRodNames().contains(name)); - - // All locations should be empty. - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - assertTrue(assembly.getRodLocations(name).isEmpty()); - - // The first attempt to set a location should succeed. Subsequent - // attempts to set the same rod in the same location should fail. - - // Put it in the first spot. - assertTrue(assembly.setRodLocation(name, 0, 0)); - assertFalse(assembly.setRodLocation(name, 0, 0)); - emptyIndexes.remove(0); - - // Put it in a middle spot. - assertTrue(assembly.setRodLocation(name, 0, 6)); - assertFalse(assembly.setRodLocation(name, 0, 6)); - emptyIndexes.remove(6); - - // Put it in a middle spot. - assertTrue(assembly.setRodLocation(name, 3, 7)); - assertFalse(assembly.setRodLocation(name, 3, 7)); - emptyIndexes.remove(3 * size + 7); - - // Put it in the last spot. - assertTrue(assembly.setRodLocation(name, size - 1, size - 1)); - assertFalse(assembly.setRodLocation(name, size - 1, size - 1)); - emptyIndexes.remove(size * size - 1); - - // Verify the rod locations. - assertEquals(rod1, assembly.getRodByLocation(0, 0)); - assertEquals(rod1, assembly.getRodByLocation(0, 6)); - assertEquals(rod1, assembly.getRodByLocation(3, 7)); - assertEquals(rod1, assembly.getRodByLocation(size - 1, size - 1)); - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - // We should still be able to get the rod by location. - assertEquals(rod1, assembly.getRodByLocation(0, 0)); - - // Verify the rod locations (getRodLocations()). - assertEquals(4, assembly.getRodLocations(name).size()); - assertTrue(assembly.getRodLocations(name).contains(0)); - assertTrue(assembly.getRodLocations(name).contains(0 * size + 6)); - assertTrue(assembly.getRodLocations(name).contains(3 * size + 7)); - assertTrue(assembly.getRodLocations(name).contains(size * size - 1)); - /* -------------------------------------------- */ - - /* ---- Test overriding a rod location. ---- */ - name = rod2.getName(); - assertTrue(assembly.addRod(rod2)); - assertFalse(assembly.addRod(rod2)); - - // Verify that the rod was added. - assertEquals(rod2, assembly.getRodByName(name)); - assertEquals(2, assembly.getNumberOfRods()); - assertEquals(2, assembly.getRodNames().size()); - assertTrue(assembly.getRodNames().contains(rod1.getName())); - assertTrue(assembly.getRodNames().contains(name)); - - // Verify the rod locations. - assertEquals(rod1, assembly.getRodByLocation(0, 0)); - assertEquals(rod1, assembly.getRodByLocation(0, 6)); - assertEquals(rod1, assembly.getRodByLocation(3, 7)); - assertEquals(rod1, assembly.getRodByLocation(size - 1, size - 1)); - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - // Put it in a new spot. - assertTrue(assembly.setRodLocation(name, 1, 1)); - assertFalse(assembly.setRodLocation(name, 1, 1)); - emptyIndexes.remove(size + 1); - - // Put it in a spot occupied by rod1. - assertTrue(assembly.setRodLocation(name, 3, 7)); - assertFalse(assembly.setRodLocation(name, 3, 7)); - - // Verify the rod locations. - assertEquals(rod1, assembly.getRodByLocation(0, 0)); - assertEquals(rod1, assembly.getRodByLocation(0, 6)); - assertEquals(rod1, assembly.getRodByLocation(size - 1, size - 1)); - assertEquals(rod2, assembly.getRodByLocation(1, 1)); - assertEquals(rod2, assembly.getRodByLocation(3, 7)); - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - /* ----------------------------------------- */ - - /* ---- Test adding yet another rod. ---- */ - name = rod3.getName(); - assertTrue(assembly.addRod(rod3)); - assertFalse(assembly.addRod(rod3)); - - // Verify that the rod was added. - assertEquals(rod3, assembly.getRodByName(name)); - assertEquals(3, assembly.getNumberOfRods()); - assertEquals(3, assembly.getRodNames().size()); - assertTrue(assembly.getRodNames().contains(rod1.getName())); - assertTrue(assembly.getRodNames().contains(rod2.getName())); - assertTrue(assembly.getRodNames().contains(name)); - - // Verify the rod locations. - assertEquals(rod1, assembly.getRodByLocation(0, 0)); - assertEquals(rod1, assembly.getRodByLocation(0, 6)); - assertEquals(rod1, assembly.getRodByLocation(size - 1, size - 1)); - assertEquals(rod2, assembly.getRodByLocation(1, 1)); - assertEquals(rod2, assembly.getRodByLocation(3, 7)); - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - // Put it in a new spot. - assertTrue(assembly.setRodLocation(name, 3, 3)); - assertFalse(assembly.setRodLocation(name, 3, 3)); - emptyIndexes.remove(3 * size + 3); - - // Verify the rod locations. - assertEquals(rod1, assembly.getRodByLocation(0, 0)); - assertEquals(rod1, assembly.getRodByLocation(0, 6)); - assertEquals(rod1, assembly.getRodByLocation(size - 1, size - 1)); - assertEquals(rod2, assembly.getRodByLocation(1, 1)); - assertEquals(rod2, assembly.getRodByLocation(3, 7)); - assertEquals(rod3, assembly.getRodByLocation(3, 3)); - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - /* -------------------------------------- */ - - /* ---- Test removing a rod from a location. ---- */ - assertTrue(assembly.removeRodFromLocation(0, 6)); - assertFalse(assembly.removeRodFromLocation(0, 6)); - emptyIndexes.add(6); - - // Verify the rod locations. - assertEquals(rod1, assembly.getRodByLocation(0, 0)); - assertEquals(rod1, assembly.getRodByLocation(size - 1, size - 1)); - assertEquals(rod2, assembly.getRodByLocation(1, 1)); - assertEquals(rod2, assembly.getRodByLocation(3, 7)); - assertEquals(rod3, assembly.getRodByLocation(3, 3)); - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - // Remove rod2 entirely manually. - assertTrue(assembly.removeRodFromLocation(1, 1)); - assertFalse(assembly.removeRodFromLocation(1, 1)); - emptyIndexes.add(size + 1); - - assertTrue(assembly.removeRodFromLocation(3, 7)); - assertFalse(assembly.removeRodFromLocation(3, 7)); - emptyIndexes.add(3 * size + 7); - - // Verify the rod locations. - assertEquals(rod1, assembly.getRodByLocation(0, 0)); - assertEquals(rod1, assembly.getRodByLocation(size - 1, size - 1)); - assertEquals(rod3, assembly.getRodByLocation(3, 3)); - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - // Verify the rod locations (getRodLocations()). - assertEquals(2, assembly.getRodLocations(rod1.getName()).size()); - assertTrue(assembly.getRodLocations(rod1.getName()).contains(0)); - assertTrue(assembly.getRodLocations(rod1.getName()).contains( - size * size - 1)); - - // rod2 should still be in the assembly, though. - - // Verify the rods stored in the assembly. - assertEquals(rod1, assembly.getRodByName(rod1.getName())); - assertEquals(rod2, assembly.getRodByName(rod2.getName())); - assertEquals(rod3, assembly.getRodByName(rod3.getName())); - assertEquals(3, assembly.getNumberOfRods()); - assertEquals(3, assembly.getRodNames().size()); - assertTrue(assembly.getRodNames().contains(rod1.getName())); - assertTrue(assembly.getRodNames().contains(rod2.getName())); - assertTrue(assembly.getRodNames().contains(rod3.getName())); - /* ---------------------------------------------- */ - - /* ---- Test removing a rod completely. ---- */ - assertTrue(assembly.removeRod(rod1.getName())); - assertFalse(assembly.removeRod(rod1.getName())); - - emptyIndexes.add(0); - emptyIndexes.add(size * size - 1); - - // Verify the rod locations. - assertEquals(rod3, assembly.getRodByLocation(3, 3)); - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - // rod1 should not have any locations. In fact, since the rod is not in - // the assembly, this returns an empty List. - assertTrue(assembly.getRodLocations(rod1.getName()).isEmpty()); - - // Verify the rods stored in the assembly. - assertNull(assembly.getRodByName(rod1.getName())); - assertEquals(rod2, assembly.getRodByName(rod2.getName())); - assertEquals(rod3, assembly.getRodByName(rod3.getName())); - assertEquals(2, assembly.getNumberOfRods()); - assertEquals(2, assembly.getRodNames().size()); - assertFalse(assembly.getRodNames().contains(rod1.getName())); - assertTrue(assembly.getRodNames().contains(rod2.getName())); - assertTrue(assembly.getRodNames().contains(rod3.getName())); - /* ----------------------------------------- */ - - /* ---- Remove everything and verify. ---- */ - assertFalse(assembly.removeRod(rod1.getName())); - assertTrue(assembly.removeRod(rod2.getName())); - assertFalse(assembly.removeRod(rod2.getName())); - assertTrue(assembly.removeRod(rod3.getName())); - assertFalse(assembly.removeRod(rod3.getName())); - - // Add the last rod location back to the empty index set. - emptyIndexes.add(size * 3 + 3); - - // Verify the rod locations. - for (int i : emptyIndexes) { - assertNull(assembly.getRodByLocation(i / size, i % size)); - } - // Verify the rods stored in the assembly. - assertNull(assembly.getRodByName(rod1.getName())); - assertNull(assembly.getRodByName(rod2.getName())); - assertNull(assembly.getRodByName(rod3.getName())); - assertEquals(0, assembly.getNumberOfRods()); - assertEquals(0, assembly.getRodNames().size()); - /* --------------------------------------- */ - - return; - } - - /** - *

- * Tests the methods inherited from SFRComposite. Users should not be able - * to add SFRComponents to a ReflectorAssembly through these methods. - *

- * - */ - @Test - public void checkCompositeImplementation() { - - // Tests the following methods: - - // public Component getComponent(int childId) - // public SFRComponent getComponent(String name) - // public ArrayList getComponentNames() - // public int getNumberOfComponents() - // public ArrayList getComponents() - - // public void addComponent(Component child) - // public void removeComponent(int childId) - // public void removeComponent(String name) - - // Initialize an assembly to test. - ReflectorAssembly assembly = new ReflectorAssembly(15); - - SFRComposite composite; - SFRComponent component; - String name = "Ford"; - int id = 1; - int numberOfComponents = 0; - - /* ---- Check the initial state of the Composite. ---- */ - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertTrue(assembly.getComponents().isEmpty()); - assertTrue(assembly.getComponentNames().isEmpty()); - /* --------------------------------------------------- */ - - /* ---- Make sure we cannot add components directly. ---- */ - component = new SFRComponent(); - assembly.addComponent(component); - - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertTrue(assembly.getComponents().isEmpty()); - assertTrue(assembly.getComponentNames().isEmpty()); - assertNull(assembly.getComponent(component.getName())); - - // Try the same with a Composite. - composite = new SFRComposite(); - assembly.addComponent(composite); - - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertTrue(assembly.getComponents().isEmpty()); - assertTrue(assembly.getComponentNames().isEmpty()); - assertNull(assembly.getComponent(composite.getName())); - /* ------------------------------------------------------ */ - - /* ---- Add a component the proper way. ---- */ - // Create a valid component. - component = new SFRRod(); - component.setName(name); - - // Add it. - assertTrue(assembly.addRod((SFRRod) component)); - - numberOfComponents = 1; - - // Verify that it's there. - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertEquals(numberOfComponents, assembly.getComponents().size()); - assertTrue(assembly.getComponents().contains(component)); - assertEquals(numberOfComponents, assembly.getComponentNames().size()); - assertTrue(assembly.getComponentNames().contains(name)); - assertEquals(component, assembly.getComponent(name)); - /* ----------------------------------------- */ - - /* ---- Make sure we cannot remove components directly. ---- */ - id = component.getId(); - - // Try to remove it via ID. - assembly.removeComponent(id); - - // Verify that the component is still there. - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertEquals(numberOfComponents, assembly.getComponents().size()); - assertTrue(assembly.getComponents().contains(component)); - assertEquals(numberOfComponents, assembly.getComponentNames().size()); - assertTrue(assembly.getComponentNames().contains(name)); - assertEquals(component, assembly.getComponent(name)); - - // Try to remove it via name. - assembly.removeComponent(name); - - // Verify that the component is still there. - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertEquals(numberOfComponents, assembly.getComponents().size()); - assertTrue(assembly.getComponents().contains(component)); - assertEquals(numberOfComponents, assembly.getComponentNames().size()); - assertTrue(assembly.getComponentNames().contains(name)); - assertEquals(component, assembly.getComponent(name)); - - // Try removing an invalid component. - assembly.removeComponent(null); - - // Verify that the component is still there. - assertEquals(numberOfComponents, assembly.getNumberOfComponents()); - assertEquals(numberOfComponents, assembly.getComponents().size()); - assertTrue(assembly.getComponents().contains(component)); - assertEquals(numberOfComponents, assembly.getComponentNames().size()); - assertTrue(assembly.getComponentNames().contains(name)); - assertEquals(component, assembly.getComponent(name)); - /* --------------------------------------------------------- */ - - return; - } - - /** - *

- * Tests the equality and hashCode operations. - *

- */ - @Test - public void checkEquality() { - - int size = 78; - - // Initialize objects for testing. - ReflectorAssembly object = new ReflectorAssembly(size); - ReflectorAssembly equalObject = new ReflectorAssembly(size); - ReflectorAssembly unequalObject = new ReflectorAssembly(size); - - // Set up the object and equalObject. - SFRRod component = new SFRRod(); - component.setName("Marvin"); - SFRData subComponent = new SFRData("Depressed"); - subComponent.setValue(10); - component.addData(subComponent, 0); - - object.addRod(new SFRRod("Ford")); - object.addRod(new SFRRod("Zaphod")); - object.addRod(component); - - object.setRodLocation("Ford", 0, 0); - object.setRodLocation("Ford", 3, 4); - object.setRodLocation("Zaphod", 18, 35); - object.setRodLocation("Zaphod", 15, 36); - object.setRodLocation("Zaphod", 76, 77); - object.setRodLocation("Marvin", 13, 13); - object.setRodLocation("Marvin", 14, 14); - object.setRodLocation("Marvin", 15, 15); - - component = new SFRRod(); - component.setName("Marvin"); - subComponent = new SFRData("Depressed"); - subComponent.setValue(10); - component.addData(subComponent, 0); - - equalObject.addRod(new SFRRod("Ford")); - equalObject.addRod(new SFRRod("Zaphod")); - equalObject.addRod(component); - - equalObject.setRodLocation("Ford", 0, 0); - equalObject.setRodLocation("Ford", 3, 4); - equalObject.setRodLocation("Zaphod", 18, 35); - equalObject.setRodLocation("Zaphod", 15, 36); - equalObject.setRodLocation("Zaphod", 76, 77); - equalObject.setRodLocation("Marvin", 13, 13); - equalObject.setRodLocation("Marvin", 14, 14); - equalObject.setRodLocation("Marvin", 15, 15); - - // Set up the unequalObject. - component = new SFRRod(); - component.setName("Marvin"); - subComponent = new SFRData("Depressed"); - subComponent.setValue(10); - component.addData(subComponent, 0); - - unequalObject.addRod(new SFRRod("Ford")); - unequalObject.addRod(new SFRRod("Zaphod")); - unequalObject.addRod(component); - - unequalObject.setRodLocation("Ford", 0, 0); - unequalObject.setRodLocation("Ford", 3, 4); - unequalObject.setRodLocation("Zaphod", 18, 35); - unequalObject.setRodLocation("Zaphod", 15, 36); - unequalObject.setRodLocation("Zaphod", 76, 77); - unequalObject.setRodLocation("Marvin", 13, 13); - unequalObject.setRodLocation("Marvin", 14, 14); - unequalObject.setRodLocation("Marvin", 15, 16); // Different! - - // Make sure the references are different. - assertFalse(object == equalObject); - assertFalse(object == unequalObject); - assertFalse(equalObject == unequalObject); - - // Check that equality is reflexive and symmetric. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Check that equals will fail when it should. - assertFalse(object == null); - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Check the hash codes. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - assertFalse(object.hashCode() == unequalObject.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations. - *

- */ - @Test - public void checkCopying() { - - int size = 79; - - // Initialize objects for testing. - ReflectorAssembly object = new ReflectorAssembly(size); - ReflectorAssembly copy = new ReflectorAssembly(size); - ReflectorAssembly clone = null; - - // Set up the object. - SFRRod component = new SFRRod(); - component.setName("Marvin"); - SFRData subComponent = new SFRData("Depressed"); - subComponent.setValue(10); - component.addData(subComponent, 0); - - object.addRod(new SFRRod("Ford")); - object.addRod(new SFRRod("Zaphod")); - object.addRod(component); - - object.setRodLocation("Ford", 0, 0); - object.setRodLocation("Ford", 3, 4); - object.setRodLocation("Zaphod", 18, 35); - object.setRodLocation("Zaphod", 15, 36); - object.setRodLocation("Zaphod", 76, 77); - object.setRodLocation("Marvin", 13, 13); - object.setRodLocation("Marvin", 14, 14); - object.setRodLocation("Marvin", 15, 15); - - // Make sure the objects are not equal before copying. - assertFalse(object == copy); - assertFalse(object.equals(copy)); - - // Copy the object. - copy.copy(object); - - // Make sure the references are different but contents the same. - assertFalse(object == copy); - assertTrue(object.equals(copy)); - - // Do the same for the clone operation. - - // Make sure the objects are not equal before copying. - assertFalse(object == clone); - assertFalse(object.equals(clone)); - - // Copy the object. - clone = (ReflectorAssembly) object.clone(); - - // Make sure the references are different but contents the same. - assertFalse(object == clone); - assertTrue(object.equals(clone)); - assertFalse(copy == clone); - assertTrue(copy.equals(clone)); - - return; - } -} diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/RingTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/RingTester.java deleted file mode 100644 index 36d897e1a..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/RingTester.java +++ /dev/null @@ -1,334 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.ice.reactor.sfr.core.Material; -import org.eclipse.ice.reactor.sfr.core.assembly.Ring; -import org.junit.Test; - -/** - *

- * Tests the operations of the Ring class. - *

- * - * @author Anna Wojtowicz - */ -public class RingTester { - /** - *

- * Tests the constructors and default values for the Ring class. - *

- * - */ - @Test - public void checkConstruction() { - - /* - * Three constructors to test: Ring(); Ring(String name) Ring(String - * name, Material material, double height, double innerRadius, double - * outerRadius) - */ - - /* --- Test the nullary constructor -------------------------------- */ - - // Create a Ring for testing - Ring ringOne = new Ring(); - - // Check the name, description and ID - assertEquals("Ring 1", ringOne.getName()); - assertEquals("Ring 1 Description", ringOne.getDescription()); - assertEquals(1, ringOne.getId()); - - // Check the material, height and radii default values - assertNotNull(ringOne.getMaterial()); - assertEquals(0.0, ringOne.getHeight(), 0.0); - assertEquals(0.0, ringOne.getInnerRadius(), 0.0); - assertEquals(1.0, ringOne.getOuterRadius(), 0.0); - - /* --- Test parameterized constructor with name -------------------- */ - - // Create a Ring for testing with name specified - Ring ringTwo = new Ring("Babelfish"); - - // Check the name, description and ID - assertEquals("Babelfish", ringTwo.getName()); - assertEquals("Ring 1 Description", ringTwo.getDescription()); - assertEquals(1, ringTwo.getId()); - - // Check the material, height and radii default values - assertNotNull(ringTwo.getMaterial()); - assertEquals(0.0, ringTwo.getHeight(), 0.0); - assertEquals(0.0, ringTwo.getInnerRadius(), 0.0); - assertEquals(1.0, ringTwo.getOuterRadius(), 0.0); - - /* - * --- Test parameterized constructor with name, height, material, --- - * inner radius and outer radius ------------------------------- - */ - Material blubber = new Material(); - - // Create a Ring for testing with name, height, material, and radii - Ring ringThree = new Ring("Sperm Whale", blubber, 1.0, 2.55, 4.039); - - // Check the name, description and ID - assertEquals("Sperm Whale", ringThree.getName()); - assertEquals("Ring 1 Description", ringThree.getDescription()); - assertEquals(1, ringThree.getId()); - - // Check the material, height and radii - assertEquals(blubber, ringThree.getMaterial()); - assertEquals(1.0, ringThree.getHeight(), 0.0); - assertEquals(2.55, ringThree.getInnerRadius(), 0.0); - assertEquals(4.039, ringThree.getOuterRadius(), 0.0); - - } - - /** - *

- * Checks the getters and setters for the height, innerRadius, outerRadius, - * and material attributes. - *

- * - */ - @Test - public void checkAttributes() { - - // Create a nullary Ring for testing - Ring ring = new Ring(); - - // Create a material to use for testing - Material material = new Material("Pan Galactic Gargle Blaster"); - - // Set the height, innerRadius, outerRadius and material - ring.setHeight(53.2); - ring.setInnerRadius(12.6); - ring.setOuterRadius(13.9); - ring.setMaterial(material); - - // Check the height, innerRadius, outerRadius and material - assertEquals(53.2, ring.getHeight(), 0.0); - assertEquals(12.6, ring.getInnerRadius(), 0.0); - assertEquals(13.9, ring.getOuterRadius(), 0.0); - assertEquals(material, ring.getMaterial()); - - // Check radii are unchanged - assertEquals(12.6, ring.getInnerRadius(), 0.0); - assertEquals(13.9, ring.getOuterRadius(), 0.0); - - // Try setting height, radii and material to illegal values - ring.setHeight(-1.0); - ring.setInnerRadius(-8.7); - ring.setOuterRadius(-20.4); - ring.setMaterial(null); - - // Check attributes are unchanged - assertEquals(53.2, ring.getHeight(), 0.0); - assertEquals(12.6, ring.getInnerRadius(), 0.0); - assertEquals(13.9, ring.getOuterRadius(), 0.0); - assertEquals(material, ring.getMaterial()); - - } - - /** - *

- * Checks the getters and setters for the height, innerRadius, outerRadius, - * and material attributes. - *

- * - */ - @Test - public void checkCompareTo() { - - // Create "smaller" ring for testing - Ring smallRing = new Ring(); - smallRing.setInnerRadius(6.2); - smallRing.setOuterRadius(7.8); - - // Create a "larger" ring for testing - Ring largeRing = new Ring(); - largeRing.setInnerRadius(7.8); - largeRing.setOuterRadius(8.4); - - // Check that smallRing compared to largeRing returns -1 (inside) - assertEquals(-1, smallRing.compareTo(largeRing)); - - // Check that largeRing compared to smallRing returns +1 (outside) - assertEquals(1, largeRing.compareTo(smallRing)); - - // Test for overlapping rings. The smaller ring is chosen arbitrarily to - // test against, but you could just as easily use the larger one - - // Create a ring that overlaps innerRadius - Ring overlapInner = new Ring(); - overlapInner.setInnerRadius(5.9); - overlapInner.setOuterRadius(6.7); - - // Check that smallRing compared to overlapInner returns 0 (overlap) - assertEquals(0, smallRing.compareTo(overlapInner)); - - // Create a ring that overlaps outerRadius - Ring overlapOuter = new Ring(); - overlapOuter.setInnerRadius(7.7); - overlapOuter.setOuterRadius(8.2); - - // Check that smallRing compared to overlapOuter returns 0 (overlap) - assertEquals(0, smallRing.compareTo(overlapOuter)); - - // Create a ring that overlaps both radii - Ring totalOverlap = new Ring(); - totalOverlap.setInnerRadius(5.7); - totalOverlap.setOuterRadius(8.3); - - // Check that smallRing compared to totalOverlap returns 0 (overlap) - assertEquals(0, smallRing.compareTo(totalOverlap)); - - } - - /** - *

- * Tests the equality operation of Rings. - *

- */ - @Test - public void checkEquality() { - - /* --- Check equality between like rings --------------------------- */ - - // Construct a ring (with a material) to test against - Ring ring = new Ring(); - Material material = new Material("Awfulness"); - ring.setName("Paula Nancy Millstone Jennings of Greenbridge, Essex"); - ring.setDescription("Worst poet in the universe"); - ring.setHeight(23.4); - ring.setInnerRadius(0.001); - ring.setOuterRadius(0.01); - ring.setMaterial(material); - - // Construct a ring (with material) equal to the first - Ring equalRing = new Ring(); - Material equalMaterial = new Material("Awfulness"); - equalRing - .setName("Paula Nancy Millstone Jennings of Greenbridge, Essex"); - equalRing.setDescription("Worst poet in the universe"); - equalRing.setHeight(23.4); - equalRing.setInnerRadius(0.001); - equalRing.setOuterRadius(0.01); - equalRing.setMaterial(equalMaterial); - - // Check that equals() is reflexive and symmetric - assertTrue(ring.equals(ring)); - assertTrue(ring.equals(equalRing) && equalRing.equals(ring)); - - // Check equals() fails with illegal rings - assertFalse(ring==null); - - /* --- Check transitivity with similar rings ----------------------- */ - - // Construct another ring equal to the first, for testing transitivity - Ring transRing = new Ring(); - Material transMaterial = new Material("Awfulness"); - transRing - .setName("Paula Nancy Millstone Jennings of Greenbridge, Essex"); - transRing.setDescription("Worst poet in the universe"); - transRing.setHeight(23.4); - transRing.setInnerRadius(0.001); - transRing.setOuterRadius(0.01); - transRing.setMaterial(transMaterial); - - // Check for transitivity - if (ring.equals(transRing) && transRing.equals(equalRing)) { - assertTrue(ring.equals(equalRing)); - } else { - fail(); - } - /* --- Check inequality between two dissimilar rings --------------- */ - - // Construct a ring (with a material) unequal to the first - Ring unequalRing = new Ring(); - Material unequalMaterial = new Material("Ickiness"); - unequalRing.setName("Grunthos the Flatulent"); - unequalRing.setDescription("Poetmaster of the Azgoths of Kria"); - unequalRing.setHeight(64.77); - unequalRing.setInnerRadius(10.222); - unequalRing.setOuterRadius(100.2); - unequalRing.setMaterial(unequalMaterial); - - // Check that ring and unequalRing are not the same - assertFalse(ring.equals(unequalRing)); - - /* --- Check hash values between equal and unequal rings ----------- */ - - assertEquals(ring.hashCode(), ring.hashCode()); - assertEquals(ring.hashCode(), equalRing.hashCode()); - assertFalse(ring.hashCode() == unequalRing.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations of Rings. - *

- */ - @Test - public void checkCopying() { - - /* --- Testing the copy operation ---------------------------------- */ - - // Create a ring (with material) to copy from - Ring ring = new Ring(); - Material material = new Material("Fleshy bits"); - ring.setName("Phouchg"); - ring.setDescription("Chosen to recieve DeepThought's answer"); - ring.setId(7001); - ring.setHeight(54.6); - ring.setInnerRadius(1.78); - ring.setOuterRadius(6.77); - ring.setMaterial(material); - - // Create an empty ring to copy to - Ring ringCopy = new Ring(); - - // Copy the contents of ring to ringCopy - ringCopy.copy(ring); - - // Check ring and ringCopy are identical - assertTrue(ring.equals(ringCopy)); - - // Try copying the contents of a null ring - ringCopy.copy(null); - - // Check to see that ringCopy remains unchanged - assertTrue(ringCopy.equals(ring)); - - /* --- Testing the cloning operation ------------------------------- */ - - // Clone the first ring - Object ringClone = ring.clone(); - - // Check that ringClone isn't null - assertNotNull(ringClone); - - // Check that ring and ringClone are identical - assertTrue(ringClone.equals(ring)); - - return; - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRAssemblyTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRAssemblyTester.java deleted file mode 100644 index f12231062..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRAssemblyTester.java +++ /dev/null @@ -1,271 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.eclipse.ice.reactor.sfr.core.AssemblyType; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRAssembly; -import org.junit.Test; - -/** - *

- * Tests the operations of the SFRAssembly class. - *

- * - * @author Anna Wojtowicz - */ -public class SFRAssemblyTester { - - /** - *

- * Tests the constructors and default values of the SFRAssembly class. - *

- * - */ - @Test - public void checkConstruction() { - - // An assembly to test. - SFRAssembly assembly; - - // Invalid, default, and valid values to use in the constructor. - int invalidSize = 0; - ; - int defaultSize = 1; - int size = 10; - - String nullName = null; - String emptyName = " "; - String defaultName = "SFR Assembly 1"; - String name = "Arthur"; - - AssemblyType invalidType = null; - AssemblyType defaultType = AssemblyType.Fuel; - AssemblyType type = AssemblyType.Control; - - // Other defaults. - String defaultDescription = "SFR Assembly 1's Description"; - int defaultId = 1; - double defaultDuctThickness = 0.0; - - /* ---- Test the basic constructor. ---- */ - // Invalid parameters. - assembly = new SFRAssembly(invalidSize); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - - // Valid parameters. - assembly = new SFRAssembly(size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - /* ------------------------------------- */ - - /* ---- Test the second constructor. ---- */ - // Invalid parameters. - - // All invalid. - assembly = new SFRAssembly(nullName, invalidType, invalidSize); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - - // Name invalid. - assembly = new SFRAssembly(emptyName, type, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(type, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - - // Type invalid. - assembly = new SFRAssembly(name, invalidType, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(defaultType, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - - // Size invalid. - assembly = new SFRAssembly(name, type, invalidSize); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(type, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - - // Valid parameters. - assembly = new SFRAssembly(name, type, size); - - assertEquals(defaultId, assembly.getId()); - assertEquals(name, assembly.getName()); - assertEquals(defaultDescription, assembly.getDescription()); - assertEquals(size, assembly.getSize()); - assertEquals(type, assembly.getAssemblyType()); - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - /* -------------------------------------- */ - - return; - } - - /** - *

- * Tests the getter and setter of SFRAssembly's ductThickness attribute. - *

- * - */ - @Test - public void checkDuctThickness() { - - SFRAssembly assembly = new SFRAssembly(1); - double defaultDuctThickness = 0.0; - - // Check the default. - assertEquals(defaultDuctThickness, assembly.getDuctThickness(), 0); - - // Set it to 1 and check it. - assembly.setDuctThickness(1.0); - assertEquals(1.0, assembly.getDuctThickness(), 0); - - // Set it to an invalid number. - assembly.setDuctThickness(-1.0); - assertEquals(1.0, assembly.getDuctThickness(), 0); - - // Set it to a valid number. - assembly.setDuctThickness(500); - assertEquals(500, assembly.getDuctThickness(), 0); - - return; - } - - /** - *

- * Tests the equality and hashCode operations. - *

- */ - @Test - public void checkEquality() { - - int size = 18; - String name = "So long, and thanks for all the fish!"; - - // Initialize objects for testing. - SFRAssembly object = new SFRAssembly(name, AssemblyType.Fuel, size); - SFRAssembly equalObject = new SFRAssembly(name, AssemblyType.Fuel, size); - SFRAssembly unequalObject = new SFRAssembly(name, AssemblyType.Control, - size); - - // Set up the object and equalObject. - object.setDuctThickness(17); - - equalObject.setDuctThickness(17); - - // Set up the unequalObject. - // (AssemblyType is different for unequalObject.) - unequalObject.setDuctThickness(17); - - // Make sure the references are different. - assertFalse(object == equalObject); - assertFalse(object == unequalObject); - assertFalse(equalObject == unequalObject); - - // Check that equality is reflexive and symmetric. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Check that equals will fail when it should. - assertFalse(object==null); - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Check the hash codes. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - assertFalse(object.hashCode() == unequalObject.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations. - *

- */ - @Test - public void checkCopying() { - - int size = 18; - String name = "So long, and thanks for all the fish!"; - - // Initialize objects for testing. - SFRAssembly object = new SFRAssembly(name, AssemblyType.Fuel, size); - SFRAssembly copy = new SFRAssembly(size); - SFRAssembly clone = null; - - // Set up the object. - object.setDuctThickness(17); - - // Make sure the objects are not equal before copying. - assertFalse(object == copy); - assertFalse(object.equals(copy)); - - // Copy the object. - copy.copy(object); - - // Make sure the references are different but contents the same. - assertFalse(object == copy); - assertTrue(object.equals(copy)); - - // Do the same for the clone operation. - - // Make sure the objects are not equal before copying. - assertFalse(object == clone); - assertFalse(object.equals(clone)); - - // Copy the object. - clone = (SFRAssembly) object.clone(); - - // Make sure the references are different but contents the same. - assertFalse(object == clone); - assertTrue(object.equals(clone)); - assertFalse(copy == clone); - assertTrue(copy.equals(clone)); - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRComponentTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRComponentTester.java deleted file mode 100644 index c85f8bf3c..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRComponentTester.java +++ /dev/null @@ -1,987 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ice.analysistool.IData; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.componentVisitor.SelectiveComponentVisitor; -import org.eclipse.ice.datastructures.test.TestComponentListener; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.base.SFRData; -import org.junit.Test; - -/** - *

- * Tests the operations of the SFRComponent class. - *

- * - * @author Anna Wojtowicz - */ -public class SFRComponentTester { - /** - *

- * Tests the constructors and default values of the SFRComponent class. - *

- * - */ - @Test - public void checkConstruction() { - - // We have two constructors to test: - // new SFRComponent(); - // new SFRComponent(String name); - - // Component variable used for testing the constructor. - SFRComponent component; - - /* ---- Test the nullary constructor. ---- */ - component = new SFRComponent(); - - // Test all of the getters for default values. - assertEquals("Component 1", component.getName()); - assertEquals(1, component.getId()); - assertEquals("Component 1's Description", component.getDescription()); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getNumberOfTimeSteps()); - assertEquals("No Source Information", component.getSourceInfo()); - assertNotNull(component.getTimes()); - assertTrue(component.getTimes().isEmpty()); - assertEquals("seconds", component.getTimeUnits()); - assertEquals(-1, component.getTimeStep(42)); - /* --------------------------------------- */ - - /* ---- Test a constructor with a String parameter. ---- */ - component = new SFRComponent("Arthur"); - - // Test all of the getters for default values. - assertEquals("Arthur", component.getName()); - assertEquals(1, component.getId()); - assertEquals("Component 1's Description", component.getDescription()); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getNumberOfTimeSteps()); - assertEquals("No Source Information", component.getSourceInfo()); - assertNotNull(component.getTimes()); - assertTrue(component.getTimes().isEmpty()); - assertEquals("seconds", component.getTimeUnits()); - assertEquals(-1, component.getTimeStep(3.14)); - /* ----------------------------------------------------- */ - - /* ---- Test a constructor with a bad (null) String parameter. ---- */ - component = new SFRComponent(null); - - // Test all of the getters for default values. - assertEquals("Component 1", component.getName()); - assertEquals(1, component.getId()); - assertEquals("Component 1's Description", component.getDescription()); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getNumberOfTimeSteps()); - assertEquals("No Source Information", component.getSourceInfo()); - assertNotNull(component.getTimes()); - assertTrue(component.getTimes().isEmpty()); - assertEquals("seconds", component.getTimeUnits()); - assertEquals(-1, component.getTimeStep(Double.MIN_VALUE)); - /* ---------------------------------------------------------------- */ - - /* ---- Test a constructor with a bad (empty) String parameter. ---- */ - component = new SFRComponent(""); - - // Test all of the getters for default values. - assertEquals("Component 1", component.getName()); - assertEquals(1, component.getId()); - assertEquals("Component 1's Description", component.getDescription()); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getNumberOfTimeSteps()); - assertEquals("No Source Information", component.getSourceInfo()); - assertNotNull(component.getTimes()); - assertTrue(component.getTimes().isEmpty()); - assertEquals("seconds", component.getTimeUnits()); - assertEquals(-1, component.getTimeStep(Double.MIN_VALUE)); - /* ----------------------------------------------------------------- */ - - return; - } - - /** - *

- * Tests the getters and setters for the name, description, id, sourceInfo - * and timeUnits attributes. - *

- * - */ - @Test - public void checkAttributes() { - - SFRComponent component = new SFRComponent(); - - // Set name, description, id, sourceInfo and timeUnit attributes - component.setName("Zaphod"); - component.setDescription("fooDescription"); - component.setId(1); - component.setSourceInfo("fooSource"); - component.setTimeUnits("fooSeconds"); - - // Check the name, description, id, sourceInfo and timeUnit attributes - assertEquals("Zaphod", component.getName()); - assertEquals("fooDescription", component.getDescription()); - assertEquals(1, component.getId()); - assertEquals("fooSource", component.getSourceInfo()); - assertEquals("fooSeconds", component.getTimeUnits()); - - // Set attributes to illegal values - component.setName(null); - component.setDescription(null); - component.setId(-1); - component.setSourceInfo(null); - component.setTimeUnits(null); - - // Check attributes, should remain unchanged - assertEquals("Zaphod", component.getName()); - assertEquals("fooDescription", component.getDescription()); - assertEquals(1, component.getId()); - assertEquals("fooSource", component.getSourceInfo()); - assertEquals("fooSeconds", component.getTimeUnits()); - - // Set string attributes to empty strings - component.setName(""); - component.setDescription(" "); - component.setSourceInfo(" "); - component.setTimeUnits(""); - - // Check string attributes, should remain unchanged - assertEquals("Zaphod", component.getName()); - assertEquals("fooDescription", component.getDescription()); - assertEquals("fooSource", component.getSourceInfo()); - assertEquals("fooSeconds", component.getTimeUnits()); - - // Set string attributes with leading/trailing whitespaces - component.setName(" Zaphod "); - component.setDescription(" fooDescription "); - component.setSourceInfo(" fooSource "); - component.setTimeUnits(" fooSeconds "); - - // Check string attributes for trimmed leading/trailing whitespaces - assertEquals("Zaphod", component.getName()); - assertEquals("fooDescription", component.getDescription()); - assertEquals("fooSource", component.getSourceInfo()); - assertEquals("fooSeconds", component.getTimeUnits()); - - return; - } - - /** - *

- * Test the addition and removal of SFRData from the SFRComponent. - *

- * - */ - @Test - public void checkDataAddRem() { - - // The component that we will be updating for this test. - SFRComponent component = new SFRComponent(); - - // Some pre-defined features, times, and IData objects. - String featOne = "Two heads"; - String featTwo = "Three arms"; - String featThree = "Ex-Galactic president"; - double timeOne = 1.5; - double timeTwo = 3.0; - double timeThree = 4.5; - SFRData dataOne = new SFRData(featOne); - SFRData dataTwo = new SFRData(featOne); - SFRData dataThree = new SFRData(featTwo); - SFRData dataFour = new SFRData(featThree); - - // Overall data information (these change when we add/remove - // timesteps/features). - int numberOfTimeSteps; - List times; - List featureList; - - // Time-/feature-specific information. - double currentTime; - int timeStep; - List featuresAtCurrentTime; - List dataAtCurrentTime; - List emptyData = new ArrayList(); - - /* ---- Check the overall information. ---- */ - numberOfTimeSteps = 0; - times = new ArrayList(); - featureList = new ArrayList(); - - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList, component.getFeatureList()); - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - currentTime = 0.0; - timeStep = -1; - featuresAtCurrentTime = new ArrayList(); - dataAtCurrentTime = new ArrayList(); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(emptyData, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Add IData to the component at t=1.5 - component.addData(dataOne, timeOne); - - /* ---- Check the overall information. ---- */ - numberOfTimeSteps++; - times.add(timeOne); - featureList.add(featOne); - - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(emptyData, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Update the current time. - component.setTime(timeOne); - - /* ---- Check the overall information. ---- */ - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - currentTime = timeOne; - timeStep = 0; - featuresAtCurrentTime.add(featOne); - dataAtCurrentTime = new ArrayList(); - dataAtCurrentTime.add(dataOne); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(dataAtCurrentTime, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Add another piece of IData to the component at t=1.5 - component.addData(dataTwo, timeOne); - - /* ---- Check the overall information. ---- */ - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - dataAtCurrentTime.add(dataTwo); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(dataAtCurrentTime, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Change current time to t=3.0 - component.setTime(timeTwo); - - /* ---- Check the overall information. ---- */ - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - currentTime = timeTwo; - timeStep = -1; - featuresAtCurrentTime = new ArrayList(); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(emptyData, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Add third piece of IData to component, at current time (t=3.0) - component.addData(dataThree, timeTwo); - - /* ---- Check the overall information. ---- */ - numberOfTimeSteps++; - times.add(timeTwo); - featureList.add(featTwo); - - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - timeStep = 1; - featuresAtCurrentTime.add(featTwo); - dataAtCurrentTime = new ArrayList(); - dataAtCurrentTime.add(dataThree); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(emptyData, component.getDataAtCurrentTime(featOne)); - assertEquals(dataAtCurrentTime, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Add fourth piece of IData to component, at t=4.5 - component.addData(dataFour, timeThree); - - /* ---- Check the overall information. ---- */ - numberOfTimeSteps++; - times.add(timeThree); - featureList.add(featThree); - - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(emptyData, component.getDataAtCurrentTime(featOne)); - assertEquals(dataAtCurrentTime, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Change current time to t=4.5 - component.setTime(timeThree); - - /* ---- Check the overall information. ---- */ - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - currentTime = timeThree; - timeStep = 2; - featuresAtCurrentTime = new ArrayList(); - featuresAtCurrentTime.add(featThree); - dataAtCurrentTime = new ArrayList(); - dataAtCurrentTime.add(dataFour); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(emptyData, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(dataAtCurrentTime, - component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Set the time to 1.5 and add dataFour. - component.setTime(timeOne); - component.addData(dataFour, timeOne); - - /* ---- Check the overall information. ---- */ - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - currentTime = timeOne; - timeStep = 0; - featuresAtCurrentTime = new ArrayList(); - featuresAtCurrentTime.add(featOne); - featuresAtCurrentTime.add(featThree); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime.size(), component - .getFeaturesAtCurrentTime().size()); - assertTrue(component.getFeaturesAtCurrentTime().containsAll( - featuresAtCurrentTime)); - - // Check the data for the features at this timestep. (dataOne and - // dataTwo for featOne, dataFour for featThree) - dataAtCurrentTime = new ArrayList(); - dataAtCurrentTime.add(dataOne); - dataAtCurrentTime.add(dataTwo); - assertEquals(dataAtCurrentTime, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - dataAtCurrentTime = new ArrayList(); - dataAtCurrentTime.add(dataFour); - assertEquals(dataAtCurrentTime, - component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Try to set invalid time - component.setTime(-1.0); - - // The time should not have changed. - assertEquals(currentTime, component.getCurrentTime(), 0); - - // Remove featThree IData from component - component.removeDataFromFeature(featThree); - - /* ---- Check the overall information. ---- */ - featureList.remove(featThree); - - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - featuresAtCurrentTime = new ArrayList(); - featuresAtCurrentTime.add(featOne); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. (dataOne and - // dataTwo for featOne, now empty for featThree) - dataAtCurrentTime = new ArrayList(); - dataAtCurrentTime.add(dataOne); - dataAtCurrentTime.add(dataTwo); - assertEquals(dataAtCurrentTime, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - - // Update the current time so we can check timeThree's data. - component.setTime(timeThree); - - currentTime = timeThree; - timeStep = 2; - featuresAtCurrentTime = new ArrayList(); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - assertEquals(emptyData, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Remove featTwo IData from component - component.removeDataFromFeature(featTwo); - - /* ---- Check the overall information. ---- */ - featureList.remove(featTwo); - - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - // Change time to t=3.0 - component.setTime(timeTwo); - - /* ---- Check the time-/feature-specific information. ---- */ - currentTime = timeTwo; - timeStep = 1; - featuresAtCurrentTime = new ArrayList(); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(emptyData, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - // Remove featOne IData from component - component.removeDataFromFeature(featOne); - - /* ---- Check the overall information. ---- */ - featureList.remove(featOne); - - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - // Change time to t=1.5 - component.setTime(timeOne); - - /* ---- Check the overall information. ---- */ - assertEquals(numberOfTimeSteps, component.getNumberOfTimeSteps()); - assertEquals(times, component.getTimes()); - assertEquals(featureList.size(), component.getFeatureList().size()); - for (String feature : featureList) { - assertTrue(component.getFeatureList().contains(feature)); - } - /* ---------------------------------------- */ - - /* ---- Check the time-/feature-specific information. ---- */ - currentTime = timeOne; - timeStep = 0; - featuresAtCurrentTime = new ArrayList(); - - assertEquals(currentTime, component.getCurrentTime(), 0); - assertEquals(timeStep, component.getTimeStep(currentTime)); - assertEquals(featuresAtCurrentTime, - component.getFeaturesAtCurrentTime()); - - // Check the data for the features at this timestep. - assertEquals(emptyData, component.getDataAtCurrentTime(featOne)); - assertEquals(emptyData, component.getDataAtCurrentTime(featTwo)); - assertEquals(emptyData, component.getDataAtCurrentTime(featThree)); - /* ------------------------------------------------------- */ - - /* ---- Check adding data in a different order. ---- */ - - // Initialize three components: one component, one which will have data - // added in the same order, and one with data added in another order. - component = new SFRComponent(); - SFRComponent sameOrder = new SFRComponent(); - SFRComponent diffOrder = new SFRComponent(); - - // At this point, they are all the same. - assertEquals(component, sameOrder); - assertEquals(component, diffOrder); - - // Create some data with different features to add. - SFRData data1 = new SFRData("feature1"); - SFRData data2 = new SFRData("feature2"); - SFRData data3 = new SFRData("feature3"); - SFRData data4 = new SFRData("feature4"); - - // Add the data to the component. - component.addData(data1, 0.0); - component.addData(data2, 0.0); - component.addData(data3, 0.0); - component.addData(data4, 0.0); - - // Add the data in the same order to another component. - sameOrder.addData(data1, 0.0); - sameOrder.addData(data2, 0.0); - sameOrder.addData(data3, 0.0); - sameOrder.addData(data4, 0.0); - - // Add the data in a different order to another component. - diffOrder.addData(data1, 0.0); - diffOrder.addData(data4, 0.0); - diffOrder.addData(data2, 0.0); - diffOrder.addData(data3, 0.0); - - // Check the list of feature names. - assertEquals(component.getFeatureList(), sameOrder.getFeatureList()); - assertEquals(component.getFeatureList(), diffOrder.getFeatureList()); - - // Check the list of feature names at the current time. - assertEquals(component.getFeaturesAtCurrentTime(), - sameOrder.getFeaturesAtCurrentTime()); - assertEquals(component.getFeaturesAtCurrentTime(), - diffOrder.getFeaturesAtCurrentTime()); - - // Check the contents of the feature at the current time. - for (int i = 1; i <= 4; i++) { - String feature = "feature" + i; - - // Check the size and contents. - assertEquals(component.getDataAtCurrentTime(feature).size(), - sameOrder.getDataAtCurrentTime(feature).size()); - assertTrue(sameOrder.getDataAtCurrentTime(feature).containsAll( - component.getDataAtCurrentTime(feature))); - - assertEquals(component.getDataAtCurrentTime(feature).size(), - diffOrder.getDataAtCurrentTime(feature).size()); - assertTrue(diffOrder.getDataAtCurrentTime(feature).containsAll( - component.getDataAtCurrentTime(feature))); - } - - // The components should all still be equal! - assertEquals(component, sameOrder); - assertEquals(component, diffOrder); - /* ------------------------------------------------- */ - - return; - } - - /** - *

- * Tests the visitation of ISFRComponentVisitors in the SFRComponent. - *

- * - */ - @Test - public void checkVisitation() { - - // Create a new SFRComponent to visit. - SFRComponent component = new SFRComponent("Marvin"); - - // Create a fake visitor that stores a reference to the visited - // IReactorComponent. - FakeComponentVisitor visitor = null; - - // Try accepting an invalid visitor. - component.accept(visitor); - - // Initialize the visitor and get its current component (null). - visitor = new FakeComponentVisitor(); - Object visitedObject = visitor.getComponent(); - - // Make sure the component and the [un]visited object are not equal. - assertFalse(component.equals(visitedObject)); - - // Try accepting the fake component visitor. - component.accept(visitor); - visitedObject = visitor.getComponent(); - - // See if the visited component from the visitor is the same component - // that we initially created. - assertTrue(component == visitedObject); - assertTrue(component.equals(visitedObject)); - - return; - } - - /** - *

- * Tests the equality operation of SFRComponents. - *

- * - */ - @Test - public void checkEquality() { - - // Construct a component to test against - SFRComponent component = new SFRComponent("Earth"); - component.setDescription("Mostly Harmless"); - component.setId(10); - - // Construct a component equal to the first - SFRComponent equalComponent = new SFRComponent("Earth"); - equalComponent.setDescription("Mostly Harmless"); - equalComponent.setId(10); - - // Construct a component not equal to the first - SFRComponent unequalComponent = new SFRComponent("Betelgeuse 5"); - unequalComponent.setDescription("Suspiciously Shifty"); - unequalComponent.setId(5); - - // Check that component and unequalComponet are not the same - assertFalse(component.equals(unequalComponent)); - assertFalse(unequalComponent.equals(component)); - - // Check that equality also fails with illegal values - assertFalse(component == null); - assertFalse(component.equals(42)); - assertFalse("just a string".equals(component)); - - // Check is equals() is reflexive and symmetric - assertTrue(component.equals(component)); - assertTrue(component.equals(equalComponent) - && equalComponent.equals(component)); - - // Construct a component equal to the first, for testing transitivity - SFRComponent transComponent = new SFRComponent("Earth"); - transComponent.setDescription("Mostly Harmless"); - transComponent.setId(10); - - // Check equals is transitive() - if (component.equals(transComponent) - && transComponent.equals(equalComponent)) { - assertTrue(component.equals(equalComponent)); - } else { - fail(); - } - // Check the hashCode values. - assertEquals(component.hashCode(), component.hashCode()); - assertEquals(component.hashCode(), equalComponent.hashCode()); - assertFalse(component.hashCode() == unequalComponent.hashCode()); - - // FIXME - We might also want to test components where the datasets - // are/aren't different. - - return; - } - - /** - *

- * Tests the copying and cloning operation of SFRComponents. - *

- * - */ - @Test - public void checkCopying() { - - // Construct a base component to copy from - SFRComponent component = new SFRComponent("Ford Prefect"); - component.setDescription("Out-of-work actor from Guildford"); - component.setId(30); - - /* ---- Check copying. ---- */ - // Construct an empty component to copy to - SFRComponent componentCopy = new SFRComponent(); - - // Check that component and componentCopy are not identical yet - assertFalse(component == componentCopy); - assertFalse(component.equals(componentCopy)); - - // Copy contents over - componentCopy.copy(component); - - // Check component and componentCopy are identical - assertTrue(component.equals(componentCopy)); - - // Try to copy contents of an invalid component - componentCopy.copy(null); - - // Check that componentCopy remains unchanged - assertTrue(component.equals(componentCopy)); - - // Make sure they are still different references! - assertFalse(component == componentCopy); - /* ------------------------ */ - - /* ---- Check cloning. ---- */ - // Get a clone of the original component. - Object objectClone = component.clone(); - - // Make sure it's not null! - assertNotNull(objectClone); - - // Make sure the reference is different but the contents are equal. - assertFalse(component == objectClone); - assertTrue(component.equals(objectClone)); - assertFalse(componentCopy == objectClone); - assertTrue(componentCopy.equals(objectClone)); - - // Make sure the object is an instance of SFRComponent. - assertTrue(objectClone instanceof SFRComponent); - - // Cast the component. - SFRComponent componentClone = (SFRComponent) component.clone(); - - // Check the components one last time for good measure. - assertFalse(component == componentClone); - assertTrue(component.equals(componentClone)); - /* ------------------------ */ - - return; - } - - /** - *

- * Tests the notifyListeners method of SFRComponents. - *

- */ - @Test - public void checkNotifications() { - - // Create a new component to listen to. - SFRComponent component = new SFRComponent("Tricia McMillan"); - SFRComponent component2 = new SFRComponent(); - - // All methods that should notify listeners: - // component.addData(SFRData, double) - // component.copy(SFRComponent) - // component.removeDataFromFeature(String) - // component.setDescription(String) - // component.setId(int) - // component.setName(String) - // component.setSourceInfo(String) - // component.setTime(double) - // component.setTimeUnits(String) - - // All of these methods are tested at some point below. - - // Create a test listener and register it with the component. - TestComponentListener listener1 = new TestComponentListener(); - component.register(listener1); - - // The setter should notify the only listener. - component.addData(new SFRData("Heart of Gold"), 1.5); - assertTrue(listener1.wasNotified()); - listener1.reset(); - - // The setter should notify the only listener. - component.setDescription("Arthur's love interest?"); - assertTrue(listener1.wasNotified()); - listener1.reset(); - - // The setter should notify the only listener. - component.setId(42); - assertTrue(listener1.wasNotified()); - listener1.reset(); - - // The setter should notify the only listener. - component.setName("Trillian"); - assertTrue(listener1.wasNotified()); - listener1.reset(); - - // Create a new listener and register it with the original component. - TestComponentListener listener2 = new TestComponentListener(); - component.register(listener2); - - // The setter should notify both listeners. - component.setSourceInfo("Earth"); - assertTrue(listener1.wasNotified()); - listener1.reset(); - assertTrue(listener2.wasNotified()); - listener2.reset(); - - // The setter should notify both listeners. - component.setTime(1.5); - assertTrue(listener1.wasNotified()); - listener1.reset(); - assertTrue(listener2.wasNotified()); - listener2.reset(); - - // The copy operation should notify both listeners. - component2.copy(component); - assertTrue(listener1.wasNotified()); - listener1.reset(); - assertTrue(listener2.wasNotified()); - listener2.reset(); - - // Create a new listener and register it with the component copy. - TestComponentListener listener3 = new TestComponentListener(); - component2.register(listener3); - - // The component copy should notify listeners 1, 2, and 3. - component2.setTimeUnits("tea"); - assertTrue(listener1.wasNotified()); - listener1.reset(); - assertTrue(listener2.wasNotified()); - listener2.reset(); - assertTrue(listener3.wasNotified()); - listener3.reset(); - - // Test removeDataFromFeature. The original component should only notify - // listeners 1 and 2. - component.removeDataFromFeature("Heart of Gold"); - assertTrue(listener1.wasNotified()); - listener1.reset(); - assertTrue(listener2.wasNotified()); - listener2.reset(); - - // Listener3 is NOT supposed to be notified. However, attempts to test - // this behavior have proved unsuccessful: the CountDownLatch.await() - // operation in listener.wasNotified() does not always wait, so we can - // never tell if it succeeded or if JUnit decided it should not run. - // assertFalse(listener3.wasNotified()); - // listener3.reset(); - - return; - } - - /** - * This is a fake visitor class to test the accept(IComponentVisitor) method - * of SFRComponent. - * - * @author Jordan H. Deyton - * - */ - private class FakeComponentVisitor extends SelectiveComponentVisitor { - private IReactorComponent component = null; - - protected IReactorComponent getComponent() { - return component; - } - - @Override - public void visit(IReactorComponent component) { - this.component = component; - } - }; -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRCompositeTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRCompositeTester.java deleted file mode 100644 index 2d66f0641..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRCompositeTester.java +++ /dev/null @@ -1,457 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.base.SFRComposite; -import org.junit.Test; - -/** - *

- * Tests the operations of the SFRComposite class. - *

- * - * @author Anna Wojtowicz - */ -public class SFRCompositeTester { - - // FIXME - Removed checkComponent() - - /** - *

- * Tests the constructor and default values of the SFRComposite class. - *

- * - */ - @Test - public void checkConstruction() { - - SFRComposite composite = new SFRComposite(); - - // SFRComposite extends SFRComponent, so we need to check the defaults - // for SFRComponent AND the features that SFRComposite adds. - - // SFRComponent default check. - // composite.getCurrentTime(); - // composite.getDataAtCurrentTime("feature"); - assertEquals("Composite 1's Description", composite.getDescription()); - // composite.getFeatureList(); - // composite.getFeaturesAtCurrentTime(); - assertEquals(1, composite.getId()); - assertEquals("Composite 1", composite.getName()); - // composite.getNumberOfTimeSteps(); - // composite.getSourceInfo(); - // composite.getTimes(); - // composite.getTimeStep(0.0); - // composite.getTimeUnit(); - // composite.getTimeUnits(); - - // SFRComposite default check. (We initialize the list of components!) - // composite.getComponent("name"); - // composite.getComponent(0); - assertNotNull(composite.getComponentNames()); - assertTrue(composite.getComponentNames().isEmpty()); - assertNotNull(composite.getComponents()); - assertTrue(composite.getComponents().isEmpty()); - assertEquals(0, composite.getNumberOfComponents()); - - return; - } - - /** - *

- * Tests the addition and removal of components from the SFRComposite. - *

- * - */ - @Test - public void checkComponentAddRem() { - - // Initialize a Composite for testing. - SFRComposite composite = new SFRComposite(); - - Component component; - ArrayList components; - ArrayList componentNames; - - /* ---- Make sure the list of components is empty. ---- */ - // This method should return zero. - assertEquals(0, composite.getNumberOfComponents()); - - // The component list should be empty. - components = composite.getComponents(); - assertNotNull(components); - assertTrue(components.isEmpty()); - - // The component name list should also be empty. - componentNames = composite.getComponentNames(); - assertNotNull(componentNames); - assertTrue(componentNames.isEmpty()); - /* ---------------------------------------------------- */ - - /* ---- Add a single component and check getting and removing. ---- */ - SFRComponent defaultComponent = new SFRComponent(); - String defaultName = defaultComponent.getName(); - int defaultId = defaultComponent.getId(); - - // Make sure defaultComponent is not in the list yet. - assertNull(composite.getComponent(defaultName)); - - // Add defaultComponent to the list. - composite.addComponent(defaultComponent); - - /* -- Make sure defaultComponent is the only one in the list. -- */ - // Check getComponent(int childId) - component = composite.getComponent(defaultId); - assertNotNull(component); - assertSame(defaultComponent, component); - - // Check getComponent(String name) - component = composite.getComponent(defaultName); - assertNotNull(component); - assertSame(defaultComponent, component); - - // Check the component list. - components = composite.getComponents(); - assertNotNull(components); - assertEquals(1, components.size()); - assertSame(defaultComponent, components.get(0)); - - // Check the component names list. - componentNames = composite.getComponentNames(); - assertNotNull(componentNames); - assertEquals(1, componentNames.size()); - assertEquals(defaultName, componentNames.get(0)); - /* -- ------------------------------------------------------- -- */ - - // Remove the component with removeComponent(int childId). - composite.removeComponent(defaultId); - - // The component list should be empty. - components = composite.getComponents(); - assertNotNull(components); - assertTrue(components.isEmpty()); - - // The component name list should also be empty. - componentNames = composite.getComponentNames(); - assertNotNull(componentNames); - assertTrue(componentNames.isEmpty()); - assertNull(composite.getComponent(defaultId)); - assertNull(composite.getComponent(defaultName)); - - // Re-add the component. - composite.addComponent(defaultComponent); - - /* -- Make sure defaultComponent is the only one in the list. -- */ - // Check getComponent(int childId) - component = composite.getComponent(defaultId); - assertNotNull(component); - assertSame(defaultComponent, component); - - // Check getComponent(String name) - component = composite.getComponent(defaultName); - assertNotNull(component); - assertSame(defaultComponent, component); - - // Check the component list. - components = composite.getComponents(); - assertNotNull(components); - assertEquals(1, components.size()); - assertSame(defaultComponent, components.get(0)); - - // Check the component names list. - componentNames = composite.getComponentNames(); - assertNotNull(componentNames); - assertEquals(1, componentNames.size()); - assertEquals(defaultName, componentNames.get(0)); - /* -- ------------------------------------------------------- -- */ - - // Remove the component with removeComponent(String name). - composite.removeComponent(defaultName); - - // The component list should be empty. - components = composite.getComponents(); - assertNotNull(components); - assertTrue(components.isEmpty()); - - // The component name list should also be empty. - componentNames = composite.getComponentNames(); - assertNotNull(componentNames); - assertTrue(componentNames.isEmpty()); - assertNull(composite.getComponent(defaultId)); - assertNull(composite.getComponent(defaultName)); - - /* ---------------------------------------------------------------- */ - - /* ---- Make sure the list of components is empty. ---- */ - // This method should return zero. - assertEquals(0, composite.getNumberOfComponents()); - - // The component list should be empty. - components = composite.getComponents(); - assertNotNull(components); - assertTrue(components.isEmpty()); - - // The component name list should also be empty. - componentNames = composite.getComponentNames(); - assertNotNull(componentNames); - assertTrue(componentNames.isEmpty()); - /* ---------------------------------------------------- */ - - /* ---- Add multiple components and check getting and removing. ---- */ - SFRComponent component1 = new SFRComponent("Leonardo"); - SFRComponent component2 = new SFRComponent("Raphael"); - SFRComponent component3 = new SFRComponent("Donatello"); - SFRComponent component4 = new SFRComponent("Michelangelo"); - - // Set their IDs to non-default IDs, otherwise who knows what - // composite.getComponent(int childId) will return. - component1.setId(10); - component2.setId(20); - component3.setId(30); - component4.setId(40); - - // Add all four components. - composite.addComponent(component1); - composite.addComponent(component2); - composite.addComponent(component3); - composite.addComponent(component4); - - /* -- Make sure all four components are in the list. -- */ - // Check getComponent(int childId) - component = composite.getComponent(component1.getName()); - assertNotNull(component); - assertSame(component1, component); - - // Check getComponent(String name) - component = composite.getComponent("Raphael"); - assertNotNull(component); - assertSame(component2, component); - - // Check getComponent(int childId) - component = composite.getComponent(component3.getId()); - assertNotNull(component); - assertSame(component3, component); - - // Check getComponent(String name) - component = composite.getComponent("Michelangelo"); - assertNotNull(component); - assertSame(component4, component); - - // Check the component list. - components = composite.getComponents(); - assertNotNull(components); - assertEquals(4, components.size()); - assertTrue(components.contains(component1)); - assertTrue(components.contains(component2)); - assertTrue(components.contains(component3)); - assertTrue(components.contains(component4)); - - // Check the component names list. - componentNames = composite.getComponentNames(); - assertNotNull(componentNames); - assertEquals(4, componentNames.size()); - assertTrue(componentNames.contains("Leonardo")); - assertTrue(componentNames.contains("Raphael")); - assertTrue(componentNames.contains("Donatello")); - assertTrue(componentNames.contains("Michelangelo")); - /* -- ---------------------------------------------- -- */ - /* ----------------------------------------------------------------- */ - - /* ---- Check adding/getting/removing nulls. ---- */ - composite.addComponent(null); - - // Make sure the components haven't changed. - assertEquals(4, composite.getNumberOfComponents()); - assertSame(component1, composite.getComponent("Leonardo")); - assertSame(component2, composite.getComponent("Raphael")); - assertSame(component3, composite.getComponent("Donatello")); - assertSame(component4, composite.getComponent("Michelangelo")); - - assertNull(composite.getComponent(null)); - composite.removeComponent(null); - - // Make sure the components haven't changed. - assertEquals(4, composite.getNumberOfComponents()); - assertSame(component1, composite.getComponent("Leonardo")); - assertSame(component2, composite.getComponent("Raphael")); - assertSame(component3, composite.getComponent("Donatello")); - assertSame(component4, composite.getComponent("Michelangelo")); - /* ---------------------------------------------- */ - - /* ---- Check getting/removing invalid IDs. ---- */ - assertNull(composite.getComponent(1984)); - composite.removeComponent(1984); - - // Make sure the components haven't changed. - assertEquals(4, composite.getNumberOfComponents()); - assertSame(component1, composite.getComponent("Leonardo")); - assertSame(component2, composite.getComponent("Raphael")); - assertSame(component3, composite.getComponent("Donatello")); - assertSame(component4, composite.getComponent("Michelangelo")); - /* --------------------------------------------- */ - - /* ---- Check getting/removing invalid Strings. ---- */ - assertNull(composite.getComponent("Shredder")); - composite.removeComponent("Shredder"); - - // Make sure the components haven't changed. - assertEquals(4, composite.getNumberOfComponents()); - assertSame(component1, composite.getComponent("Leonardo")); - assertSame(component2, composite.getComponent("Raphael")); - assertSame(component3, composite.getComponent("Donatello")); - assertSame(component4, composite.getComponent("Michelangelo")); - /* ------------------------------------------------- */ - - /* ---- Check adding a component with a used name. ---- */ - component = new SFRComponent("Donatello"); - - // Make absolutely sure there are two "Donatello" components. - assertNotSame(component, component3); - - // Add the component. - composite.addComponent(component); - - // We shouldn't get a result because there's already a component with - // the name "Donatello". - assertNull(composite.getComponent(component.getId())); - assertNotSame(component, composite.getComponent("Donatello")); - - // Make sure the components haven't changed. - assertEquals(4, composite.getNumberOfComponents()); - assertSame(component1, composite.getComponent("Leonardo")); - assertSame(component2, composite.getComponent("Raphael")); - assertSame(component3, composite.getComponent("Donatello")); - assertSame(component4, composite.getComponent("Michelangelo")); - /* ---------------------------------------------------- */ - - return; - } - - /** - *

- * Tests the equality and hashCode operations. - *

- */ - @Test - public void checkEquality() { - - // Initialize objects for testing. - SFRComposite object = new SFRComposite(); - SFRComposite equalObject = new SFRComposite(); - SFRComposite unequalObject = new SFRComposite(); - - // Set up the object and equalObject. - object.setName("Earth"); - object.setDescription("Mostly Harmless"); - object.setSourceInfo("Mice made it"); - object.addComponent(new SFRComponent("Arthur")); - object.addComponent(new SFRComponent("Trillian")); - - equalObject.setName("Earth"); - equalObject.setDescription("Mostly Harmless"); - equalObject.setSourceInfo("Mice made it"); - equalObject.addComponent(new SFRComponent("Arthur")); - equalObject.addComponent(new SFRComponent("Trillian")); - - // Set up the unequalObject. - unequalObject.setName("Earth"); - unequalObject.setDescription("Mostly Harmless"); - unequalObject.setSourceInfo("Mice made it"); - unequalObject.addComponent(new SFRComponent("Arthur")); - - // Make sure the references are different. - assertFalse(object == equalObject); - assertFalse(object == unequalObject); - assertFalse(equalObject == unequalObject); - - // Check that equality is reflexive and symmetric. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Check that equals will fail when it should. - assertFalse(object==null); - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Check the hash codes. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - assertFalse(object.hashCode() == unequalObject.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations. - *

- */ - @Test - public void checkCopying() { - - // Initialize objects for testing. - SFRComposite object = new SFRComposite(); - SFRComposite copy = new SFRComposite(); - SFRComposite clone = null; - - // Set up the object. - object.setName("Earth"); - object.setDescription("Mostly Harmless"); - object.setSourceInfo("Mice made it"); - object.addComponent(new SFRComponent("Arthur")); - object.addComponent(new SFRComponent("Trillian")); - - // Make sure the objects are not equal before copying. - assertFalse(object == copy); - assertFalse(object.equals(copy)); - - // Copy the object. - copy.copy(object); - - // Make sure the references are different but contents the same. - assertFalse(object == copy); - assertTrue(object.equals(copy)); - - // Do the same for the clone operation. - - // Make sure the objects are not equal before copying. - assertFalse(object == clone); - assertFalse(object.equals(clone)); - - // Copy the object. - clone = (SFRComposite) object.clone(); - - // Make sure the references are different but contents the same. - assertFalse(object == clone); - assertTrue(object.equals(clone)); - assertFalse(copy == clone); - assertTrue(copy.equals(clone)); - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRDataTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRDataTester.java deleted file mode 100644 index 3d34a1788..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRDataTester.java +++ /dev/null @@ -1,491 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ice.reactor.sfr.base.SFRData; -import org.junit.Test; - -/** - *

- * Tests the operations of the SFRData class. - *

- * - * @author Anna Wojtowicz - */ -public class SFRDataTester { - - /** - *

- * Tests the constructors and default values of the SFRData class. - *

- * - */ - @Test - public void checkConstruction() { - - SFRData data; - - // Default values: - String feature = "Feature 1"; - - List position = new ArrayList(3); - position.add(0.0); - position.add(0.0); - position.add(0.0); - - double uncertainty = 0.0; - String units = "seconds"; - double value = 0.0; - - /* ---- Check nullary constructor. ---- */ - data = new SFRData(); - - assertEquals(feature, data.getFeature()); - assertEquals(position, data.getPosition()); - assertEquals(uncertainty, data.getUncertainty(), 0); - assertEquals(units, data.getUnits()); - assertEquals(value, data.getValue(), 0); - /* ------------------------------------ */ - - /* ---- Check feature-based constructor. ---- */ - data = new SFRData("Infinite Improbability Device"); - - assertEquals("Infinite Improbability Device", data.getFeature()); - assertEquals(position, data.getPosition()); - assertEquals(uncertainty, data.getUncertainty(), 0); - assertEquals(units, data.getUnits()); - assertEquals(value, data.getValue(), 0); - /* ------------------------------------------ */ - - /* ---- Check invalid constructor (null). ---- */ - data = new SFRData(null); - - assertEquals(feature, data.getFeature()); - assertEquals(position, data.getPosition()); - assertEquals(uncertainty, data.getUncertainty(), 0); - assertEquals(units, data.getUnits()); - assertEquals(value, data.getValue(), 0); - /* ------------------------------------------- */ - - /* ---- Check invalid constructor (blank). ---- */ - data = new SFRData(" "); - - assertEquals(feature, data.getFeature()); - assertEquals(position, data.getPosition()); - assertEquals(uncertainty, data.getUncertainty(), 0); - assertEquals(units, data.getUnits()); - assertEquals(value, data.getValue(), 0); - /* -------------------------------------------- */ - - return; - } - - /** - *

- * Tests the getter and setter of the value attribute. - *

- * - */ - @Test - public void checkValue() { - - // Initialize a new SFRData. - SFRData data = new SFRData(); - - // Check the default value. - double value = 0.0; - assertEquals(value, data.getValue(), 0); - data.setValue(0.0); - assertEquals(value, data.getValue(), 0); - - // Update the value. - value = 42.0; - data.setValue(42.0); - assertEquals(value, data.getValue(), 0); - - // Try setting it to some big values. - value = Double.MAX_VALUE; - data.setValue(Double.MAX_VALUE); - assertEquals(value, data.getValue(), 0); - - // Try setting it to some really small values. - value = Double.MIN_VALUE; - data.setValue(Double.MIN_VALUE); - assertEquals(value, data.getValue(), 0); - - return; - } - - /** - *

- * Tests the getter and setter for the uncertainty attribute. - *

- * - */ - @Test - public void checkUncertainty() { - - // Initialize a new SFRData. - SFRData data = new SFRData(); - - // Check the default uncertainty. - double uncertainty = 0.0; - assertEquals(uncertainty, data.getUncertainty(), 0); - data.setUncertainty(0.0); - assertEquals(uncertainty, data.getUncertainty(), 0); - - // Update the value. - uncertainty = 42.0; - data.setUncertainty(42.0); - assertEquals(uncertainty, data.getUncertainty(), 0); - - // Try setting it to some big values. - uncertainty = Double.MAX_VALUE; - data.setUncertainty(Double.MAX_VALUE); - assertEquals(uncertainty, data.getUncertainty(), 0); - - // Try setting it to some really small values. - uncertainty = Double.MIN_VALUE; - data.setUncertainty(Double.MIN_VALUE); - assertEquals(uncertainty, data.getUncertainty(), 0); - - return; - } - - /** - *

- * Tests the getter and setter of the units attribute. - *

- * - */ - @Test - public void checkUnits() { - - // Initialize a new SFRData. - SFRData data = new SFRData(); - - String defaultString = "seconds"; - String normalString = "minutes"; - String emptyString = ""; - String whitespaceString = " "; - String normalStringPlus = " minutes "; - - // Check the default. - assertEquals(defaultString, data.getUnits()); - - // Check setting it to a null String. - data.setUnits(null); - assertEquals(defaultString, data.getUnits()); - - // Check setting it to an empty String. - data.setUnits(emptyString); - assertEquals(defaultString, data.getUnits()); - - // Check setting it to a String with whitespace only. - data.setUnits(whitespaceString); - assertEquals(defaultString, data.getUnits()); - - // Check setting it to a normal String. - data.setUnits(normalString); - assertEquals(normalString, data.getUnits()); - - // Revert it to default temporarily. - data.setUnits(defaultString); - assertEquals(defaultString, data.getUnits()); - - // Check setting it to a normal String with whitespace. - data.setUnits(normalStringPlus); - assertEquals(normalString, data.getUnits()); - - return; - } - - /** - *

- * Tests the getter and setter of the feature attribute. - *

- * - */ - @Test - public void checkFeature() { - - // Initialize a new SFRData. - SFRData data = new SFRData(); - - String defaultString = "Feature 1"; - String normalString = "Dimensions Traversed"; - String emptyString = ""; - String whitespaceString = " "; - String normalStringPlus = " Dimensions Traversed "; - - // Check the default. - assertEquals(defaultString, data.getFeature()); - - // Check setting it to a null String. - data.setFeature(null); - assertEquals(defaultString, data.getFeature()); - - // Check setting it to an empty String. - data.setFeature(emptyString); - assertEquals(defaultString, data.getFeature()); - - // Check setting it to a String with whitespace only. - data.setFeature(whitespaceString); - assertEquals(defaultString, data.getFeature()); - - // Check setting it to a normal String. - data.setFeature(normalString); - assertEquals(normalString, data.getFeature()); - - // Revert it to default temporarily. - data.setFeature(defaultString); - assertEquals(defaultString, data.getFeature()); - - // Check setting it to a normal String with whitespace. - data.setFeature(normalStringPlus); - assertEquals(normalString, data.getFeature()); - - return; - } - - /** - *

- * Tests the getter and setter for the position attribute. - *

- * - */ - @Test - public void checkPosition() { - - // Initialize a new SFRData. - SFRData data = new SFRData(); - - // Initialize the default position. - ArrayList defaultPosition = new ArrayList(); - defaultPosition.add(0.0); - defaultPosition.add(0.0); - defaultPosition.add(0.0); - - // Make sure the default position is set. - assertEquals(defaultPosition, data.getPosition()); - - // Initialize a non-default position. - ArrayList position = new ArrayList(); - - // Add a position value. The list size is 1 and should not change the - // data's position. - position.add(1.0); - data.setPosition(position); - assertEquals(defaultPosition, data.getPosition()); - - // Add a position value. The list size is 2 and should not change the - // data's position. - position.add(-1.0); - data.setPosition(position); - assertEquals(defaultPosition, data.getPosition()); - - // Add a position value. The list size is 3 and should change the data's - // position. - position.add(-1.0); - data.setPosition(position); - assertEquals(position, data.getPosition()); - - // Add a fourth position value. The list size is 4 and should not change - // the data's position. - position.add(-1.0); - data.setPosition(position); - assertFalse(position.equals(data.getPosition())); - assertEquals(position.subList(0, 3), data.getPosition()); - - // Remove the fourth element from our position. - position.remove(3); - assertEquals(position, data.getPosition()); - - // Set it to an empty ArrayList. This should not change the position. - data.setPosition(new ArrayList()); - assertEquals(position, data.getPosition()); - - // Set it to null. This should not change the position. - data.setPosition(null); - assertEquals(position, data.getPosition()); - - return; - } - - /** - *

- * Tests the equality operation of SFRData. - *

- */ - @Test - public void checkEquality() { - - SFRData object, equalObject, unequalObject, invalidObject; - - // Some values for loading into the data. - String units = "mouse brain"; - double value = 1.0; - double uncertainty = 0.0; - ArrayList position = new ArrayList(); - position.add(1.0); - position.add(2.0); - position.add(3.0); - - // Set the information for the initial data. - object = new SFRData("Mouse"); - object.setUnits(units); - object.setValue(value); - object.setUncertainty(uncertainty); - object.setPosition(position); - - // Set the information for the equal data. - equalObject = new SFRData("Mouse"); - equalObject.setUnits(units); - equalObject.setValue(value); - equalObject.setUncertainty(uncertainty); - equalObject.setPosition(position); - - // Set the information for the unequal data. - unequalObject = new SFRData("Human"); - unequalObject.setUnits(units); - unequalObject.setValue(0.5); - unequalObject.setUncertainty(0.25); - unequalObject.setPosition(position); - - // Set the information for an invalid SFRData. - invalidObject = new SFRData(null); - invalidObject.setUnits(units); - invalidObject.setValue(value); - invalidObject.setUncertainty(uncertainty); - invalidObject.setPosition(position); - - // Test reflexivity and symmetry. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Test hash code equality. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - - // Test inequality. - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Test hash code inequality. - assertFalse(object.hashCode() == unequalObject.hashCode()); - - // Test inequality with invalid objects. - assertFalse(object.equals(invalidObject)); - assertFalse(invalidObject.equals(object)); - - // Test inequality with null values - assertFalse(object==null); - assertFalse(equalObject==null); - assertFalse(unequalObject==null); - assertFalse(invalidObject==null); - - // Test inequality with bad values. - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - - return; - } - - /** - *

- * Tests the copying and cloning methods of SFRData. - *

- */ - @Test - public void checkCopying() { - - String feature = "Acceleration"; - String units = "ft/s/s"; - double value = 32.0; - - // Create a new SFRData with some special features and data. - SFRData object = new SFRData("Bowl of petunias"); - object.setFeature(feature); - object.setUnits(units); - object.setValue(value); - - ArrayList position = new ArrayList(); - position.add(42.0); - position.add(42000.0); - position.add(84.0); - object.setPosition(position); - - // Create objects for copying/cloning. - SFRData copiedObject = new SFRData("Sperm whale"); - SFRData clonedObject = null; - - /* ---- Test passing in bad arguments to copy. ---- */ - object.copy(null); - - // Make sure we didn't clobber the old contents of object. - assertTrue(object.getFeature().equals(feature)); - assertTrue(object.getUnits().equals(units)); - assertTrue(object.getValue() == value); - assertTrue(object.getPosition().equals(position)); - /* ------------------------------------------------ */ - - /* ---- Test copying. ---- */ - // Make sure these are different objects beforehand! - assertFalse(object == copiedObject); - assertFalse(object.equals(copiedObject)); - - // Copy the contents of object into copiedObject. - copiedObject.copy(object); - - // Make sure they are still different references but have the same info. - assertFalse(object == copiedObject); - assertTrue(object.equals(copiedObject)); - - // Make sure we didn't clobber the old contents of object. - assertTrue(object.getFeature().equals(feature)); - assertTrue(object.getUnits().equals(units)); - assertTrue(object.getValue() == value); - assertTrue(object.getPosition().equals(position)); - /* ----------------------- */ - - /* ---- Test cloning. ---- */ - // Make sure these are different objects beforehand! - assertFalse(object.equals(clonedObject)); - - // Clone the object. - clonedObject = (SFRData) object.clone(); - - // Make sure they are still different references but have the same info. - assertFalse(object == clonedObject); - assertTrue(object.equals(clonedObject)); - assertFalse(copiedObject == clonedObject); - assertTrue(copiedObject.equals(clonedObject)); - - // Make sure we didn't clobber the old contents of object. - assertTrue(object.getFeature().equals(feature)); - assertTrue(object.getUnits().equals(units)); - assertTrue(object.getValue() == value); - assertTrue(object.getPosition().equals(position)); - /* ----------------------- */ - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRPinTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRPinTester.java deleted file mode 100644 index 877ab6b87..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRPinTester.java +++ /dev/null @@ -1,614 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.Iterator; -import java.util.TreeSet; - -import org.eclipse.ice.reactor.sfr.base.SFRData; -import org.eclipse.ice.reactor.sfr.core.Material; -import org.eclipse.ice.reactor.sfr.core.MaterialBlock; -import org.eclipse.ice.reactor.sfr.core.assembly.Ring; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRPin; -import org.junit.Test; - -/** - *

- * Tests the operations of the SFRPin class. - *

- * - * @author Anna Wojtowicz - */ -public class SFRPinTester { - - /** - *

- * Tests constructors and default values for SFRPin class. - *

- * - */ - @Test - public void checkConstruction() { - - // A pin to test. - SFRPin pin; - - // Invalid, default and valid values to use in the constructor. - String defaultName = "SFR Pin 1"; - String name = "Trillian"; - - Ring defaultCladding; - Ring cladding = new Ring("Hollow tube", - new Material("Something solid"), 42.0, 15, 16); - - Material defaultFillGas; - Material fillGas = new Material("Oxygen-based mixture"); - - TreeSet invalidMaterialBlocks = new TreeSet(); - TreeSet defaultMaterialBlocks; - TreeSet materialBlocks = new TreeSet(); - - // Other defaults. - String defaultDescription = "SFR Pin 1's Description"; - int defaultId = 1; - - // Used to test equivalence of MaterialBlock TreeSets. - TreeSet set1; - TreeSet set2; - Iterator iter1; - Iterator iter2; - - /* ---- Update the default values. ---- */ - // Create a helium material. - Material helium = new Material("He"); - helium.setDescription("Helium"); - - // Create a stainless steel material. - Material steel = new Material("SS-316"); - steel.setDescription("Stainless Steel"); - - // Create a fuel material. - Material fuel = new Material("UO2"); - fuel.setDescription("Uranium Oxide"); - - defaultFillGas = helium; - defaultCladding = new Ring("Cladding", steel, -1, 16.25, 17.5); - - MaterialBlock block = new MaterialBlock(); - - block = new MaterialBlock(); - block.setVertPosition(0); - - // Add the cladding, fill gas, and fuel to the block. - block.addRing(defaultCladding); - block.addRing(new Ring("Fill Gas", helium, -1, 13.3333, 16.25)); - block.addRing(new Ring("Fuel", steel, -1, 0, 13.3333)); - - materialBlocks.add(block); - /* ------------------------------------ */ - - /* ---- Test SFRPin() ---- */ - // Nullary constructor. - pin = new SFRPin(); - - assertEquals(defaultId, pin.getId()); - assertEquals(defaultName, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(defaultFillGas, pin.getFillGas()); - assertEquals(defaultCladding, pin.getCladding()); - - // Update the default MaterialBlock TreeSet. - defaultMaterialBlocks = new TreeSet(); - block = new MaterialBlock(); - block.setVertPosition(0); - block.addRing(defaultCladding); - block.addRing(new Ring("Fill Gas", helium, -1, 13.3333, 16.25)); - block.addRing(new Ring("Fuel", fuel, -1, 0, 13.3333)); - defaultMaterialBlocks.add(block); - - // Compare the contents of the MaterialBlock TreeSets. - set1 = defaultMaterialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - /* ----------------------- */ - - /* ---- Test SFRPin(String) ---- */ - - // Null name String. - pin = new SFRPin(null); - - assertEquals(defaultId, pin.getId()); - assertEquals(defaultName, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(defaultFillGas, pin.getFillGas()); - assertEquals(defaultCladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = defaultMaterialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Empty name String. - pin = new SFRPin(""); - - assertEquals(defaultId, pin.getId()); - assertEquals(defaultName, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(defaultFillGas, pin.getFillGas()); - assertEquals(defaultCladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = defaultMaterialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Valid name String. - pin = new SFRPin(name); - - assertEquals(defaultId, pin.getId()); - assertEquals(name, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(defaultFillGas, pin.getFillGas()); - assertEquals(defaultCladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = defaultMaterialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - /* ----------------------------- */ - - /* ---- Test SFRPin(String, Ring, Material, TreeSet) ---- */ - // All parameters invalid. - pin = new SFRPin(null, null, null, null); - - assertEquals(defaultId, pin.getId()); - assertEquals(defaultName, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(defaultFillGas, pin.getFillGas()); - assertEquals(defaultCladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = defaultMaterialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Null name String. - pin = new SFRPin(null, cladding, fillGas, materialBlocks); - - assertEquals(defaultId, pin.getId()); - assertEquals(defaultName, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(fillGas, pin.getFillGas()); - assertEquals(cladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = materialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Empty name String. - pin = new SFRPin(" ", cladding, fillGas, materialBlocks); - - assertEquals(defaultId, pin.getId()); - assertEquals(defaultName, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(fillGas, pin.getFillGas()); - assertEquals(cladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = materialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Null cladding. - pin = new SFRPin(name, null, fillGas, materialBlocks); - - assertEquals(defaultId, pin.getId()); - assertEquals(name, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(fillGas, pin.getFillGas()); - assertEquals(defaultCladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = materialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Null fill gas. - pin = new SFRPin(name, cladding, null, materialBlocks); - - assertEquals(defaultId, pin.getId()); - assertEquals(name, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(defaultFillGas, pin.getFillGas()); - assertEquals(cladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = materialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Null material block TreeSet. - pin = new SFRPin(name, cladding, fillGas, null); - - assertEquals(defaultId, pin.getId()); - assertEquals(name, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(fillGas, pin.getFillGas()); - assertEquals(cladding, pin.getCladding()); - - // We need to update the default MaterialBlocks because it will use the - // fillGas and cladding that we provided. - defaultMaterialBlocks = new TreeSet(); - block = new MaterialBlock(); - block.setVertPosition(0); - block.addRing(cladding); - block.addRing(new Ring("Fill Gas", fillGas, -1, cladding - .getInnerRadius() - 2.9167, cladding.getInnerRadius())); - block.addRing(new Ring("Fuel", fuel, -1, 0, - cladding.getInnerRadius() - 2.9167)); - defaultMaterialBlocks.add(block); - - // Compare the contents of the MaterialBlock TreeSets. - set1 = defaultMaterialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Invalid material block TreeSet. - pin = new SFRPin(name, cladding, fillGas, invalidMaterialBlocks); - - assertEquals(defaultId, pin.getId()); - assertEquals(name, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(fillGas, pin.getFillGas()); - assertEquals(cladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = defaultMaterialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // All parameters valid. - pin = new SFRPin(name, cladding, fillGas, materialBlocks); - - assertEquals(defaultId, pin.getId()); - assertEquals(name, pin.getName()); - assertEquals(defaultDescription, pin.getDescription()); - assertEquals(fillGas, pin.getFillGas()); - assertEquals(cladding, pin.getCladding()); - // Compare the contents of the MaterialBlock TreeSets. - set1 = materialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - /* --------------------------------------------------------------- */ - - return; - } - - /** - *

- * Tests getters and setters for the location, fillGas, cladding and - * materialBlocks attributes. - *

- * - */ - @Test - public void checkAttributes() { - - SFRPin pin = new SFRPin(); - - // Invalids, defaults, and non-defaults. - Material defaultFillGas; - Material fillGas = new Material("Martian atmosphere"); - Ring defaultCladding; - Ring cladding; - - TreeSet invalidMaterialBlocks = new TreeSet(); - TreeSet defaultMaterialBlocks = new TreeSet(); - TreeSet materialBlocks = new TreeSet(); - - // Used to test equivalence of MaterialBlock TreeSets. - TreeSet set1; - TreeSet set2; - Iterator iter1; - Iterator iter2; - - /* ---- Update the default values. ---- */ - // Create a helium material. - Material helium = new Material("He"); - helium.setDescription("Helium"); - - // Create a stainless steel material. - Material steel = new Material("SS-316"); - steel.setDescription("Stainless Steel"); - - // Create a fuel material. - Material fuel = new Material("UO2"); - fuel.setDescription("Uranium Oxide"); - - defaultFillGas = helium; - defaultCladding = new Ring("Cladding", steel, -1, 16.25, 17.5); - cladding = new Ring("Cladding", fuel, -1, 16.25, 17.5); - - MaterialBlock block = new MaterialBlock(); - block.setVertPosition(0); - - // Add the cladding, fill gas, and fuel to the block. - block.addRing(defaultCladding); - block.addRing(new Ring("Fill Gas", helium, -1, 13.3333, 16.25)); - block.addRing(new Ring("Fuel", fuel, -1, 0, 13.3333)); - - defaultMaterialBlocks.add(block); - - block = new MaterialBlock(); - block.setVertPosition(0); - - // Add the cladding, fill gas, and fuel to the block. - block.addRing(defaultCladding); - block.addRing(new Ring("Fill Gas", helium, -1, 13.3333, 16.25)); - block.addRing(new Ring("Fuel", steel, -1, 0, 13.3333)); - - materialBlocks.add(block); - /* ------------------------------------ */ - - /* ---- Test fill gas. ---- */ - // Check the default. - assertEquals(defaultFillGas, pin.getFillGas()); - - // Update the value. - pin.setFillGas(fillGas); - - // Verify the value. - assertEquals(fillGas, pin.getFillGas()); - - // Try to set an invalid value. - pin.setFillGas(null); - - // Verify the value. - assertEquals(fillGas, pin.getFillGas()); - /* ------------------------ */ - - /* ---- Test cladding. ---- */ - // Check the default. - assertEquals(defaultCladding, pin.getCladding()); - - // Update the value. - pin.setCladding(cladding); - - // Verify the value. - assertEquals(cladding, pin.getCladding()); - - // Try to set an invalid value. - pin.setCladding(null); - - // Verify the value. - assertEquals(cladding, pin.getCladding()); - /* ------------------------ */ - - /* ---- Test material blocks. ---- */ - // Check the default. - // Compare the contents of the MaterialBlock TreeSets. - set1 = defaultMaterialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Update the value. - pin.setMaterialBlocks(materialBlocks); - - // Verify the value. - // Compare the contents of the MaterialBlock TreeSets. - set1 = materialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Try to set an invalid value. - pin.setMaterialBlocks(null); - - // Verify the value. - // Compare the contents of the MaterialBlock TreeSets. - set1 = materialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - - // Try to set an invalid value. - pin.setMaterialBlocks(invalidMaterialBlocks); - - // Verify the value. - // Compare the contents of the MaterialBlock TreeSets. - set1 = materialBlocks; - set2 = pin.getMaterialBlocks(); - assertEquals(set1.size(), set2.size()); - iter1 = set1.iterator(); - iter2 = set2.iterator(); - while (iter1.hasNext()) { - assertEquals(iter1.next(), iter2.next()); - } - /* ------------------------------- */ - - return; - } - - /** - *

- * Tests the equality and hashCode operations. - *

- */ - @Test - public void checkEquality() { - - // Initialize objects for testing. - SFRPin object = new SFRPin(); - SFRPin equalObject = new SFRPin(); - SFRPin unequalObject = new SFRPin(); - - // Set up the object and equalObject. - object.setCladding(new Ring("Cladding!!!")); - object.setFillGas(new Material("Fill gas!!!")); - for (int i = 0; i < 10; i++) { - object.addData(new SFRData("Data" + Integer.toString(i)), 0); - } - equalObject.setCladding(new Ring("Cladding!!!")); - equalObject.setFillGas(new Material("Fill gas!!!")); - for (int i = 0; i < 10; i++) { - equalObject.addData(new SFRData("Data" + Integer.toString(i)), 0); - } - // Set up the unequalObject. - unequalObject.setCladding(new Ring("Cladding!!!")); - unequalObject.setFillGas(new Material("He makes your voice squeaky.")); - for (int i = 0; i < 10; i++) { - unequalObject.addData(new SFRData("Data" + Integer.toString(i)), 0); - } - // Make sure the references are different. - assertFalse(object == equalObject); - assertFalse(object == unequalObject); - assertFalse(equalObject == unequalObject); - - // Check that equality is reflexive and symmetric. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Check that equals will fail when it should. - assertFalse(object == null); - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Check the hash codes. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - assertFalse(object.hashCode() == unequalObject.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations. - *

- */ - @Test - public void checkCopying() { - - // Initialize objects for testing. - SFRPin object = new SFRPin(); - SFRPin copy = new SFRPin(); - SFRPin clone = null; - - // Set up the object. - object.setCladding(new Ring("Cladding!!!")); - object.setFillGas(new Material("Fill gas!!!")); - for (int i = 0; i < 10; i++) { - object.addData(new SFRData("Data" + Integer.toString(i)), 0); - } - // Make sure the objects are not equal before copying. - assertFalse(object == copy); - assertFalse(object.equals(copy)); - - // Copy the object. - copy.copy(object); - - // Make sure the references are different but contents the same. - assertFalse(object == copy); - assertTrue(object.equals(copy)); - - // Do the same for the clone operation. - - // Make sure the objects are not equal before copying. - assertFalse(object == clone); - assertFalse(object.equals(clone)); - - // Copy the object. - clone = (SFRPin) object.clone(); - - // Make sure the references are different but contents the same. - assertFalse(object == clone); - assertTrue(object.equals(clone)); - assertFalse(copy == clone); - assertTrue(copy.equals(clone)); - - return; - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRRodTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRRodTester.java deleted file mode 100644 index 11310704d..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFRRodTester.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.ice.reactor.sfr.core.Material; -import org.eclipse.ice.reactor.sfr.core.assembly.Ring; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRRod; -import org.junit.Test; - -/** - *

- * Tests the operations of the SFRRod class. - *

- * - * @author Anna Wojtowicz - */ -public class SFRRodTester { - /** - *

- * Tests the constructors and default values for the SFRRod class. - *

- * - */ - @Test - public void checkConstruction() { - - /* --- Test the nullary constructor -------------------------------- */ - - // Create a SFRRod for testing - SFRRod rodOne = new SFRRod(); - - // Create a default reflector to test against - Material material = new Material("SS-316"); - material.setDescription("Stainless Steel"); - - Ring reflector = new Ring(); - reflector.setMaterial(material); - reflector.setHeight(0.0); - reflector.setInnerRadius(0.0); - reflector.setOuterRadius(26.666); - - // Check the name description and ID - assertEquals("SFR Rod 1", rodOne.getName()); - assertEquals("SFR Rod 1's Description", rodOne.getDescription()); - assertEquals(1, rodOne.getId()); - - // Check the reflector - assertEquals(reflector, rodOne.getReflector()); - - /* --- Test parameterized constructor with name -------------------- */ - - // Create a SFRRod with a name specified - SFRRod rodTwo = new SFRRod("Ravenous Bugblatter Beast of Traal"); - - // Check the name description and ID - assertEquals("Ravenous Bugblatter Beast of Traal", rodTwo.getName()); - assertEquals("SFR Rod 1's Description", rodTwo.getDescription()); - assertEquals(1, rodTwo.getId()); - - // Check the reflector - assertEquals(reflector, rodTwo.getReflector()); - - } - - /** - *

- * Tests the getter and setter for the rod attribute. - *

- * - */ - @Test - public void checkAttributes() { - - // Create a SFRRod for testing - SFRRod rod = new SFRRod(); - - // Create a reflector for testing - Ring reflector = new Ring(); - Material reflectorMaterial = new Material( - "Almost, but not quite, entirely unlike tea"); - reflector.setMaterial(reflectorMaterial); - - // Set the reflector rod and check it - rod.setReflector(reflector); - assertNotNull(rod.getReflector()); - assertEquals(reflector, rod.getReflector()); - - // Try setting an invalid reflector - rod.setReflector(null); - - // Check that reflector remains unchanged - assertEquals(reflector, rod.getReflector()); - - } - - /** - *

- * Tests the equality operation of SFRRods. - *

- */ - @Test - public void checkEquality() { - - /* --- Check equality between like rods --------------------------- */ - - // Construct a SFRRod (with reflector) to test against - SFRRod rod = new SFRRod(); - Ring reflector = new Ring(); - rod.setReflector(reflector); - - rod.setName("Paula Nancy Millstone Jennings of Greenbridge, Essex"); - rod.setDescription("Worst poet in the universe"); - rod.setId(5); - - // Construct a SFRRod equal to the first - SFRRod equalRod = new SFRRod(); - Ring equalReflector = new Ring(); - equalRod.setReflector(equalReflector); - - equalRod.setName("Paula Nancy Millstone Jennings of Greenbridge, Essex"); - equalRod.setDescription("Worst poet in the universe"); - equalRod.setId(5); - - // Check that equals() is reflexive and symmetric - assertTrue(rod.equals(equalRod)); - assertTrue(rod.equals(equalRod) && equalRod.equals(rod)); - - // Check equals() fails with illegal rings - assertFalse(rod==null); - - /* --- Check transitivity with similar rods ----------------------- */ - - // Construct another SFRRod equal to the first, for testing transitivity - SFRRod transRod = new SFRRod(); - Ring transReflector = new Ring(); - transRod.setReflector(transReflector); - - transRod.setName("Paula Nancy Millstone Jennings of Greenbridge, Essex"); - transRod.setDescription("Worst poet in the universe"); - transRod.setId(5); - - // Check for transitivity - if (rod.equals(transRod) && transRod.equals(equalRod)) { - assertTrue(rod.equals(equalRod)); - } else { - fail(); - } - - /* --- Check inequality between two dissimilar rods ---------------- */ - - // Construct a SFRRod unequal to the first - SFRRod unequalRod = new SFRRod(); - Ring unequalReflector = new Ring(); - unequalRod.setReflector(unequalReflector); - - unequalRod.setName("Grunthos the Flatulent"); - unequalRod.setDescription("Poetmaster of the Azgoths of Kria"); - unequalRod.setId(5); - - // Check that ring and unequalRing are not the same - assertFalse(rod.equals(unequalRod)); - - /* --- Check hash values between equal and unequal rings ----------- */ - - assertEquals(rod.hashCode(), rod.hashCode()); - assertEquals(rod.hashCode(), rod.hashCode()); - assertFalse(rod.hashCode() == unequalRod.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations of SFRRods. - *

- */ - @Test - public void checkCopying() { - - /* --- Testing the copy operation ---------------------------------- */ - - // Create a SFRRod to copy from - SFRRod rod = new SFRRod(); - Ring reflector = new Ring(); - rod.setName("Phouchg"); - rod.setDescription("Chosen to recieve DeepThought's answer"); - rod.setId(7001); - rod.setReflector(reflector); - - // Create an empty SFRRod to copy to - SFRRod rodCopy = new SFRRod(); - - // Copy the contents of rod to rodCopy - rodCopy.copy(rod); - - // Check rod and rodCopy are identical - assertTrue(rod.equals(rodCopy)); - - // Try copying the contents of a null rod - rodCopy.copy(null); - - // Check to see that rodCopy remains unchanged - assertTrue(rodCopy.equals(rod)); - - /* --- Testing the cloning operation ------------------------------- */ - - // Clone the first rod - Object rodClone = rod.clone(); - - // Check that rodClone isn't null - assertNotNull(rodClone); - - // Check that rod and rodClone are identical - assertTrue(rodClone.equals(rod)); - - return; - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFReactorFactory.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFReactorFactory.java deleted file mode 100644 index b5c276747..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFReactorFactory.java +++ /dev/null @@ -1,401 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Random; -import java.util.TreeSet; - -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.base.SFRData; -import org.eclipse.ice.reactor.sfr.core.AssemblyType; -import org.eclipse.ice.reactor.sfr.core.Material; -import org.eclipse.ice.reactor.sfr.core.MaterialBlock; -import org.eclipse.ice.reactor.sfr.core.SFReactor; -import org.eclipse.ice.reactor.sfr.core.assembly.PinAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.PinType; -import org.eclipse.ice.reactor.sfr.core.assembly.ReflectorAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.Ring; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRPin; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRRod; - -/** - * This factory can be used to generate full-core reactors. The assemblies, - * rods/pins, their locations within their respective containers, and their data - * are generated randomly. - * - * @author Jordan H. Deyton - * - */ -public class SFReactorFactory { - - public SFReactor generatePopulatedFullCoreReactor(int reactorSize, - int assemblySize, int nAssemblies, int nAssemblyComponents, - int nAxialLevels, long seed, boolean randomData, - boolean randomLocations) { - - // Check the sizes. If invalid, set the defaults. - if (reactorSize <= 0) { - reactorSize = 17; - } - if (assemblySize <= 0) { - assemblySize = 15; - } - // Check the other properties. - if (nAssemblies <= 0) { - nAssemblies = reactorSize * reactorSize; - } - if (nAssemblyComponents <= 0) { - nAssemblyComponents = assemblySize * assemblySize; - } - if (nAxialLevels <= 0) { - nAxialLevels = 49; - } - - int i, j, k; - int nLocations; - int row, column; - - // Timesteps for the data. - List times = new ArrayList(); - times.add(0.0); - times.add(1.0); - times.add(2.0); - - // Features to use. - Map features = new HashMap(); - features.put("Feature 1", 1); - features.put("Axial Feature 1", nAxialLevels); - features.put("Feature 2", 1); - features.put("Axial Feature 2", nAxialLevels); - features.put("Feature 3", 3); - - // Initialize the random number generator. - Random generator = new Random(seed); - - // Initialize the reactor. - SFReactor reactor = new SFReactor(reactorSize); - - // Materials that we can use in the reactor. - Material helium = new Material("He"); - helium.setDescription("Helium"); - Material steel = new Material("SS-316"); - steel.setDescription("Stainless Steel"); - Material uraniumOxide = new Material("UO2"); - uraniumOxide.setDescription("Uranium Oxide"); - Material boronCarbide = new Material("B4C"); - boronCarbide.setDescription("Boron Carbide"); - - // Add data to the reactor. - addDataToComponent(reactor, features, times, randomData, generator); - - // For each assembly type: - for (AssemblyType assemblyType : AssemblyType.values()) { - // Generate random assemblies. - for (i = 0; i < nAssemblies; i++) { - - /* ---- Create an assembly and add it to the reactor. ---- */ - // The assembly. Its name and ID should be based on i. - SFRAssembly assembly; - String name = Integer.toString(i); - - // Create a new assembly. - if (assemblyType.equals(AssemblyType.Reflector)) { - assembly = new ReflectorAssembly(name, assemblySize); - } else if (assemblyType.equals(AssemblyType.Control)) { - PinType pinType = ((randomData && generator.nextBoolean()) - || (!randomData && i % 2 == 0) ? PinType.PrimaryControl - : PinType.SecondaryControl); - assembly = new PinAssembly(name, pinType, assemblySize); - } else { - PinType pinType = ((randomData && generator.nextBoolean()) - || (!randomData && i % 2 == 0) ? PinType.InnerFuel - : PinType.BlanketFuel); - assembly = new PinAssembly(name, pinType, assemblySize); - } - assembly.setId(i); - - // Add data to the assembly. - addDataToComponent(assembly, features, times, randomData, - generator); - - // Add the assembly to the reactor. - reactor.addAssembly(assemblyType, assembly); - - // Set the assembly's location. - if (!randomLocations) { - reactor.setAssemblyLocation(assemblyType, name, i - / reactorSize, i % reactorSize); - } else { - // Set some random locations for the assembly. - // nLocations = generator.nextInt(reactorSize * reactorSize) - // + 1; - nLocations = 5; - for (j = 0; j < nLocations; j++) { - // Pick a random location for the assembly. - row = generator.nextInt(reactorSize); - column = generator.nextInt(reactorSize); - - // Set the assembly location. - reactor.setAssemblyLocation(assemblyType, name, row, - column); - } - } - /* ------------------------------------------------------- */ - - /* ---- Create rods/pins and add them to the assembly. ---- */ - // Generate assembly components (rods/pins). - for (j = 0; j < nAssemblyComponents; j++) { - - // The rod/pin. Its name and ID should be based on j. - SFRComponent component; - name = Integer.toString(j); - - // Create a new rod/pin. We also need to add them to the - // assembly here (because Reflector/PinAssemblies add them - // via other operations). - if (assemblyType.equals(AssemblyType.Reflector)) { - // Initialize a rod. - SFRRod rod = new SFRRod(name); - rod.setId(j); - component = rod; - - // Occasionally add some reflector rods with different - // radii. - if ((randomData && generator.nextInt() % 5 == 0) - || (!randomData && j % 5 == 0)) { - Ring reflector = new Ring(); - reflector.setMaterial(steel); - reflector.setHeight(0.0); - reflector.setInnerRadius(0.0); - - // We don't want the outer radius to be too small. - double ratio = (randomData ? generator.nextDouble() - : (double) j / (double) nAssemblyComponents); - if (ratio < 0.25) { - ratio = 0.25; - } - reflector.setOuterRadius(ratio * 26.666); - } - } else { - // Initialize a pin. - SFRPin pin = new SFRPin(name); - pin.setId(j); - component = pin; - - PinType pinType = ((PinAssembly) assembly).getPinType(); - - // Change the structure of the pin based on the assembly - // type. - if (assemblyType.equals(AssemblyType.Control)) { - // Control pins get boron carbide and no data - // (although they can have data). - - // Set up the basic block materials. - Ring cladding = new Ring("Cladding", steel, 0, - 16.25, 17.5); - if (pinType.equals(PinType.SecondaryControl)) { - cladding.setOuterRadius(17); - } - Ring fillGas = new Ring("Fill Gas", helium, 0, - 13.3333, 16.25); - Ring fuel = new Ring("Control Fuel", boronCarbide, - 0, 0, 13.3333); - - // Construct the material block set. - TreeSet materialBlocks = new TreeSet(); - - // Construct the first block. - MaterialBlock block = new MaterialBlock(); - block.setVertPosition(0); - block.addRing(cladding); - block.addRing(fillGas); - block.addRing(fuel); - materialBlocks.add(block); - - // Set the pin attributes. - pin.setCladding(cladding); - pin.setFillGas(helium); - pin.setMaterialBlocks(materialBlocks); - } else { - // Fuel pins get uranium oxide and data. - - // Set up the basic block materials. - Ring cladding = new Ring("Cladding", steel, 0, - 16.25, 17.5); - if (pinType.equals(PinType.BlanketFuel)) { - cladding.setOuterRadius(17); - } - Ring fillGas = new Ring("Fill Gas", helium, 0, - 13.3333, 16.25); - Ring fuel = new Ring("Fuel", uraniumOxide, 0, 0, - 13.3333); - - // Construct the material block set. - TreeSet materialBlocks = new TreeSet(); - - // Construct the fuel block. - MaterialBlock block = new MaterialBlock(); - block.setVertPosition(0); - block.addRing(cladding); - block.addRing(fillGas); - block.addRing(fuel); - - // For blanket fuel, sandwich the fuel with some - // boron carbide (just for testing purposes). - if (pinType.equals(PinType.BlanketFuel)) { - // The main fuel should comprise the middle 50% - // of the pin. - block.setVertPosition(0.25); - materialBlocks.add(block); - - Ring blanketFuel = new Ring("Blanket Fuel", - boronCarbide, 0, 0, 13.0); - fillGas = (Ring) fillGas.clone(); - - // The control fuel should comprise the bottom - // 25% of the pin. - block = new MaterialBlock(); - block.setVertPosition(0); - block.addRing(cladding); - fillGas.setInnerRadius(13.0); - block.addRing(fillGas); - block.addRing(blanketFuel); - materialBlocks.add(block); - - // The remaining control fuel should comprise - // the top 25% of the pin. - block = (MaterialBlock) block.clone(); - block.setVertPosition(0.75); - } - // Add the last block that was modified. - materialBlocks.add(block); - - // Set the pin attributes. - pin.setCladding(cladding); - pin.setFillGas(helium); - pin.setMaterialBlocks(materialBlocks); - } - } - - // Add data to the component. - addDataToComponent(component, features, times, randomData, - generator); - - // Add the rod/pin to the assembly and set its location. - if (assemblyType.equals(AssemblyType.Reflector)) { - ((ReflectorAssembly) assembly) - .addRod((SFRRod) component); - } else { - ((PinAssembly) assembly).addPin((SFRPin) component); - } - // Set the pin/rod location. - if (!randomLocations) { - if (assemblyType.equals(AssemblyType.Reflector)) { - ((ReflectorAssembly) assembly).setRodLocation(name, - j / assemblySize, j % assemblySize); - } else { - ((PinAssembly) assembly).setPinLocation(name, j - / assemblySize, j % assemblySize); - } - } else { - // Set some random locations for the rod/pin. - // nLocations = generator.nextInt(assemblySize) + 1; - nLocations = 5; - for (k = 0; k < nLocations; k++) { - // Pick a random location for the rod/pin. - row = generator.nextInt(assemblySize); - column = generator.nextInt(assemblySize); - - // Set the rod/pin location. - if (assemblyType.equals(AssemblyType.Reflector)) { - ((ReflectorAssembly) assembly).setRodLocation( - name, row, column); - } else { - ((PinAssembly) assembly).setPinLocation(name, - row, column); - } - } - } - } - /* -------------------------------------------------------- */ - - /* ---- Add GridData to the assembly. ---- */ - // Add data to each grid position. - for (int dataRow = 0; dataRow < assemblySize; dataRow++) { - for (int dataColumn = 0; dataColumn < assemblySize; dataColumn++) { - SFRComponent provider = null; - if (assemblyType.equals(AssemblyType.Reflector)) { - provider = ((ReflectorAssembly) assembly) - .getDataProviderByLocation(dataRow, - dataColumn); - } else { - provider = ((PinAssembly) assembly) - .getDataProviderByLocation(dataRow, - dataColumn); - } - if (provider != null) { - addDataToComponent(provider, features, times, - randomData, generator); - } - } - } - /* --------------------------------------- */ - } - } - - return reactor; - } - - private void addDataToComponent(SFRComponent component, - Map features, List times, - boolean randomData, Random generator) { - for (Entry entry : features.entrySet()) { - - String feature = entry.getKey(); - int nAxialLevels = entry.getValue(); - - for (double time : times) { - // Add the correct number of data points. - for (int k = 0; k < nAxialLevels; k++) { - SFRData data = new SFRData(feature); - - // Set a random value. - data.setValue(randomData ? generator.nextDouble() - : 1.0 / (k + 1)); - - // Set the position (z-only). - ArrayList position = new ArrayList(3); - position.add(0.0); - position.add(0.0); - position.add((double) k); - data.setPosition(position); - - // Set some different units (although typically they are the - // same). - data.setUnits("Units # " + k); - - // Add the data to the component. - component.addData(data, time); - } - } - } - - return; - } -} diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFReactorIOHandlerTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFReactorIOHandlerTester.java deleted file mode 100644 index 5b08f9962..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFReactorIOHandlerTester.java +++ /dev/null @@ -1,259 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import org.eclipse.ice.reactor.sfr.base.SFReactorIOHandler; -import org.eclipse.ice.reactor.sfr.core.SFReactor; -import org.junit.Ignore; -import org.junit.Test; - -/** - *

- * Tests the operations of the SFReactorIOHandler class. - *

- * - * @author Anna Wojtowicz - */ -public class SFReactorIOHandlerTester { - - // FIXME We need to update the SFReactorIOHandler in the C++ library so that - // it too writes and reads null-terminated strings correctly from the h5 - // files. See bug #180 - @Ignore - @Test - public void checkRead() { - - // Constants for this test. - int reactorSize = 0; // Use the default. - int assemblySize = 0; // Use the default. - int nAssemblies = 7; - int nAssemblyComponents = 5; - int nAxialLevels = 3; - boolean randomData = false; // Use fixed data and properties. - boolean randomLocations = false; // Use fixed component locations. - - // Input/Output files for this test. - // On the Java side, this uses a previously generated file from the C++ - // side. If we make changes to the way h5 files are written, we will - // need to generate a new file and commit it to the repo. - String s = System.getProperty("file.separator"); - String directory = System.getProperty("user.dir") + s - + "ICEIOTestDirectory" + s; - String testInputPath = directory + "fromCPP.h5"; - // String testOutputPath = directory + "fromJava.h5"; - - // Create a factory for generating populated reactors. - SFReactorFactory factory = new SFReactorFactory(); - - // Create an IO handler for writing/reading the reactor. - SFReactorIOHandler handler = new SFReactorIOHandler(); - - // Get a URI from the input path. - File inFile = new File(testInputPath); - URI uri = inFile.toURI(); - - // Declare the reactors. One will be generated; the other will be read. - SFReactor reactor; - SFReactor loadedReactor; - - // Time the test. - long start = System.nanoTime(); - long testStart = start; - - // Generate a reactor with no random info. - reactor = factory.generatePopulatedFullCoreReactor(reactorSize, - assemblySize, nAssemblies, nAssemblyComponents, nAxialLevels, - 0, randomData, randomLocations); - reactor.setName("Arcturus"); - - long end = System.nanoTime(); - System.out - .println("SFReactorIOHandlerTester message: Random reactor generated for read test."); - System.out.println("Time elapsed (s): " + (end - start) / 1000000000.0); - - start = System.nanoTime(); - - // Read the other reactor from the input file. - loadedReactor = handler.readHDF5(uri); - - end = System.nanoTime(); - System.out - .println("SFReactorIOHandlerTester message: Reading completed for read test."); - System.out.println("Time elapsed (s): " + (end - start) / 1000000000.0); - - start = System.nanoTime(); - - // The reactors should be equivalent. - assertEquals(reactor, loadedReactor); - - end = System.nanoTime(); - System.out - .println("SFReactorIOHandlerTester message: Comparison completed for read test."); - System.out.println("Time elapsed (s): " + (end - start) / 1000000000.0); - - // /* ---- Write the reactor (for manual testing, only). ---- */ - // // Uncomment this if you would like to compare the h5 files manually. - // - // // Get a URI from the output path. - // File outFile = new File(testOutputPath); - // uri = outFile.toURI(); - // - // start = System.nanoTime(); - // - // // Write the output file from the loaded reactor. - // handler.writeHDF5(uri, loadedReactor); - // - // end = System.nanoTime(); - // - // System.out.println("SFReactorIOHandlerTester message: Writing completed for read test. You may now compare the h5 files."); - // System.out.println("Time elapsed (s): " + (end - start) / - // 1000000000.0); - // /* ------------------------------------------------------- */ - - System.out.println("Total Time elapsed (s): " + (end - testStart) - / 1000000000.0); - - return; - } - - @Test - public void checkWriteAndRead() { - - // Constants for this test. - int reactorSize = 0; // Use the default. - int assemblySize = 0; // Use the default. - int nAssemblies = 5; - int nAssemblyComponents = 10; - int nAxialLevels = 15; - boolean randomData = true; // Randomize the data and properties. - boolean randomLocations = true; // Randomize the component locations. - - // Input/Output files for this test. - String s = System.getProperty("file.separator"); - String directory = System.getProperty("user.dir") + s - + "ICEIOTestDirectory" + s; - String path = directory + "fromJava.h5"; - - // Create a factory for generating populated reactors. - SFReactorFactory factory = new SFReactorFactory(); - - // Create an IO handler for writing/reading the reactor. - SFReactorIOHandler handler = new SFReactorIOHandler(); - - // Create a URI for a file to write/read for the test. - URI uri = new File(path).toURI(); - - // Set up some seeds. - // int[] seeds = new int[] { 0, 3, 42, 1337, (int) System.nanoTime() }; - int[] seeds = new int[] { 1337 }; - - // Run the test for each seed. - for (int seed : seeds) { - - // Generate a reactor, an identical but separate copy of it, and a - // reactor to read written data into. - SFReactor reactor; - SFReactor backupReactor; - SFReactor loadedReactor = null; - - // Time the test. - long start = System.nanoTime(); - long testStart = start; - - // Construct a reactor based on the seed. - reactor = factory.generatePopulatedFullCoreReactor(reactorSize, - assemblySize, nAssemblies, nAssemblyComponents, - nAxialLevels, seed, randomData, randomLocations); - backupReactor = factory.generatePopulatedFullCoreReactor( - reactorSize, assemblySize, nAssemblies, - nAssemblyComponents, nAxialLevels, seed, randomData, - randomLocations); - - reactor.setName("Arcturus"); - backupReactor.setName("Arcturus"); - - long end = System.nanoTime(); - System.out - .println("SFReactorIOHandlerTester message: Random reactor generated for seed " - + seed); - System.out.println("Time elapsed (s): " + (end - start) - / 1000000000.0); - - // Make sure the reactor and backup reactor are completely the same. - assertFalse(reactor == backupReactor); - assertEquals(reactor, backupReactor); - - start = System.nanoTime(); - - // Perform the write operation. - handler.writeHDF5(uri, reactor); - - end = System.nanoTime(); - System.out - .println("SFReactorIOHandlerTester message: Writing completed for seed " - + seed); - System.out.println("Time elapsed (s): " + (end - start) - / 1000000000.0); - - // Make sure the reactor was not modified in any way. - assertFalse(reactor == backupReactor); - assertEquals(reactor, backupReactor); - - start = System.nanoTime(); - - // Perform the read operation. - loadedReactor = handler.readHDF5(uri); - - end = System.nanoTime(); - System.out - .println("SFReactorIOHandlerTester message: Reading completed for seed " - + seed); - System.out.println("Time elapsed (s): " + (end - start) - / 1000000000.0); - - // Make sure all of the reactors are equivalent but separate. - assertFalse(reactor == backupReactor); - assertFalse(reactor == loadedReactor); - assertFalse(backupReactor == loadedReactor); - assertEquals(reactor, backupReactor); - assertEquals(reactor, loadedReactor); - - end = System.nanoTime(); - System.out - .println("SFReactorIOHandlerTester message: Writing/reading tests completed successfully for seed " - + seed); - System.out.println("Total Time elapsed (s): " + (end - testStart) - / 1000000000.0); - } - - // Delete the .h5 file produced by this test. - try { - File file = new File(path); - file.delete(); - } catch (Exception e) { - System.err - .println("SFReactorIOHandlerTester error: Could not delete file \"" - + path + "\"."); - fail(); - } - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFReactorTester.java b/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFReactorTester.java deleted file mode 100644 index dca3f954b..000000000 --- a/org.eclipse.ice.reactor.sfr.test/src/org/eclipse/ice/reactor/sfr/test/SFReactorTester.java +++ /dev/null @@ -1,1210 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.base.SFRComposite; -import org.eclipse.ice.reactor.sfr.base.SFRData; -import org.eclipse.ice.reactor.sfr.core.AssemblyType; -import org.eclipse.ice.reactor.sfr.core.SFReactor; -import org.eclipse.ice.reactor.sfr.core.assembly.PinAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.PinType; -import org.eclipse.ice.reactor.sfr.core.assembly.ReflectorAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRPin; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRRod; -import org.junit.Test; - -/** - *

- * Tests the operations of the SFReactor class. - *

- * - * @author Anna Wojtowicz - */ -public class SFReactorTester { - /** - *

- * Tests the constructors and default values of the SFReactor class. - *

- * - */ - @Test - public void checkConstruction() { - - // We have the following constructors to test: - // new SFReactor(int size) - - int defaultSize = 1; - String defaultName = "SFReactor 1"; - String defaultDescription = "SFReactor 1's Description"; - int defaultId = 1; - double defaultLatticePitch = 1.0; - double defaultOuterFlatToFlat = 1.0; - int defaultNumberOfAssemblies = 0; - - int size = 15; - - SFReactor reactor; - - /* ---- Test a valid construction (size = 15 > 1). ---- */ - // Initialize the reactor. - reactor = new SFReactor(size); - - // Check non-default values. - assertEquals(size, reactor.getSize()); - - // Check default values. - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(defaultLatticePitch, reactor.getLatticePitch(), 0); - assertEquals(defaultOuterFlatToFlat, reactor.getOuterFlatToFlat(), 0); - for (AssemblyType type : AssemblyType.values()) { - assertEquals(defaultNumberOfAssemblies, - reactor.getNumberOfAssemblies(type)); - assertNotNull(reactor.getAssemblyNames(type)); - assertTrue(reactor.getAssemblyNames(type).isEmpty()); - } - /* ---------------------------------------------------- */ - - /* ---- Test an valid construction (size = 1 = 1). ---- */ - // Initialize the reactor. - reactor = new SFReactor(defaultSize); - - // Check default values. - assertEquals(defaultSize, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(defaultLatticePitch, reactor.getLatticePitch(), 0); - assertEquals(defaultOuterFlatToFlat, reactor.getOuterFlatToFlat(), 0); - for (AssemblyType type : AssemblyType.values()) { - assertEquals(defaultNumberOfAssemblies, - reactor.getNumberOfAssemblies(type)); - assertNotNull(reactor.getAssemblyNames(type)); - assertTrue(reactor.getAssemblyNames(type).isEmpty()); - } - /* ----------------------------------------------------- */ - - /* ---- Test an invalid construction (size = 0 < 1). ---- */ - // Initialize the reactor. - reactor = new SFReactor(0); - - // Check default values. - assertEquals(defaultSize, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(defaultLatticePitch, reactor.getLatticePitch(), 0); - assertEquals(defaultOuterFlatToFlat, reactor.getOuterFlatToFlat(), 0); - for (AssemblyType type : AssemblyType.values()) { - assertEquals(defaultNumberOfAssemblies, - reactor.getNumberOfAssemblies(type)); - assertNotNull(reactor.getAssemblyNames(type)); - assertTrue(reactor.getAssemblyNames(type).isEmpty()); - } - /* ----------------------------------------------------- */ - - /* ---- Test an invalid construction (size = -3 < 1). ---- */ - // Initialize the reactor. - reactor = new SFReactor(-3); - - // Check default values. - assertEquals(defaultSize, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(defaultLatticePitch, reactor.getLatticePitch(), 0); - assertEquals(defaultOuterFlatToFlat, reactor.getOuterFlatToFlat(), 0); - for (AssemblyType type : AssemblyType.values()) { - assertEquals(defaultNumberOfAssemblies, - reactor.getNumberOfAssemblies(type)); - assertNotNull(reactor.getAssemblyNames(type)); - assertTrue(reactor.getAssemblyNames(type).isEmpty()); - } - /* ------------------------------------------------------ */ - - return; - } - - /** - *

- * Tests the getter and setter of SFReactor's latticePitch attribute. - *

- * - */ - @Test - public void checkLatticePitch() { - - // A reactor to play with. - SFReactor reactor = new SFReactor(10); - - // Some lattice pitch values. - double defaultLatticePitch = 1.0; - double latticePitch = 2.0; - double invalidLatticePitch = 0.0; - - // Check the default value. - assertEquals(defaultLatticePitch, reactor.getLatticePitch(), 0); - - // We should be able to set a new value. - reactor.setLatticePitch(latticePitch); - assertEquals(latticePitch, reactor.getLatticePitch(), 0); - - // Setting to an invalid value should change nothing. - reactor.setLatticePitch(invalidLatticePitch); - assertEquals(latticePitch, reactor.getLatticePitch(), 0); - - // We should be able to set a new value. - latticePitch = Double.MIN_VALUE; - reactor.setLatticePitch(latticePitch); - assertEquals(latticePitch, reactor.getLatticePitch(), 0); - - // Setting to an invalid value should change nothing. - invalidLatticePitch = -5.0; - reactor.setLatticePitch(invalidLatticePitch); - assertEquals(latticePitch, reactor.getLatticePitch(), 0); - - return; - } - - /** - *

- * Tests the getter and setter of SFReactor's outerFlatToFlat attribute. - *

- * - */ - @Test - public void checkOuterFlatToFlat() { - - // A reactor to play with. - SFReactor reactor = new SFReactor(10); - - // Some outer flat-to-flat values. - double defaultOuterFlatToFlat = 1.0; - double outerFlatToFlat = 2.0; - double invalidOuterFlatToFlat = 0.0; - - // Check the default value. - assertEquals(defaultOuterFlatToFlat, reactor.getOuterFlatToFlat(), 0); - - // We should be able to set a new value. - reactor.setOuterFlatToFlat(outerFlatToFlat); - assertEquals(outerFlatToFlat, reactor.getOuterFlatToFlat(), 0); - - // Setting to an invalid value should change nothing. - reactor.setOuterFlatToFlat(invalidOuterFlatToFlat); - assertEquals(outerFlatToFlat, reactor.getOuterFlatToFlat(), 0); - - // We should be able to set a new value. - outerFlatToFlat = Double.MIN_VALUE; - reactor.setOuterFlatToFlat(outerFlatToFlat); - assertEquals(outerFlatToFlat, reactor.getOuterFlatToFlat(), 0); - - // Setting to an invalid value should change nothing. - invalidOuterFlatToFlat = -5.0; - reactor.setOuterFlatToFlat(invalidOuterFlatToFlat); - assertEquals(outerFlatToFlat, reactor.getOuterFlatToFlat(), 0); - - return; - } - - /** - *

- * Tests the addition and removal of assemblies in the SFReactor. - *

- * - */ - @Test - public void checkAssemblyAddRem() { - - // Note: I only check reactor.getAssemblyLocations() in a few spots - // below since it's a late addition. Further testing may be required. - - int size = 15; - - List boundaryIndexes = new ArrayList(); - boundaryIndexes.add(-1); - boundaryIndexes.add(0); - boundaryIndexes.add(size - 1); - boundaryIndexes.add(size); - - // An SFReactor to test. - SFReactor reactor = new SFReactor(size); - - // Initialize some assemblies to add/remove from the reactor. - PinAssembly InnerFuelAssembly = new PinAssembly("Vogons", - PinType.InnerFuel, 41); - PinAssembly blanketFuelAssembly = new PinAssembly("Hooloovoo", - PinType.BlanketFuel, 43); - PinAssembly primaryControlAssembly = new PinAssembly("Mice", - PinType.PrimaryControl, 42); - PinAssembly secondaryControlAssembly = new PinAssembly("Dolphins", - PinType.SecondaryControl, 32); - ReflectorAssembly reflectorAssembly = new ReflectorAssembly( - "Grebulons", 64); - SFRAssembly plainAssembly = new SFRAssembly(42); - - AssemblyType assemblyType; - String name; - - // Methods to test: - // public boolean addAssembly(AssemblyType type, SFRComposite assembly) - // public boolean removeAssembly(AssemblyType type, String assemblyName) - // public boolean removeAssemblyFromLocation(AssemblyType type, int row, - // int column) - // public int getNumberOfAssemblies(AssemblyType type) - // public ArrayList getAssemblyNames(AssemblyType type) - // public SFRComponent getAssemblyByName(AssemblyType type, String name) - // public SFRComponent getAssemblyByLocation(AssemblyType type, int row, - // int column) - // public boolean setAssemblyLocation(AssemblyType type, String - // assemblyName, int row, int column) - - // Make sure we have no assemblies of any type first. - for (AssemblyType type : AssemblyType.values()) { - assertEquals(0, reactor.getNumberOfAssemblies(type)); - assertTrue(reactor.getAssemblyNames(type).isEmpty()); - - // Check invalid locations. - for (int row : boundaryIndexes) { - for (int column : boundaryIndexes) { - if (row < 0 || row == size || column < 0 || column == size) { - assertNull(reactor.getAssemblyByLocation(type, row, - column)); - } - } - } - - // Check all valid locations. - for (int row = 0; row < size; row++) { - for (int column = 0; column < size; column++) { - assertNull(reactor.getAssemblyByLocation(type, row, column)); - } - } - } - - /* ---- Try various argument combinations for each method. ---- */ - for (AssemblyType type : AssemblyType.values()) { - - // The name of the assembly that we'll be adding. - name = plainAssembly.getName(); - - // Verify that there is no assembly data yet. - assertNull(reactor.getAssemblyByName(type, name)); - assertEquals(0, reactor.getNumberOfAssemblies(type)); - assertFalse(reactor.getAssemblyNames(type).contains(name)); - - // Check all the locations. - for (int row = 0; row < size; row++) { - for (int column = 0; column < size; column++) { - assertNull(reactor.getAssemblyByLocation(type, row, column)); - } - } - - // addAssembly - assertFalse(reactor.addAssembly(null, null)); - assertFalse(reactor.addAssembly(null, plainAssembly)); - assertFalse(reactor.addAssembly(type, null)); - - // addAssembly (successful) - assertTrue(reactor.addAssembly(type, plainAssembly)); - - // setAssemblyLocation - assertFalse(reactor.setAssemblyLocation(null, null, -1, -1)); - assertFalse(reactor.setAssemblyLocation(null, name, 0, 0)); - assertFalse(reactor.setAssemblyLocation(type, null, 0, 0)); - assertFalse(reactor.setAssemblyLocation(type, "Vogons", 0, 0)); - assertFalse(reactor.setAssemblyLocation(type, name, -1, 0)); - assertFalse(reactor.setAssemblyLocation(type, name, 0, size)); - - // Check setting invalid locations. - for (int row : boundaryIndexes) { - for (int column : boundaryIndexes) { - if (row < 0 || row >= size || column < 0 || column >= size) { - assertFalse(reactor.setAssemblyLocation(type, name, - row, column)); - assertNull(reactor.getAssemblyByLocation(type, row, - column)); - } - } - } - - // setAssemblyLocation (successful) - assertTrue(reactor.setAssemblyLocation(type, name, 0, 0)); - - // getNumberOfAssemblies - assertEquals(0, reactor.getNumberOfAssemblies(null)); - - // getNumberOfAssemblies (successful) - assertEquals(1, reactor.getNumberOfAssemblies(type)); - - // getAssemblyNames - assertTrue(reactor.getAssemblyNames(null).isEmpty()); - - // getAssemblyNames (successful) - assertEquals(1, reactor.getAssemblyNames(type).size()); - assertTrue(reactor.getAssemblyNames(type).contains(name)); - - // getAssemblyByName - assertNull(reactor.getAssemblyByName(null, null)); - assertNull(reactor.getAssemblyByName(null, name)); - assertNull(reactor.getAssemblyByName(type, null)); - assertNull(reactor.getAssemblyByName(type, "Vogons")); - - // getAssemblyByName (successful) - assertEquals(plainAssembly, reactor.getAssemblyByName(type, name)); - - // getAssemblyByLocation - assertNull(reactor.getAssemblyByLocation(null, -1, -1)); - assertNull(reactor.getAssemblyByLocation(null, 0, 0)); - assertNull(reactor.getAssemblyByLocation(type, -1, 0)); - assertNull(reactor.getAssemblyByLocation(type, 0, size)); - assertNull(reactor.getAssemblyByLocation(type, size, -1)); - assertNull(reactor.getAssemblyByLocation(type, 1, 1)); - - // getAssemblyByLocation (successful) - assertEquals(plainAssembly, - reactor.getAssemblyByLocation(type, 0, 0)); - - // getAssemblyLocations - assertTrue(reactor.getAssemblyLocations(null, null).isEmpty()); - assertTrue(reactor.getAssemblyLocations(null, name).isEmpty()); - assertTrue(reactor.getAssemblyLocations(type, null).isEmpty()); - assertTrue(reactor.getAssemblyLocations(type, "Vogons").isEmpty()); - - // getAssemblyLocations (successful) - assertEquals(1, reactor.getAssemblyLocations(type, name).size()); - assertTrue(reactor.getAssemblyLocations(type, name).contains(0)); - - // removeAssemblyFromLocation - assertFalse(reactor.removeAssemblyFromLocation(null, -1, -1)); - assertFalse(reactor.removeAssemblyFromLocation(null, 0, 0)); - assertFalse(reactor.removeAssemblyFromLocation(type, -1, 0)); - assertFalse(reactor.removeAssemblyFromLocation(type, 0, size)); - assertFalse(reactor.removeAssemblyFromLocation(type, size, -1)); - assertFalse(reactor.removeAssemblyFromLocation(type, 1, 1)); - - // removeAssemblyFromLocation (successful) - assertTrue(reactor.removeAssemblyFromLocation(type, 0, 0)); - - // removeAssembly - assertFalse(reactor.removeAssembly(null, null)); - assertFalse(reactor.removeAssembly(null, name)); - assertFalse(reactor.removeAssembly(type, null)); - - // removeAssembly (successful). - assertTrue(reactor.removeAssembly(type, name)); - - // Verify that the assembly has been completely removed. - assertNull(reactor.getAssemblyByName(type, name)); - assertEquals(0, reactor.getNumberOfAssemblies(type)); - assertFalse(reactor.getAssemblyNames(type).contains(name)); - - // Check all the locations. - for (int row = 0; row < size; row++) { - for (int column = 0; column < size; column++) { - assertNull(reactor.getAssemblyByLocation(type, row, column)); - } - } - } - /* ------------------------------------------------------------ */ - - /* ---- Test adding an assembly. ---- */ - // public boolean addAssembly() - assemblyType = AssemblyType.Fuel; - name = InnerFuelAssembly.getName(); - - // Add an assembly. - assertTrue(reactor.addAssembly(AssemblyType.Fuel, InnerFuelAssembly)); - assertFalse(reactor.addAssembly(AssemblyType.Fuel, InnerFuelAssembly)); - - // Make sure the assembly was added, but it is not in any location. - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByName(assemblyType, name)); - assertTrue(reactor.getAssemblyNames(assemblyType).contains(name)); - assertEquals(1, reactor.getNumberOfAssemblies(assemblyType)); - - // All assembly locations should be empty. - for (int row = 0; row < size; row++) { - for (int column = 0; column < size; column++) { - assertNull(reactor.getAssemblyByLocation(assemblyType, row, - column)); - } - } - assertTrue(reactor.getAssemblyLocations(assemblyType, name).isEmpty()); - - // Add the assembly to some locations. - - // Put it in the first spot. - assertTrue(reactor.setAssemblyLocation(assemblyType, name, 0, 0)); - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, 0, 0)); - - // Put it in a middle spot. - assertTrue(reactor.setAssemblyLocation(assemblyType, name, 12, 10)); - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, 12, 10)); - - // Put it in a middle spot. - assertTrue(reactor.setAssemblyLocation(assemblyType, name, 4, 2)); - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, 4, 2)); - - // Put it in the last spot. - assertTrue(reactor.setAssemblyLocation(assemblyType, name, size - 1, - size - 1)); - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, 0, 0)); - - // Put it in an invalid spot. - assertFalse(reactor.setAssemblyLocation(assemblyType, name, 0, -1)); - assertNull(reactor.getAssemblyByLocation(assemblyType, 0, -1)); - - // Check the assembly's locations. - assertEquals(4, reactor.getAssemblyLocations(assemblyType, name).size()); - assertTrue(reactor.getAssemblyLocations(assemblyType, name).contains(0)); - assertTrue(reactor.getAssemblyLocations(assemblyType, name).contains( - 12 * size + 10)); - assertTrue(reactor.getAssemblyLocations(assemblyType, name).contains( - 4 * size + 2)); - assertTrue(reactor.getAssemblyLocations(assemblyType, name).contains( - size * size - 1)); - /* ---------------------------------- */ - - /* ---- Test overriding an assembly in a location. ---- */ - - // Try overriding a location with the assembly that's already there. - assertFalse(reactor.setAssemblyLocation(assemblyType, name, 0, 0)); - - // Verify that the core fuel assembly is still in location 0, 0. - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, 0, 0)); - - // Add the other fuel assembly. - assertTrue(reactor.addAssembly(assemblyType, blanketFuelAssembly)); - - // Make sure it was added and that the core fuel assembly is still - // there. - assertEquals(2, reactor.getNumberOfAssemblies(assemblyType)); - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByName(assemblyType, name)); - assertTrue(reactor.getAssemblyNames(assemblyType).contains(name)); - assertEquals( - blanketFuelAssembly, - reactor.getAssemblyByName(assemblyType, - blanketFuelAssembly.getName())); - assertTrue(reactor.getAssemblyNames(assemblyType).contains( - blanketFuelAssembly.getName())); - - // Verify that the core fuel assembly is still in location 0, 0. - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, 0, 0)); - - // Override location 0, 0. - assertTrue(reactor.setAssemblyLocation(assemblyType, - blanketFuelAssembly.getName(), 0, 0)); - - // It should now be the blanket fuel assembly in that spot. - assertEquals(blanketFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, 0, 0)); - /* ---------------------------------------------------- */ - - /* ---- Test adding another type of assembly. ---- */ - // Add another type of assembly. - assertTrue(reactor.addAssembly(AssemblyType.Control, - primaryControlAssembly)); - - // Make sure it was added. - assertEquals(primaryControlAssembly, reactor.getAssemblyByName( - AssemblyType.Control, primaryControlAssembly.getName())); - assertEquals(1, reactor.getNumberOfAssemblies(AssemblyType.Control)); - - // Make sure the fuel assemblies are still there. - assertEquals(2, reactor.getNumberOfAssemblies(assemblyType)); - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByName(assemblyType, name)); - assertTrue(reactor.getAssemblyNames(assemblyType).contains(name)); - assertEquals( - blanketFuelAssembly, - reactor.getAssemblyByName(assemblyType, - blanketFuelAssembly.getName())); - assertTrue(reactor.getAssemblyNames(assemblyType).contains( - blanketFuelAssembly.getName())); - - // Add it to location 12, 10. - assertTrue(reactor.setAssemblyLocation(AssemblyType.Control, - primaryControlAssembly.getName(), 12, 10)); - - // It should be there. - assertEquals(primaryControlAssembly, - reactor.getAssemblyByLocation(AssemblyType.Control, 12, 10)); - - // The core fuel assembly should still be there for the fuel type. - assertEquals(InnerFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, 12, 10)); - /* ----------------------------------------------- */ - - /* ---- Test removing an assembly from a location. ---- */ - // public boolean removeAssemblyFromLocation() - assertTrue(reactor.removeAssemblyFromLocation(assemblyType, 12, 10)); - - // The core fuel assembly shouldn't be there. - assertNull(reactor.getAssemblyByLocation(assemblyType, 12, 10)); - - // The control assembly should still be there. - assertEquals(primaryControlAssembly, - reactor.getAssemblyByLocation(AssemblyType.Control, 12, 10)); - /* ---------------------------------------------------- */ - - /* ---- Test removing an assembly completely. ---- */ - // public boolean removeAssembly() - assertTrue(reactor.removeAssembly(assemblyType, name)); - - // The reactor shouldn't know about the core fuel assembly. - assertNull(reactor.getAssemblyByName(assemblyType, name)); - assertEquals(1, reactor.getNumberOfAssemblies(assemblyType)); - assertTrue(reactor.getAssemblyNames(assemblyType).contains( - blanketFuelAssembly.getName())); - assertFalse(reactor.getAssemblyNames(assemblyType).contains(name)); - - // The core fuel assembly should not be in any location. - for (int row = 0; row < size; row++) { - for (int column = 0; column < size; column++) { - if (row == 0 && column == 0) { - assertEquals(blanketFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, row, - column)); - } else { - assertNull(reactor.getAssemblyByLocation(assemblyType, row, - column)); - } - } - } - assertTrue(reactor.getAssemblyLocations(assemblyType, name).isEmpty()); - /* ----------------------------------------------- */ - - // Add another control assembly. - assertTrue(reactor.addAssembly(AssemblyType.Control, - secondaryControlAssembly)); - assertTrue(reactor.setAssemblyLocation(AssemblyType.Control, - secondaryControlAssembly.getName(), 10, 10)); - - // Add a reflector assembly and set a location for it. - assertTrue(reactor.addAssembly(AssemblyType.Reflector, - reflectorAssembly)); - assertTrue(reactor.setAssemblyLocation(AssemblyType.Reflector, - reflectorAssembly.getName(), 10, 10)); - - /* ---- Check the fuel assemblies in the reactor. ---- */ - // Check the blanket fuel assembly. - assemblyType = AssemblyType.Fuel; - - // Check the number of assemblies and their names. - assertEquals(1, reactor.getNumberOfAssemblies(assemblyType)); - assertTrue(reactor.getAssemblyNames(assemblyType).contains( - blanketFuelAssembly.getName())); - - // Make sure we can look up the assembly by name. - assertEquals( - blanketFuelAssembly, - reactor.getAssemblyByName(assemblyType, - blanketFuelAssembly.getName())); - - // Check the contents of each location. - for (int row = 0; row < size; row++) { - for (int column = 0; column < size; column++) { - if (row == 0 && column == 0) { - assertEquals(blanketFuelAssembly, - reactor.getAssemblyByLocation(assemblyType, row, - column)); - } else { - assertNull(reactor.getAssemblyByLocation(assemblyType, row, - column)); - } - } - } - /* --------------------------------------------------- */ - - /* ---- Check the control assemblies in the reactor. ---- */ - // Check the control assemblies. - assemblyType = AssemblyType.Control; - - // Check the number of assemblies and their names. - assertEquals(2, reactor.getNumberOfAssemblies(assemblyType)); - assertTrue(reactor.getAssemblyNames(assemblyType).contains( - primaryControlAssembly.getName())); - assertTrue(reactor.getAssemblyNames(assemblyType).contains( - secondaryControlAssembly.getName())); - - // Make sure we can look up the assembly by name. - assertEquals( - primaryControlAssembly, - reactor.getAssemblyByName(assemblyType, - primaryControlAssembly.getName())); - assertEquals(secondaryControlAssembly, reactor.getAssemblyByName( - assemblyType, secondaryControlAssembly.getName())); - - // Check the contents of each location. - for (int row = 0; row < size; row++) { - for (int column = 0; column < size; column++) { - if (row == 12 && column == 10) { - assertEquals(primaryControlAssembly, - reactor.getAssemblyByLocation(assemblyType, row, - column)); - } else if (row == 10 && column == 10) { - assertEquals(secondaryControlAssembly, - reactor.getAssemblyByLocation(assemblyType, row, - column)); - } else { - assertNull(reactor.getAssemblyByLocation(assemblyType, row, - column)); - } - } - } - /* ------------------------------------------------------ */ - - /* ---- Check the reflector assemblies in the reactor. ---- */ - // Check the reflector assembly. - assemblyType = AssemblyType.Reflector; - - // Check the number of assemblies and their names. - assertEquals(1, reactor.getNumberOfAssemblies(assemblyType)); - assertTrue(reactor.getAssemblyNames(assemblyType).contains( - reflectorAssembly.getName())); - - // Make sure we can look up the assembly by name. - assertEquals( - reflectorAssembly, - reactor.getAssemblyByName(assemblyType, - reflectorAssembly.getName())); - - // Check the contents of each location. - for (int row = 0; row < size; row++) { - for (int column = 0; column < size; column++) { - if (row == 10 && column == 10) { - assertEquals(reflectorAssembly, - reactor.getAssemblyByLocation(assemblyType, row, - column)); - } else { - assertNull(reactor.getAssemblyByLocation(assemblyType, row, - column)); - } - } - } - /* -------------------------------------------------------- */ - - /* ---- Remove everything and verify. ---- */ - - // Remove them. - assertTrue(reactor.removeAssembly(AssemblyType.Fuel, - blanketFuelAssembly.getName())); - assertTrue(reactor.removeAssembly(AssemblyType.Control, - primaryControlAssembly.getName())); - assertTrue(reactor.removeAssembly(AssemblyType.Control, - secondaryControlAssembly.getName())); - assertTrue(reactor.removeAssembly(AssemblyType.Reflector, - reflectorAssembly.getName())); - - // Make sure you can't look them up by name any more. - assertNull(reactor.getAssemblyByName(AssemblyType.Fuel, - blanketFuelAssembly.getName())); - assertNull(reactor.getAssemblyByName(AssemblyType.Control, - primaryControlAssembly.getName())); - assertNull(reactor.getAssemblyByName(AssemblyType.Control, - secondaryControlAssembly.getName())); - assertNull(reactor.getAssemblyByName(AssemblyType.Reflector, - reflectorAssembly.getName())); - - // Make sure we have no assemblies of any type first. - for (AssemblyType type : AssemblyType.values()) { - assertEquals(0, reactor.getNumberOfAssemblies(type)); - assertTrue(reactor.getAssemblyNames(type).isEmpty()); - - // Check invalid locations. - for (int row : boundaryIndexes) { - for (int column : boundaryIndexes) { - if (row < 0 || row == size || column < 0 || column == size) { - assertNull(reactor.getAssemblyByLocation(type, row, - column)); - } - } - } - - // Check all valid locations. - for (int row = 0; row < size; row++) { - for (int column = 0; column < size; column++) { - assertNull(reactor.getAssemblyByLocation(type, row, column)); - } - } - } - /* --------------------------------------- */ - - return; - } - - /** - *

- * Tests the methods inherited from SFRComposite. Users should not be able - * to add SFRComponents to an SFReactor through these methods. - *

- * - */ - @Test - public void checkCompositeImplementation() { - - // Initialize a reactor to test. - SFReactor reactor = new SFReactor(15); - - SFRComposite composite; - SFRComponent component; - String name; - - /* ---- Test getComponent and its variations. ---- */ - // Tests the following methods: - // public Component getComponent(int childId) - // public SFRComponent getComponent(String name) - // public ArrayList getComponentNames() - // public int getNumberOfComponents() - // public ArrayList getComponents() - - int numberOfComposites = AssemblyType.values().length; - - // Make sure the reactor maintains a List of Composites based on the - // possible AssemblyTypes. - int id = 1; - for (AssemblyType type : AssemblyType.values()) { - String typeName = type.toString(); - name = typeName + " Composite"; - - // Put a new Composite for the AssemblyType into the Map. - composite = new SFRComposite(); - - // Set the name, description, and ID of each Composite. This also - // increments the ID counter. - composite.setName(name); - composite.setDescription("A Composite that contains many " - + typeName + " Components."); - composite.setId(id); - - assertTrue(composite.equals(reactor.getComponent(id++))); - assertTrue(composite.equals(reactor.getComponent(name))); - assertTrue(reactor.getComponentNames().contains(name)); - } - - // Make sure the reactor only has these Composites. - assertEquals(numberOfComposites, reactor.getNumberOfComponents()); - assertEquals(numberOfComposites, reactor.getComponents().size()); - assertEquals(numberOfComposites, reactor.getComponentNames().size()); - /* ----------------------------------------------- */ - - // Make sure we cannot add or remove components through the API - // inherited from SFRComposite (tests below). - - // Tests the following methods: - // public void addComponent(Component child) - // public void removeComponent(int childId) - // public void removeComponent(String name) - - /* ---- Make sure we cannot add components directly. ---- */ - component = new SFRComponent(); - reactor.addComponent(component); - - assertEquals(numberOfComposites, reactor.getNumberOfComponents()); - assertFalse(reactor.getComponents().contains(component)); - - // Try the same with a Composite. - composite = new SFRComposite(); - reactor.addComponent(composite); - - assertEquals(numberOfComposites, reactor.getNumberOfComponents()); - assertFalse(reactor.getComponents().contains(composite)); - /* ------------------------------------------------------ */ - - /* ---- Make sure we cannot remove components directly. ---- */ - // Get the first Composite stored (and make sure it's valid!). - id = 1; - name = AssemblyType.values()[0].toString() + " Composite"; - composite = (SFRComposite) reactor.getComponent(id); - - // Try to remove it via ID. - reactor.removeComponent(id); - assertEquals(numberOfComposites, reactor.getNumberOfComponents()); - assertTrue(reactor.getComponents().contains(composite)); - - // Try to remove it via name. - reactor.removeComponent(name); - assertEquals(numberOfComposites, reactor.getNumberOfComponents()); - assertTrue(reactor.getComponents().contains(composite)); - - // Try removing an invalid component. - reactor.removeComponent(null); - assertEquals(numberOfComposites, reactor.getNumberOfComponents()); - /* --------------------------------------------------------- */ - - return; - } - - /** - *

- * Tests the equality and hashCode operations. - *

- */ - @Test - public void checkEquality() { - - int size = 19; - - // Initialize objects for testing. - SFReactor object = new SFReactor(size); - SFReactor equalObject = new SFReactor(size); - SFReactor unequalObject = new SFReactor(size); - - // Set up the object and equalObject. - - /* ---- Set up some data to go into the object. ---- */ - PinAssembly fuelAssembly = new PinAssembly("Assembly A", - PinType.InnerFuel, 15); - PinAssembly controlAssembly = new PinAssembly("Assembly B", - PinType.PrimaryControl, 14); - ReflectorAssembly reflectorAssembly = new ReflectorAssembly( - "Assembly C", 17); - - SFRPin pin = new SFRPin("Zaphod"); - SFRData data1 = new SFRData("From Earth"); - data1.setValue(0); - SFRData data2 = new SFRData("From Space"); - data2.setValue(1); - - fuelAssembly.addPin(pin); - fuelAssembly.setPinLocation(pin.getName(), 0, 0); - fuelAssembly.setPinLocation(pin.getName(), 1, 3); - fuelAssembly.setPinLocation(pin.getName(), 4, 1); - controlAssembly.addPin(pin); - controlAssembly.setPinLocation(pin.getName(), 0, 0); - controlAssembly.setPinLocation(pin.getName(), 2, 4); - controlAssembly.setPinLocation(pin.getName(), 3, 2); - - pin = new SFRPin("Trillian"); - data1 = new SFRData("From Earth"); - data1.setValue(1); - data2 = new SFRData("From Space"); - data2.setValue(0); - - fuelAssembly.addPin(pin); - fuelAssembly.setPinLocation(pin.getName(), 1, 1); - fuelAssembly.setPinLocation(pin.getName(), 4, 5); - fuelAssembly.setPinLocation(pin.getName(), 8, 8); - controlAssembly.addPin(pin); - controlAssembly.setPinLocation(pin.getName(), 2, 4); - controlAssembly.setPinLocation(pin.getName(), 5, 6); - controlAssembly.setPinLocation(pin.getName(), 1, 3); - - SFRRod rod = new SFRRod("Arthur"); - data1 = new SFRData("From Earth"); - data1.setValue(1); - data2 = new SFRData("From Space"); - data2.setValue(0); - - reflectorAssembly.addRod(rod); - reflectorAssembly.setRodLocation(rod.getName(), 0, 0); - reflectorAssembly.setRodLocation(rod.getName(), 1, 3); - reflectorAssembly.setRodLocation(rod.getName(), 4, 1); - reflectorAssembly.setRodLocation(rod.getName(), 1, 1); - - rod = new SFRRod("Ford"); - data1 = new SFRData("From Earth"); - data1.setValue(0); - data2 = new SFRData("From Space"); - data2.setValue(1); - - reflectorAssembly.addRod(rod); - reflectorAssembly.setRodLocation(rod.getName(), 1, 0); - reflectorAssembly.setRodLocation(rod.getName(), 6, 3); - reflectorAssembly.setRodLocation(rod.getName(), 4, 7); - reflectorAssembly.setRodLocation(rod.getName(), 6, 1); - - object.addAssembly(fuelAssembly.getAssemblyType(), fuelAssembly); - object.addAssembly(controlAssembly.getAssemblyType(), controlAssembly); - object.addAssembly(reflectorAssembly.getAssemblyType(), - reflectorAssembly); - - object.setAssemblyLocation(fuelAssembly.getAssemblyType(), - fuelAssembly.getName(), 15, 15); - object.setAssemblyLocation(fuelAssembly.getAssemblyType(), - fuelAssembly.getName(), 12, 10); - object.setAssemblyLocation(fuelAssembly.getAssemblyType(), - fuelAssembly.getName(), 17, 17); - object.setAssemblyLocation(controlAssembly.getAssemblyType(), - controlAssembly.getName(), 15, 15); - object.setAssemblyLocation(controlAssembly.getAssemblyType(), - controlAssembly.getName(), 12, 10); - object.setAssemblyLocation(controlAssembly.getAssemblyType(), - controlAssembly.getName(), 17, 17); - object.setAssemblyLocation(reflectorAssembly.getAssemblyType(), - reflectorAssembly.getName(), 12, 10); - object.setAssemblyLocation(reflectorAssembly.getAssemblyType(), - reflectorAssembly.getName(), 17, 17); - /* ------------------------------------------------- */ - - /* ---- Set up some data to go into the equalObject. ---- */ - fuelAssembly = new PinAssembly("Assembly A", PinType.InnerFuel, 15); - controlAssembly = new PinAssembly("Assembly B", PinType.PrimaryControl, - 14); - reflectorAssembly = new ReflectorAssembly("Assembly C", 17); - - pin = new SFRPin("Zaphod"); - data1 = new SFRData("From Earth"); - data1.setValue(0); - data2 = new SFRData("From Space"); - data2.setValue(1); - - fuelAssembly.addPin(pin); - fuelAssembly.setPinLocation(pin.getName(), 0, 0); - fuelAssembly.setPinLocation(pin.getName(), 1, 3); - fuelAssembly.setPinLocation(pin.getName(), 4, 1); - controlAssembly.addPin(pin); - controlAssembly.setPinLocation(pin.getName(), 0, 0); - controlAssembly.setPinLocation(pin.getName(), 2, 4); - controlAssembly.setPinLocation(pin.getName(), 3, 2); - - pin = new SFRPin("Trillian"); - data1 = new SFRData("From Earth"); - data1.setValue(1); - data2 = new SFRData("From Space"); - data2.setValue(0); - - fuelAssembly.addPin(pin); - fuelAssembly.setPinLocation(pin.getName(), 1, 1); - fuelAssembly.setPinLocation(pin.getName(), 4, 5); - fuelAssembly.setPinLocation(pin.getName(), 8, 8); - controlAssembly.addPin(pin); - controlAssembly.setPinLocation(pin.getName(), 2, 4); - controlAssembly.setPinLocation(pin.getName(), 5, 6); - controlAssembly.setPinLocation(pin.getName(), 1, 3); - - rod = new SFRRod("Arthur"); - data1 = new SFRData("From Earth"); - data1.setValue(1); - data2 = new SFRData("From Space"); - data2.setValue(0); - - reflectorAssembly.addRod(rod); - reflectorAssembly.setRodLocation(rod.getName(), 0, 0); - reflectorAssembly.setRodLocation(rod.getName(), 1, 3); - reflectorAssembly.setRodLocation(rod.getName(), 4, 1); - reflectorAssembly.setRodLocation(rod.getName(), 1, 1); - - rod = new SFRRod("Ford"); - data1 = new SFRData("From Earth"); - data1.setValue(0); - data2 = new SFRData("From Space"); - data2.setValue(1); - - reflectorAssembly.addRod(rod); - reflectorAssembly.setRodLocation(rod.getName(), 1, 0); - reflectorAssembly.setRodLocation(rod.getName(), 6, 3); - reflectorAssembly.setRodLocation(rod.getName(), 4, 7); - reflectorAssembly.setRodLocation(rod.getName(), 6, 1); - - equalObject.addAssembly(fuelAssembly.getAssemblyType(), fuelAssembly); - equalObject.addAssembly(controlAssembly.getAssemblyType(), - controlAssembly); - equalObject.addAssembly(reflectorAssembly.getAssemblyType(), - reflectorAssembly); - - equalObject.setAssemblyLocation(fuelAssembly.getAssemblyType(), - fuelAssembly.getName(), 15, 15); - equalObject.setAssemblyLocation(fuelAssembly.getAssemblyType(), - fuelAssembly.getName(), 12, 10); - equalObject.setAssemblyLocation(fuelAssembly.getAssemblyType(), - fuelAssembly.getName(), 17, 17); - equalObject.setAssemblyLocation(controlAssembly.getAssemblyType(), - controlAssembly.getName(), 15, 15); - equalObject.setAssemblyLocation(controlAssembly.getAssemblyType(), - controlAssembly.getName(), 12, 10); - equalObject.setAssemblyLocation(controlAssembly.getAssemblyType(), - controlAssembly.getName(), 17, 17); - equalObject.setAssemblyLocation(reflectorAssembly.getAssemblyType(), - reflectorAssembly.getName(), 12, 10); - equalObject.setAssemblyLocation(reflectorAssembly.getAssemblyType(), - reflectorAssembly.getName(), 17, 17); - /* ------------------------------------------------------ */ - - // Set up the unequalObject. - - /* ---- Set up some data to go into the unequalObject. ---- */ - fuelAssembly = new PinAssembly("Assembly A", PinType.InnerFuel, 15); - controlAssembly = new PinAssembly("Assembly B", PinType.PrimaryControl, - 14); - reflectorAssembly = new ReflectorAssembly("Assembly C", 17); - - pin = new SFRPin("Zaphod"); - data1 = new SFRData("From Earth"); - data1.setValue(0); - data2 = new SFRData("From Space"); - data2.setValue(1); - - fuelAssembly.addPin(pin); - fuelAssembly.setPinLocation(pin.getName(), 0, 0); - fuelAssembly.setPinLocation(pin.getName(), 1, 3); - fuelAssembly.setPinLocation(pin.getName(), 4, 1); - controlAssembly.addPin(pin); - controlAssembly.setPinLocation(pin.getName(), 0, 0); - controlAssembly.setPinLocation(pin.getName(), 2, 4); - controlAssembly.setPinLocation(pin.getName(), 3, 2); - - pin = new SFRPin("Trillian"); - data1 = new SFRData("From Earth"); - data1.setValue(1); - data2 = new SFRData("From Space"); - data2.setValue(0); - - fuelAssembly.addPin(pin); - fuelAssembly.setPinLocation(pin.getName(), 1, 1); - fuelAssembly.setPinLocation(pin.getName(), 4, 5); - fuelAssembly.setPinLocation(pin.getName(), 8, 9); // Different! - controlAssembly.addPin(pin); - controlAssembly.setPinLocation(pin.getName(), 2, 4); - controlAssembly.setPinLocation(pin.getName(), 5, 6); - controlAssembly.setPinLocation(pin.getName(), 1, 3); - - rod = new SFRRod("Arthur"); - data1 = new SFRData("From Earth"); - data1.setValue(1); - data2 = new SFRData("From Space"); - data2.setValue(0); - - reflectorAssembly.addRod(rod); - reflectorAssembly.setRodLocation(rod.getName(), 0, 0); - reflectorAssembly.setRodLocation(rod.getName(), 1, 3); - reflectorAssembly.setRodLocation(rod.getName(), 4, 1); - reflectorAssembly.setRodLocation(rod.getName(), 1, 1); - - rod = new SFRRod("Ford"); - data1 = new SFRData("From Earth"); - data1.setValue(0); - data2 = new SFRData("From Space"); - data2.setValue(1); - - reflectorAssembly.addRod(rod); - reflectorAssembly.setRodLocation(rod.getName(), 1, 0); - reflectorAssembly.setRodLocation(rod.getName(), 6, 3); - reflectorAssembly.setRodLocation(rod.getName(), 4, 7); - reflectorAssembly.setRodLocation(rod.getName(), 6, 1); - - unequalObject.addAssembly(fuelAssembly.getAssemblyType(), fuelAssembly); - unequalObject.addAssembly(controlAssembly.getAssemblyType(), - controlAssembly); - unequalObject.addAssembly(reflectorAssembly.getAssemblyType(), - reflectorAssembly); - - unequalObject.setAssemblyLocation(fuelAssembly.getAssemblyType(), - fuelAssembly.getName(), 15, 15); - unequalObject.setAssemblyLocation(fuelAssembly.getAssemblyType(), - fuelAssembly.getName(), 12, 10); - unequalObject.setAssemblyLocation(fuelAssembly.getAssemblyType(), - fuelAssembly.getName(), 17, 17); - unequalObject.setAssemblyLocation(controlAssembly.getAssemblyType(), - controlAssembly.getName(), 15, 15); - unequalObject.setAssemblyLocation(controlAssembly.getAssemblyType(), - controlAssembly.getName(), 12, 10); - unequalObject.setAssemblyLocation(controlAssembly.getAssemblyType(), - controlAssembly.getName(), 17, 17); - unequalObject.setAssemblyLocation(reflectorAssembly.getAssemblyType(), - reflectorAssembly.getName(), 12, 10); - unequalObject.setAssemblyLocation(reflectorAssembly.getAssemblyType(), - reflectorAssembly.getName(), 17, 17); - /* -------------------------------------------------------- */ - - // Make sure the references are different. - assertFalse(object == equalObject); - assertFalse(object == unequalObject); - assertFalse(equalObject == unequalObject); - - // Check that equality is reflexive and symmetric. - assertTrue(object.equals(object)); - assertTrue(object.equals(equalObject)); - assertTrue(equalObject.equals(object)); - - // Check that equals will fail when it should. - assertFalse(object==null); - assertFalse(object.equals(42)); - assertFalse("just a string".equals(object)); - assertFalse(object.equals(unequalObject)); - assertFalse(unequalObject.equals(object)); - - // Check the hash codes. - assertTrue(object.hashCode() == object.hashCode()); - assertTrue(object.hashCode() == equalObject.hashCode()); - assertFalse(object.hashCode() == unequalObject.hashCode()); - - return; - } - - /** - *

- * Tests the copying and cloning operations. - *

- */ - @Test - public void checkCopying() { - - int size = 34; - - // Initialize objects for testing. - SFReactor object = new SFReactor(size); - SFReactor copy = new SFReactor(15); - SFReactor clone = null; - - // Set up the object. - - // Make sure the objects are not equal before copying. - assertFalse(object == copy); - assertFalse(object.equals(copy)); - - // Copy the object. - copy.copy(object); - - // Make sure the references are different but contents the same. - assertFalse(object == copy); - assertTrue(object.equals(copy)); - - // Do the same for the clone operation. - - // Make sure the objects are not equal before copying. - assertFalse(object == clone); - assertFalse(object.equals(clone)); - - // Copy the object. - clone = (SFReactor) object.clone(); - - // Make sure the references are different but contents the same. - assertFalse(object == clone); - assertTrue(object.equals(clone)); - assertFalse(copy == clone); - assertTrue(copy.equals(clone)); - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/.classpath b/org.eclipse.ice.reactor.sfr/.classpath deleted file mode 100644 index ad32c83a7..000000000 --- a/org.eclipse.ice.reactor.sfr/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.reactor.sfr/.gitignore b/org.eclipse.ice.reactor.sfr/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.reactor.sfr/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.reactor.sfr/.project b/org.eclipse.ice.reactor.sfr/.project deleted file mode 100644 index 3ea218b7e..000000000 --- a/org.eclipse.ice.reactor.sfr/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.ice.reactor.sfr - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.reactor.sfr/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.reactor.sfr/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 1d4eeb863..000000000 --- a/org.eclipse.ice.reactor.sfr/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Fri Oct 18 15:01:12 EDT 2013 -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/org.eclipse.ice.reactor.sfr/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.reactor.sfr/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 540ba1db3..000000000 --- a/org.eclipse.ice.reactor.sfr/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Fri Oct 18 15:01:12 EDT 2013 -eclipse.preferences.version=1 -resolve.requirebundle=false -pluginProject.extensions=false diff --git a/org.eclipse.ice.reactor.sfr/META-INF/MANIFEST.MF b/org.eclipse.ice.reactor.sfr/META-INF/MANIFEST.MF deleted file mode 100644 index e2fbee242..000000000 --- a/org.eclipse.ice.reactor.sfr/META-INF/MANIFEST.MF +++ /dev/null @@ -1,18 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: org.eclipse.ice.reactor.sfr -Bundle-SymbolicName: org.eclipse.ice.reactor.sfr -Bundle-Version: 2.1.8 -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Export-Package: - org.eclipse.ice.reactor.sfr.base, - org.eclipse.ice.reactor.sfr.core, - org.eclipse.ice.reactor.sfr.core.assembly -Import-Package: ncsa.hdf.hdf5lib, - ncsa.hdf.hdf5lib.exceptions, - ncsa.hdf.hdf5lib.structs, - org.eclipse.ice.analysistool, - org.slf4j;version="1.7.2" -Require-Bundle: org.eclipse.ice.datastructures -Bundle-Vendor: Oak Ridge National Laboratory - diff --git a/org.eclipse.ice.reactor.sfr/about.html b/org.eclipse.ice.reactor.sfr/about.html deleted file mode 100644 index b47b18406..000000000 --- a/org.eclipse.ice.reactor.sfr/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

July 1, 2014

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/build.properties b/org.eclipse.ice.reactor.sfr/build.properties deleted file mode 100644 index 5b359b5b7..000000000 --- a/org.eclipse.ice.reactor.sfr/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/pom.xml b/org.eclipse.ice.reactor.sfr/pom.xml deleted file mode 100644 index f05652893..000000000 --- a/org.eclipse.ice.reactor.sfr/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.reactor.sfr - eclipse-plugin - \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/FeatureSet.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/FeatureSet.java deleted file mode 100644 index 42eb24827..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/FeatureSet.java +++ /dev/null @@ -1,241 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.base; - -import java.util.ArrayList; - -import org.eclipse.ice.analysistool.IData; - -/** - *

- * A convenience class that holds IData for the Java Collection on the - * SFRComponent. This is an intermediary class designed to hold the list of - * SFRData for the same types of features. The getFeature() operation on SFRData - * should return the same value as the getName() operation on this class. - *

- * - * @author Anna Wojtowicz - */ -public class FeatureSet { - /** - *

- * List of IData associated to the FeatureSet. - *

- * - */ - private ArrayList iData; - - /** - *

- * Name of the feature. - *

- * - */ - private String name; - - /** - *

- * Parameterized constructor specifying the feature type. The passed value - * must be a valid feature set, otherwise it will set the feature name to - * null and not allow the addition of any IData. - *

- * - * @param feature - * The name of the feature. If this value is null or empty, data - * cannot be added to the set. - */ - public FeatureSet(String feature) { - - // When the FeatureSet gets an invalid feature name, don't add any data - // to it. - if (feature == null || "".equals(feature.trim())) { - System.err - .println("FeatureSet error: Invalid feature name String provided in constructor!"); - name = null; - } else { - name = feature.trim(); - } - - // Initialize the List of IData. - iData = new ArrayList(); - - return; - } - - /** - *

- * Returns the name of the feature as a string. - *

- * - * @return Returns the name of the feature set as a string. This may be null - * if the name provided during construction was invalid. - */ - public String getName() { - - // Return the FeatureSet's name. - return name; - } - - /** - *

- * Returns all IData associated to the FeatureSet. - *

- * - * @return Returns an ArrayList of IData associated with the FeatureSet. If - * the feature name is invalid, this list will not be modifiable. - */ - public ArrayList getData() { - - // By default, return the data stored in this FeatureSet. - ArrayList data = iData; - - // If the name was invalid, return a cloned copy so that data cannot be - // added externally. - if (name == null) { - data = (ArrayList) iData.clone(); - } - - return data; - } - - /** - *

- * Adds IData to the list within the feature set. The name of the feature - * must match the name set on the FeatureSet, otherwise this operation will - * fail. - *

- * - * @param iData - * The IData instance to add to the FeatureSet. - * @return Returns true if operation was successful, false otherwise. - */ - public boolean addIData(IData iData) { - - // By default, we have not added the data to the List. - boolean success = false; - - // If the argument is not null, and the feature name matches, add it to - // the List. - if (iData != null && iData.getFeature().equals(name)) { - success = this.iData.add(iData); - } - // Return whether or not the data was successfully added to the List. - return success; - } - - /** - *

- * Compares the contents of the objects and returns true if they are - * identical, otherwise returns false. - *

- * - * @param otherObject - * The other object to compare against. - * @return Returns true if the two objects are equal, otherwise false. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof FeatureSet) { - - // We can now cast the other object. - FeatureSet featureSet = (FeatureSet) otherObject; - - // Compare the values between the two objects. - if (name != null) { - equals = (name.equals(featureSet.name) && iData - .equals(featureSet.iData)); - } else { - equals = (featureSet.name == null && iData - .equals(featureSet.iData)); - } - } - - return equals; - } - - /** - *

- * Returns the hashcode of the object. - *

- * - * @return The hash of the object. - */ - @Override - public int hashCode() { - - // Static hash at 31. - int hash = 31; - - // Add all variable hash codes to the hash. - if (name != null) { - hash += 31 * name.hashCode(); - } - hash += 31 * iData.hashCode(); - - return hash; - } - - /** - *

- * Deep copies the contents of the object from another object. - *

- * - * @param otherObject - * The other object to copy the contents of. - */ - public void copy(FeatureSet otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - // Copy the name. - name = otherObject.name; - - // Copy the contents of the iData List. - iData.clear(); - for (IData data : otherObject.iData) { - iData.add(data); - } - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated cloned object. - */ - @Override - public Object clone() { - - // Initialize a new object. - FeatureSet object = new FeatureSet(name); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/GridDataManager.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/GridDataManager.java deleted file mode 100644 index 549b6fc5e..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/GridDataManager.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.base; - -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -/** - * This class extends the GridManager to manage IDataProviders for each location - * in the grid. Because the client class already has a GridManager to maintain - * locations, this class removes the burden of managing the data providers when - * that functionality is so closely tied to managing the grid locations. - * - * @author Jordan H. Deyton - * - */ -public class GridDataManager extends GridManager { - - // A map of IDataProviders (typically SFRComponents) keyed on the locations. - // Updates to the super class' location sshould also be reflected in this. - private Map dataProviders; - - // FIXME - For now, we need to use SFRComponents so that data *can be added* - // to the IDataProvider. The LWR model currently has an LWRDataProvider, - // which is essentially an LWRComponent without the name, description, etc. - - /** - * The default constructor. - * - * @param size - * The size of the Grid. - */ - public GridDataManager(int size) { - super(size); - - // Initialize the Map of IDataProviders. - dataProviders = new TreeMap(); - - return; - } - - /** - * Gets an IDataProvider for a specified location. If no component inhabits - * the location, then the return value will be null. - * - * @param location - * The location to fetch the IDataProvider. - * @return An IDataProvider (typically an SFRComponent) or null if the - * location is unset. - */ - public SFRComponent getDataProvider(int location) { - return dataProviders.get(location); - } - - /** - * Overrides the super class' behavior to also initialize an IDataProvider - * for the location. - */ - @Override - public boolean addComponent(String name, int location) { - - // By default, we did not succeed in adding the Component. - boolean success = super.addComponent(name, location); - - // If possible, add a new IDataProvider to the location. - if (success) { - dataProviders.put(location, new SFRComponent()); - } - return success; - } - - /** - * Overrides the super class' behavior to also remove the IDataProvider from - * the location. - */ - @Override - public boolean removeComponent(int location) { - - // By default, we did not succeed in removing the Component location. - boolean success = super.removeComponent(location); - - // If possible, remove the associated IDataProvider from the map. - if (success) { - dataProviders.remove(location); - } - return success; - } - - /** - * Overrides the super class' behavior to also remove the IDataProvider from - * any location inhabited by the component. - */ - @Override - public boolean removeComponent(String name) { - - // Get the locations for this component. - List locations = super.getComponentLocations(name); - - // By default, we did not succeed in removing the Component. - boolean success = super.removeComponent(name); - - // If possible, remove all of the associated IDataProviders from the - // map. - if (success) { - for (int location : locations) { - dataProviders.remove(location); - } - } - return success; - } - - /** - * Compares the contents of objects and returns true - * if they are identical, otherwise returns false. - * - * @param otherObject - * The object to compare against. - * @return True if otherObject is equal. False otherwise. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof GridDataManager) { - - // We can now cast the other object. - GridDataManager manager = (GridDataManager) otherObject; - - // Compare the values between the two objects. - equals = (super.equals(manager) && dataProviders - .equals(manager.dataProviders)); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return The hash of the object. - */ - @Override - public int hashCode() { - - // Static hash at 31. - int hash = super.hashCode(); - - // Add local hashes. - hash += 31 * dataProviders.hashCode(); - - return hash; - } - - /** - *

- * Deep copies the contents of the object from another object. - *

- * - * @param otherObject - * The other object to copy the contents of. - */ - public void copy(GridDataManager otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - super.copy(otherObject); - - // Copy the Map. - dataProviders.clear(); - dataProviders.putAll(otherObject.dataProviders); - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated cloned object. - */ - @Override - public Object clone() { - - // Initialize a new GridManager. - GridDataManager manager = new GridDataManager(1); - - // Copy the contents from this one. - manager.copy(this); - - // Return the newly instantiated object. - return manager; - } -} diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/GridManager.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/GridManager.java deleted file mode 100644 index c2043b278..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/GridManager.java +++ /dev/null @@ -1,350 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.base; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -/** - * A GridManager manages the locations of ICE Components - * in a set of possible locations. - *

- * Classes that employ this GridManager are expected to translate between their - * own geometric coordinate system and 0-based indexes used within this class. - * - * @author Jordan H. Deyton - * - */ -public class GridManager implements IGridManager { - - /** - * The size of the list of possible locations. This - * is considered the maximum index plus 1. - */ - private int size; - - /** - * A Map of Components keyed on their names. Each - * entry contains a Set of locations for quickly looking up all the - * locations for a particular Component. - */ - private Map> components; - - /** - * A Map of locations keyed on their index. Each - * entry contains the name of the Component at that location. If the - * location is not in the Map, the value should be null. - */ - private Map locations; - - /** - * The default constructor. - * - * @param size - * The maximum index supported plus 1. - */ - public GridManager(int size) { - - this.size = (size > 0 ? size : Integer.MAX_VALUE); - - components = new HashMap>(); - - locations = new TreeMap(); - - return; - } - - /** - * Gets the name of the Component in the specified - * grid location. - * - * @param location - * The index of the location in the grid being managed. - * @return A Component name or null if no name is found. - */ - @Override - public String getComponentName(int location) { - - String name = null; - - if (location >= 0 && location < size) { - name = locations.get(location); - } - return name; - } - - /** - * Gets all the locations occupied by a Component in - * the grid. - * - * @param name - * The name of the Component to search for. - * @return A List of location indexes or an empty List if the Component is - * invalid. - */ - @Override - public List getComponentLocations(String name) { - - List locations = new ArrayList(); - - if (name != null) { - Set indexes = components.get(name); - - if (indexes != null) { - for (int index : indexes) { - locations.add(index); - } - } - - } - - return locations; - } - - /** - * Adds a Component to the specified location in the - * grid. If the parameters are valid and the Component did not already - * occupy that location, this will return true. - * - * @param name - * The name of the Component to add to the grid. - * @param location - * The location index in which to put the Component. - * @return True if the component was added to the location, false otherwise. - */ - @Override - public boolean addComponent(String name, int location) { - - // By default, we did not succeed in adding the Component. - boolean success = false; - - if (name != null && location >= 0 && location < size) { - - // Get the Set of indexes this Component occupies. - Set indexes = components.get(name); - if (indexes == null) { - indexes = new HashSet(); - components.put(name, indexes); - } - - // Add this location to that Set. It will return true if the - // location did not previously exist in the Set. - if (indexes.add(location)) { - - // Update the Map of locations. - String oldName = locations.put(location, name); - - // If there was a previous Component in that location, update - // its - // Set of locations. - if (oldName != null && !oldName.equals(name)) { - indexes = components.get(oldName); - indexes.remove(location); - - // If it no longer resides in any locations, remove it from - // the - // Map of Components. - if (indexes.isEmpty()) { - components.remove(oldName); - } - } - - // We have successfully added the Component to the location. - success = true; - } - } - - return success; - } - - /** - * Dissociates the Component at a specified location - * with that location. If the location has a corresponding Component, this - * will return true. - * - * @param location - * The index of the Component to remove. - * @return True if a component was successfully removed from the location, - * false otherwise. - */ - @Override - public boolean removeComponent(int location) { - - // By default, we did not succeed in removing the Component location. - boolean success = false; - - if (location >= 0 && location < size) { - String name = locations.remove(location); - - // If there was a previous Component in that location, update its - // Set of locations. - if (name != null) { - Set indexes = components.get(name); - - // Remove the specified location from the Component's list of - // locations. This operation will return true if the location - // was valid. - success = indexes.remove(location); - - // If it no longer resides in any locations, remove it from the - // Map of Components. - if (indexes.isEmpty()) { - components.remove(name); - } - } - } - - return success; - } - - /** - * Dissociates the Component with all locations that - * it currently occupies. If the Component had corresponding locations, this - * will return true. - * - * @param name - * The name of the Component to remove from the GridManager. - * @return True if the component was successfully removed from the - * IGridManager. False otherwise. - */ - @Override - public boolean removeComponent(String name) { - - // By default, we did not succeed in removing the Component. - boolean success = false; - - if (name != null) { - - Set indexes = components.remove(name); - if (indexes != null) { - for (int index : indexes) { - locations.remove(index); - } - - // If we found a valid set of indexes, we have removed the - // Component successfully. - success = true; - } - } - - return success; - } - - /** - * Compares the contents of objects and returns true - * if they are identical, otherwise returns false. - * - * @param otherObject - * The object to compare against. - * @return True if otherObject is equal. False otherwise. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof GridManager) { - - // We can now cast the other object. - GridManager manager = (GridManager) otherObject; - - // Compare the values between the two objects. - equals = (size == manager.size - && components.equals(manager.components) && locations - .equals(manager.locations)); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return The hash of the object. - */ - @Override - public int hashCode() { - - // Static hash at 31. - int hash = 31; - - // Add local hashes. - hash += 31 * size; - hash += 31 * components.hashCode(); - hash += 31 * locations.hashCode(); - - return hash; - } - - /** - *

- * Deep copies the contents of the object from another object. - *

- * - * @param otherObject - * The other object to copy the contents of. - */ - public void copy(GridManager otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - - // Copy the size. - size = otherObject.size; - - // Copy the two Maps. - components.clear(); - components.putAll(otherObject.components); - locations.clear(); - locations.putAll(otherObject.locations); - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated cloned object. - */ - @Override - public Object clone() { - - // Initialize a new GridManager. - GridManager manager = new GridManager(size); - - // Copy the contents from this one. - manager.copy(this); - - // Return the newly instantiated object. - return manager; - } - -} diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/IGridManager.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/IGridManager.java deleted file mode 100644 index 33ae5166c..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/IGridManager.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.base; - -import java.util.List; - -/** - * Classes that implement this interface should keep - * track the locations of each Component added. It should offer fast look-up - * capabilities based on both the location and the name of a component. - * - * @author Jordan H. Deyton - * - */ -public interface IGridManager { - - /** - * Gets the name of the Component in the specified - * grid location. - * - * @param location - * The index of the location in the grid being managed. - * @return A Component name or null if no name is found. - */ - public String getComponentName(int location); - - /** - * Gets all the locations occupied by a Component in - * the grid. - * - * @param name - * The name of the Component to search for. - * @return A List of location indexes or an empty List if the Component is - * invalid. - */ - public List getComponentLocations(String name); - - /** - * Adds a Component to the specified location in the - * grid. If the parameters are valid and the Component did not already - * occupy that location, this will return true. - * - * @param name - * The name of the Component to add to the grid. - * @param location - * The location index in which to put the Component. - * @return True if the component was added to the location, false otherwise. - */ - public boolean addComponent(String name, int location); - - /** - * Dissociates the Component at a specified location - * with that location. If the location has a corresponding Component, this - * will return true. - * - * @param location - * The index of the Component to remove. - * @return True if a component was successfully removed from the location, - * false otherwise. - */ - public boolean removeComponent(int location); - - /** - * Dissociates the Component with all locations that - * it currently occupies. If the Component had corresponding locations, this - * will return true. - * - * @param name - * The name of the Component to remove from the GridManager. - * @return True if the component was successfully removed from the - * IGridManager. False otherwise. - */ - public boolean removeComponent(String name); -} diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/ISFRComponentVisitor.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/ISFRComponentVisitor.java deleted file mode 100644 index cd9a786ef..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/ISFRComponentVisitor.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.base; - -import org.eclipse.ice.reactor.sfr.core.Material; -import org.eclipse.ice.reactor.sfr.core.MaterialBlock; -import org.eclipse.ice.reactor.sfr.core.SFReactor; -import org.eclipse.ice.reactor.sfr.core.assembly.PinAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.ReflectorAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.Ring; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRPin; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRRod; - -/** - *

- * This interface defines the "visitation" routines that SFRComponents and - * subclasses may use to reveal their types to visitors. - *

- * - * @author Anna Wojtowicz - */ -public interface ISFRComponentVisitor { - /** - *

- * This operation directs a visitor to perform its actions on the - * SFRComponent as a SFReactor. - *

- * - * @param sfrComp - * The SFReactor accepting the visitor. - */ - public void visit(SFReactor sfrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * SFRComponent as a SFRAssembly. - *

- * - * @param sfrComp - * The SFRAssembly being visited. - */ - public void visit(SFRAssembly sfrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * SFRComponent as a PinAssembly. - *

- * - * @param sfrComp - * The PinAssembly accepting the visitor. - */ - public void visit(PinAssembly sfrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * SFRComponent as a ReflectorAssembly. - *

- * - * @param sfrComp - * The ReflectorAssembly accepting the visitor. - */ - public void visit(ReflectorAssembly sfrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * SFRComponent as a SFRPin. - *

- * - * @param sfrComp - * The SFRPin accepting the visitor. - */ - public void visit(SFRPin sfrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * SFRComponent as a SFRRod. - *

- * - * @param sfrComp - * The SFRRod accepting the visitor. - */ - public void visit(SFRRod sfrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * SFRComponent as a MaterialBlock. - *

- * - * @param sfrComp - * The MaterialBlock accepting the visitor. - */ - public void visit(MaterialBlock sfrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * SFRComponent as a Material. - *

- * - * @param sfrComp - * The Material accepting the visitor. - */ - public void visit(Material sfrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * SFRComponent as a Ring. - *

- * - * @param sfrComp - * The Ring accepting the visitor. - */ - public void visit(Ring sfrComp); -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFRComponent.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFRComponent.java deleted file mode 100644 index f7ec59143..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFRComponent.java +++ /dev/null @@ -1,897 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.base; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeMap; - -import org.eclipse.ice.analysistool.IData; -import org.eclipse.ice.analysistool.IDataProvider; -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.datastructures.ICEObject.IUpdateable; -import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener; -import org.eclipse.ice.datastructures.ICEObject.Identifiable; -import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; - -/** - *

- * The SFRComponent class represents all reactor components that can be stored - * in a SFRComposite. This class should be treated as an extension of the Java - * Object class where identifying pieces of information are stored on this - * object. This class also implements the IDataProvider interface in order to - * provide state point data capabilities for individual, unique instances of - * this extended class. - *

- *

- * This class implements the ICE Component interface. - *

- * - * @author Anna Wojtowicz - */ -public class SFRComponent implements IReactorComponent, IDataProvider { - - /** - *

- * Name of the SFRComponent. - *

- * - */ - private String name; - /** - *

- * Description of the SFRComponent. - *

- * - */ - private String description; - /** - *

- * ID of the SFRComponent; cannot be less than zero. - *

- * - */ - private int id; - /** - *

- * A description of the source of information for this provider and its - * data. - *

- * - */ - private String sourceInfo; - /** - *

- * The current time step. Can not be less than 0, and must be strictly less - * than the number of TimeSteps. Defaults to 0. - *

- * - */ - private double time; - /** - *

- * The time unit. - *

- * - */ - private String timeUnits; - /** - *

- * A TreeMap implementation of IData and features. Keep in mind that there - * can be multiple IData for the same feature. - *

- * - */ - private TreeMap> dataTree; - - /** - *

- * An ArrayList of ICE IComponentListeners that should be notified when the - * Component has changed. - *

- * - */ - private List listeners; - - /** - *

- * Nullary constructor. - *

- * - */ - public SFRComponent() { - - // Initialize the default name, description, and ID. - name = "Component 1"; - description = "Component 1's Description"; - id = 1; - - // Initialize the default source information. - sourceInfo = "No Source Information"; - - // Initialize the default time information. - time = 0.0; - timeUnits = "seconds"; - - // Initialize the tree used to store IData. - dataTree = new TreeMap>(); - - // Initialize the List of listeners. - listeners = new ArrayList(); - - return; - } - - /** - *

- * Parameterized constructor with name specified. - *

- * - * @param name - * Name of the SFRComponent. Cannot be an empty string or null. - */ - public SFRComponent(String name) { - - // Call the nullary constructor to set all the defaults. - this(); - - // Set the name to the specified String if it is not null and not empty. - setName(name); - - return; - } - - /** - *

- * This operation notifies the listeners of the Component that its data - * state has changed. - *

- * - */ - public void notifyListeners() { - - // Stop if we have no listeners. - if (listeners.isEmpty()) { - return; - } - // Notify the listeners through a separate thread. - Thread notifierThread = new Thread() { - @Override - public void run() { - - // Loop over the listeners and update them. - for (int i = 0; i < listeners.size(); i++) { - listeners.get(i).update(SFRComponent.this); - } - // FIXME - The iterator-based loop below throws - // ConcurrentModificationExceptions. Although the List itself is - // not modified, the listeners in it may be. - // for (IUpdateableListener listener : listeners) - // listener.update(SFRComponent.this); - - return; - } - }; - - // Start the thread to send out the notifications. - notifierThread.start(); - - return; - } - - /** - * Returns the name of the SFRComponent as a String. - * - * @return The name of the SFRComponent. - */ - @Override - public String getName() { - - // Return the name. - return name; - } - - /** - *

- * Returns the description of the SFRComponent as a String. - *

- * - * @return The description of the SFRComponent. - * @see Identifiable#getDescription() - */ - @Override - public String getDescription() { - - // Return the description. - return description; - } - - /** - *

- * Returns the ID of the SFRComponent as an int. - *

- * - * @see Identifiable#getId() - * @return The ID of the SFRComponent. - */ - @Override - public int getId() { - - // Return the ID. - return id; - } - - /** - *

- * Sets the source information. - *

- * - * @param sourceInfo - * The source information of the SFRComponent. Cannot be an empty - * string or null. - */ - public void setSourceInfo(String sourceInfo) { - - // Only update the sourceInfo if the String is not null and not empty. - if (sourceInfo != null && !sourceInfo.trim().isEmpty()) { - this.sourceInfo = sourceInfo.trim(); - - // Notify listeners of the change. - notifyListeners(); - } - - return; - } - - /** - *

- * Returns the source information as a string. - *

- * - * @return The source information of the SFRComponent. - * @see IDataProvider#getSourceInfo() - */ - @Override - public String getSourceInfo() { - - // Return the source information String. - return sourceInfo; - } - - /** - *

- * Returns the current time as a double. - *

- * - * @return The current time. - */ - public double getCurrentTime() { - - // Return the current time. - return time; - } - - /** - *

- * Sets the time units. - *

- * - * @param timeUnits - * The time units. Cannot be an empty string or null. - */ - public void setTimeUnits(String timeUnits) { - - // Only set the time units if the String is not null and not empty. - if (timeUnits != null && !timeUnits.trim().isEmpty()) { - this.timeUnits = timeUnits.trim(); - - // FIXME - This call is not in the equivalent LWR method. - // Notify listeners of the change. - notifyListeners(); - } - - return; - } - - /** - *

- * Adds a IData piece, keyed on the feature and time, to the dataTree. If - * the feature exists in the tree, it will append to the end of the list. - *

- * - * @param data - * The piece of data to be added to the dataTree. Cannot be null. - * @param time - * The time at which the data will be added to the dataTree. If - * the time does not exist, it will be created. Time cannot be - * negative. - */ - public void addData(SFRData data, double time) { - - // Check the parameters. - if (data == null || time < 0) { - return; - } - // Get the name of the feature in the data. - String feature = data.getFeature(); - - // Get the list of FeatureSets for the time in the data tree. - HashMap featureSetMap = dataTree.get(time); - - // If the timestep is not in the map, add a new entry in the data tree. - if (featureSetMap == null) { - // Initialize a new list of FeatureSets and add it to the tree. - featureSetMap = new HashMap(); - dataTree.put(time, featureSetMap); - } - - // At this point, we have a FeatureSet Map that is in the data tree. Try - // to get the FeatureSet for the feature name. - FeatureSet featureSet = featureSetMap.get(feature); - - // If no existing set matches the feature name, create a new set. - if (featureSet == null) { - // Create a new FeatureSet and add it to the list. - featureSet = new FeatureSet(feature); - featureSetMap.put(feature, featureSet); - } - - // We have either found or created a FeatureSet. Add the data to it and - // notify listeners if the data has changed. - if (featureSet.addIData(data)) { - notifyListeners(); - } - return; - } - - /** - *

- * Removes the feature and all associated IData from the dataTree at all - * time steps. If a user wishes to remove a single piece of IData from the - * tree, then use the appropriate getData operation on that feature and - * manipulate the data that way. - *

- * - * @param feature - * The name of the feature. Must be a valid feature, or not data - * will be removed. - */ - public void removeDataFromFeature(String feature) { - - // Check the parameters. - if (feature == null) { - return; - } - // Whether or not we have removed data. - boolean updated = false; - - // For each list of FeatureSets, remove the feature's data. - for (HashMap featureSetMap : dataTree.values()) { - - // Remove any FeatureSet with the feature name. If the Map returns a - // non-null value, then we have removed something. - if (featureSetMap.remove(feature) != null) { - updated = true; - } - } - - // If we have removed data, notify listeners of this change. - if (updated) { - notifyListeners(); - } - return; - } - - /** - * Sets the ID of the SFRComponent. - * - * @param id - * The ID of the SFRComponent. Must be non-negative. - * @see Identifiable#setId(int id) - */ - @Override - public void setId(int id) { - - // Only allow non-negative IDs. - if (id >= 0) { - this.id = id; - - // Notify listeners of the change. - notifyListeners(); - } - - return; - } - - /** - * Sets the name of the SFRComponent. - * - * @param name - * The name of the SFRComponent. Cannot be null or an empty - * string. - * @see Identifiable#setName(String name) - */ - @Override - public void setName(String name) { - - // Only allow names that are not null and not empty. - if (name != null && !name.trim().isEmpty()) { - this.name = name.trim(); - - // Notify listeners of the change. - notifyListeners(); - } - - return; - } - - /** - * Sets the description of the SFRComponent. - * - * @param description - * The description of the SFRComponent. Cannot be an empty string - * or null. - * @see Identifiable#setDescription(String description) - */ - @Override - public void setDescription(String description) { - - // Only allow descriptions that are not null. - if (description != null && !description.trim().isEmpty()) { - this.description = description.trim(); - - // Notify listeners of the change. - notifyListeners(); - } - - return; - } - - /** - *

- * Compares the contents of objects and returns true if they are identical, - * otherwise returns false. - *

- * - * @param otherObject - * The other object to compare against. - * @return Returns true if the two objects are equal, otherwise false. - * @see Identifiable#equals(Object otherObject) - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof SFRComponent) { - - // Cast the other object to an SFRComponent. - SFRComponent component = (SFRComponent) otherObject; - - // Compare all the variables. Save the biggest for last (Java should - // short-circuit the logical operators as soon as it detects a - // mismatch). - equals = (id == component.id && time == component.time - && name.equals(component.name) - && description.equals(component.description) - && timeUnits.equals(component.timeUnits) - && sourceInfo.equals(component.sourceInfo) && dataTree - .equals(component.dataTree)); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return The hash of the object. - * @see Identifiable#hashCode() - */ - @Override - public int hashCode() { - - // Static hash at 31. - int hash = 31; - - // Add local hashes. - hash += 31 * name.hashCode(); - hash += 31 * description.hashCode(); - hash += 31 * id; - hash += 31 * sourceInfo.hashCode(); - hash += 31 * time; - hash += 31 * timeUnits.hashCode(); - hash += 31 * dataTree.hashCode(); - - return hash; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated copied object. - */ - @Override - public Object clone() { - - // Initialize a new object. - SFRComponent object = new SFRComponent(); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } - - /** - * Deep copies the contents of the SFRComponent. - * - * @param component - * The other SFRComponent to copy the contents of. - */ - public void copy(SFRComponent component) { - - // Check the parameters. - if (component == null) { - return; - } - // Copy the name, description, and ID. - name = component.name; - description = component.description; - id = component.id; - - // Copy the source information. - sourceInfo = component.sourceInfo; - - // Copy the time information. - time = component.time; - timeUnits = component.timeUnits; - - // Copy the data tree used to store IData. - dataTree = new TreeMap>(); - - // FIXME - The corresponding LWR code also does a shallow copy here. - // Should we really do a deep copy on all of this? Otherwise, the - // documentation is sort of lying about deep copying. - - // Perform a shallow copy on the data tree. - for (Entry> entry : component.dataTree - .entrySet()) { - dataTree.put(entry.getKey(), entry.getValue()); - } - - // Add the listeners from the other component. - listeners.addAll(component.listeners); - - // Notify listeners of the changes. - notifyListeners(); - - return; - } - - /** - *

- * This operation notifies a class that has implemented IUpdateable that the - * value associated with the particular key has been updated. - *

- * - * @param updatedKey - * A unique key that describes the value that is to be updated. - * @param newValue - * The updated value of the key. - * @see IUpdateable#update(String updatedKey, String newValue) - */ - @Override - public void update(String updatedKey, String newValue) { - - // Nothing is required for this method. - - } - - /** - *

- * This operation registers a listener that realizes the IComponentListener - * interface with the Component so that it can receive notifications of - * changes to the Component, if the Component publishes such information. - *

- * - * @param listener - * The new listener that should be notified when the the - * Component's state changes. - * @see IUpdateable#register(IUpdateableListener listener) - */ - @Override - public void register(IUpdateableListener listener) { - - // Only register listeners that are not null. - if (listener != null) { - listeners.add(listener); - } - return; - } - - /** - * Accepts an IComponentVisitor that can visit the - * SFRComponent to ascertain its type and perform various type-specific - * operations. - * - * @param visitor - * The SFRComponent's visitor. - * @see Component#accept(IComponentVisitor visitor) - */ - @Override - public void accept(IComponentVisitor visitor) { - - // Only accept valid visitors. - if (visitor != null) { - visitor.visit(this); - } - return; - } - - /** - * This method calls the ISFRComponentVisitor's visit - * operation, passing itself as the argument.
- *
- * SFRComponent is not represented with a visit(SFRComponent) operation in - * ISFRComponentVisitor, so this method does nothing. However, subclasses - * that are represented should override this method. - * - * @param visitor - * An ISFRComponentVisitor that is visiting this SFRComponent. - */ - public void accept(ISFRComponentVisitor visitor) { - - return; - } - - /** - * Gets a String representation of the SFRComponent. - * - * @return The name of the SFRComponent as a string. - * @see IReactorComponent#toString() - */ - @Override - public String toString() { - - // Return the component's name. - return name; - } - - /** - * Returns an ArrayList of strings representing the - * names of all features contained in the SFRComponent's dataTree. - * - * @return ArrayList of strings representing all unique features in the - * dataTree. - * @see IDataProvider#getFeatureList() - */ - @Override - public ArrayList getFeatureList() { - - // Initialize the list of feature names. - ArrayList featureList = new ArrayList(); - - // Initialize a Set of Strings to hold only unique feature names. - Set featureNames = new HashSet(); - - // Loop over all of the lists of FeatureSets. - for (HashMap featureSetMap : dataTree.values()) { - - // Add all of the features (keys) from this key set. - featureNames.addAll(featureSetMap.keySet()); - } - - // Add each name from the Set to the List. - featureList.addAll(featureNames); - - // Return the list of feature names. - return featureList; - } - - /** - * Returns the total number of time steps contained - * in the SFRComponent's dataTree. - * - * @return Returns the total time steps in the dataTree. - * @see IDataProvider#getNumberOfTimeSteps() - */ - @Override - public int getNumberOfTimeSteps() { - - // Return the size of the data tree ( which is keyed on time values). - return dataTree.size(); - } - - /** - * Sets the current time. - * - * @param newTime - * The new time to set. - * @see IDataProvider#setTime(double step) - */ - @Override - public void setTime(double newTime) { - - // We only allow non-negative times - if (newTime >= 0.0) { - time = newTime; - - // Notify listeners of the change. - notifyListeners(); - } - - return; - } - - /** - * Returns all IData corresponding to the specified - * features at the current time. Will return an empty list if the feature at - * the current time contains no data. - * - * @param feature - * The feature of IData to be returned. Cannot be null. - * @return An ArrayList of all data found with the specified feature, at the - * current time. - * @see IDataProvider#getDataAtCurrentTime(String feature) - */ - @Override - public ArrayList getDataAtCurrentTime(String feature) { - - // Don't process anything if the parameter is invalid. - if (feature != null) { - - // Get the list of FeatureSets at the current time. - HashMap featureSetMap = dataTree.get(time); - - // If the time is in the data tree, find the FeatureSet with the - // requested name. - if (featureSetMap != null) { - FeatureSet featureSet = featureSetMap.get(feature); - - // If the FeatureSet exists, get its data. - if (featureSet != null) { - return featureSet.getData(); - } - } - } - - // No data was found, so return an empty list. - return new ArrayList(); - } - - /** - * Returns an ArrayList of strings representing all - * features found in the SFRComponent's dataTree, at the current time. - * - * @return An ArrayList of strings representing all features in the - * dataTree, at the current time. - * @see IDataProvider#getFeaturesAtCurrentTime() - */ - @Override - public ArrayList getFeaturesAtCurrentTime() { - - // Initialize the list of features to return. - ArrayList features = new ArrayList(); - - // Get the list of FeatureSets at the current time. - HashMap featureSets = dataTree.get(time); - - // If the time is in the data tree, add all of the corresponding feature - // names to the list. - if (featureSets != null) { - features.addAll(featureSets.keySet()); - } - // Return the list of features. - return features; - } - - /** - * Returns an ArrayList of doubles representing all - * times found in the SFRComponent's dataTree. - * - * @return An ArrayList of doubles representing all times in the dataTree. - * @see IDataProvider#getTimes() - */ - @Override - public ArrayList getTimes() { - - // Initialize the list of times. - ArrayList times = new ArrayList(); - - // Add each time in the data tree to the list. - for (double time : dataTree.keySet()) { - times.add(time); - } - - // Return the list of times. - return times; - } - - /** - * Returns an integer representing the time step - * associated to the specified time. Returns -1 if no time step is found. - * - * @param time - * The time. - * @return The time step associated to the input time. If no time step is - * found, returns -1. - * @see IDataProvider#getTimeStep(double time) - */ - @Override - public int getTimeStep(double time) { - - // Initialize an iterator over the data tree's keys and a counter. - Iterator iter = dataTree.keySet().iterator(); - int counter = 0; - - // Loop over the keys in the data tree. - while (iter.hasNext()) { - - // If the key matches, return the key's index. - if (iter.next().equals(time)) { - return counter; - } - // Update the index counter. - counter++; - } - - // A matching time was not found. - return -1; - } - - /** - * Returns the time units as a string. - * - * @return The time units. - * @see IDataProvider#getTimeUnits() - */ - @Override - public String getTimeUnits() { - - // Return the time units String. - return timeUnits; - } - - @Override - public void unregister(IUpdateableListener listener) { - // TODO Auto-generated method stub - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFRComposite.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFRComposite.java deleted file mode 100644 index a0aca51ab..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFRComposite.java +++ /dev/null @@ -1,360 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.base; - -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.datastructures.ICEObject.Composite; - -/** - *

- * The SFRComposite class represents all reactor components that can store and - * manage SFRComponents. This class implements the ICE Composite interface. This - * class was designed as a "branch" within the Reactor package to hold - * references to other SFRComponents. - *

- * - * @author Anna Wojtowicz - */ -public class SFRComposite extends SFRComponent implements Composite { - /** - * Hashtable of all SFRComponents contained in the - * SFRComposite, keyed by name. - * - */ - private Hashtable sFRComponents; - - /** - *

- * Nullary constructor. - *

- * - */ - public SFRComposite() { - - // Call the super constructor. - super(); - - // Set up the default values. - setName("Composite 1"); - setId(1); - setDescription("Composite 1's Description"); - - // Initialize the list of child sFRComponents. - sFRComponents = new Hashtable(); - - return; - } - - /** - *

- * Returns the SFRComponent of the specified name - *

- * - * @param name - * Name of the SFRComponent. Cannot be null. - * @return The SFRComponent matching the specified name. Will return a null - * component if no match to name was found. - */ - public SFRComponent getComponent(String name) { - - // Initialize the default return value. - SFRComponent component = null; - - // Try to look up the component based on the name. - if (name != null) { - component = sFRComponents.get(name); - } - // Return the component. - return component; - } - - /** - *

- * Returns a string ArrayList of all SFRComponent names contained in the - * SFRComposite. - *

- * - * @return ArrayList of string names representing all SFRComponents in the - * SFRComposite. - */ - public ArrayList getComponentNames() { - - // Initialize the List of component names. - ArrayList componentNames = new ArrayList(); - - // Loop over the keys in the component Hashtable and add them to the - // list. - for (String componentName : sFRComponents.keySet()) { - componentNames.add(componentName); - } - - // Return the names. - return componentNames; - } - - /** - *

- * Removes the component with the specified name. - *

- * - * @param name - * Name of the SFRComponent to be removed. - */ - public void removeComponent(String name) { - - // Hashtables do not accept null keys, so remove the component if name - // is not null. We do not need to check if the key is in the table. - if (name != null) { - sFRComponents.remove(name); - } - return; - } - - /** - * Adds the specified Component to the SFRComposite. - * - * @param child - * The child component to add to the SFRComposite. Cannot be - * null. - * @see Composite#addComponent(Component child) - */ - @Override - public void addComponent(Component child) { - - // We only want to add the child if it is a non-null SFRComponent and a - // component with the same name is not in the Hashtable. - - // Make sure the child is a non-null SFRComponent. - if (child != null && child instanceof SFRComponent) { - - // Get the name of the child. - String key = child.getName(); - - // If the name is not already a key in the table, add the child. - if (!sFRComponents.containsKey(key)) { - sFRComponents.put(key, (SFRComponent) child); - } - } - - return; - } - - /** - * Removes the component specified by the ID, from - * the SFRComposite. - * - * @param childId - * The ID of the component to the removed. - * @see Composite#removeComponent(int childId) - */ - @Override - public void removeComponent(int childId) { - - // FIXME - Currently, it is possible to have multiple Components with - // the same ID in the Hashtable which is keyed on the components' names. - // This means we have to loop through the entire list of components! - - // Declare the component for iteration in the loop below. - SFRComponent component; - - // Set up the iterator for looping over the child component values. - Iterator iter = sFRComponents.values().iterator(); - - // Iterate over the child components. - while (iter.hasNext()) { - - // Increment the iterator. - component = iter.next(); - - // Remove components with a matching ID. - if (childId == component.getId()) { - removeComponent(component.getName()); - } - } - - return; - } - - /** - * Returns the SFRComponent of the specified ID, from - * the SFRComposite. - * - * @param childId - * The ID of the SFRComponent to be returned. - * @return The SFRComponent matching the specified ID. If no match is found, - * returns a null SFRComponent. - * @see Composite#getComponent(int childId) - */ - @Override - public Component getComponent(int childId) { - - // Declare the component for iteration in the loop below. - SFRComponent component; - - // Set up the iterator for looping over the child component values. - Iterator iter = sFRComponents.values().iterator(); - - // Iterate over the child components. - while (iter.hasNext()) { - - // Increment the iterator. - component = iter.next(); - - // Return the first component with a matching ID. - if (childId == component.getId()) { - return component; - } - } - - // If the code reaches this point, then no matching component was found. - return null; - } - - /** - * Returns the number of SFRComponents contained in - * the SFRComposite, as an integer. - * - * @return The number of components in the composite. - * @see Composite#getNumberOfComponents() - */ - @Override - public int getNumberOfComponents() { - - // Return the size of the component table. - return sFRComponents.size(); - } - - /** - * Returns an ArrayList of SFRComponents contained in - * the SFRComposite. - * - * @return An ArrayList of components contained in the composite. Returns an - * empty ArrayList if the composite was empty. - * @see Composite#getComponents() - */ - @Override - public ArrayList getComponents() { - - // Initialize the return value, an ArrayList of components. - ArrayList components = new ArrayList(); - - // Add all of the child components to the List. - for (SFRComponent component : sFRComponents.values()) { - components.add(component); - } - - // Return the ArrayList. - return components; - } - - /** - *

- * Compares the contents of objects and returns true if they are identical, - * otherwise returns false. - *

- * - * @param otherObject - * The other object to compare against. - * @return Returns true if the two objects are equal, otherwise false. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof SFRComposite) { - - // We can now cast the other object. - SFRComposite composite = (SFRComposite) otherObject; - - // Compare the values between the two objects. - equals = (super.equals(otherObject) && sFRComponents - .equals(composite.sFRComponents)); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return The hash of the object. - */ - @Override - public int hashCode() { - - // Hash based on super's hashCode. - int hash = super.hashCode(); - - // Add local hashes. - hash += 31 * sFRComponents.hashCode(); - - return hash; - } - - /** - *

- * Deep copies the contents of the object from another object. - *

- * - * @param otherObject - * The object to be copied from. - */ - public void copy(SFRComposite otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - // Copy the super's values. - super.copy(otherObject); - - // Copy the local values. - sFRComponents.clear(); - sFRComponents.putAll(otherObject.sFRComponents); - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated cloned object. - */ - @Override - public Object clone() { - - // Initialize a new object. - SFRComposite object = new SFRComposite(); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFRData.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFRData.java deleted file mode 100644 index 0097324ed..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFRData.java +++ /dev/null @@ -1,365 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.base; - -import java.util.ArrayList; - -import org.eclipse.ice.analysistool.IData; - -/** - *

- * A class that implements the IData interface; provides setters for the - * particular sets of IData associated with this class. - *

- * - * @author Anna Wojtowicz - */ -public class SFRData implements IData { - /** - *

- * Value of the SFRData. - *

- * - */ - private double value; - /** - *

- * Uncertainty of the SFRData value. - *

- * - */ - private double uncertainty; - /** - *

- * Units of the SFRData value. - *

- * - */ - private String units; - /** - *

- * Feature the SFRData value describes. - *

- * - */ - private String feature; - /** - *

- * Representation of the SFRData's physical position in the reactor as an - * array of (x, y, z) coordinates. - *

- * - */ - private ArrayList position = null; - - /** - *

- * Nullary constructor. - *

- * - */ - public SFRData() { - // Initialize the default feature name. - feature = "Feature 1"; - - // Initialize position with 3 default values. - position = new ArrayList(); - position.add(0.0); - position.add(0.0); - position.add(0.0); - - // Initialize the remaining defaults. - uncertainty = 0.0; - units = "seconds"; - value = 0.0; - - return; - } - - /** - * Parameterized constructor with feature specified. - * - * @param feature - * String representation of the feature. - */ - public SFRData(String feature) { - - // Perform the standard initialization. - this(); - - // Set the feature name (the method should check the value). - setFeature(feature); - - return; - } - - /** - *

- * Sets the value of the data. - *

- * - * @param value - * The value of the data. - */ - public void setValue(double value) { - - this.value = value; - - return; - } - - /** - *

- * Sets the uncertainty of the data. - *

- * - * @param uncertainty - * The uncertainty of the data. - */ - public void setUncertainty(double uncertainty) { - - this.uncertainty = uncertainty; - - return; - } - - /** - *

- * Sets the units of the data. - *

- * - * @param units - * The units of the data. - */ - public void setUnits(String units) { - - // Only accept non-null, non-empty Strings. - if (units != null && !units.trim().isEmpty()) { - this.units = units.trim(); - } - - return; - - } - - /** - *

- * Sets the feature type of the data. - *

- * - * @param feature - * The feature of the data. - */ - public void setFeature(String feature) { - - // Only accept non-null, non-empty Strings. - if (feature != null && !feature.trim().isEmpty()) { - this.feature = feature.trim(); - } - - return; - } - - /** - *

- * Sets the position of the SFRData object. Represented in (x, y, z) - * coordinates. - *

- * - * @param position - * The position of the data, represented in (x, y, z) - * coordinates. - */ - public void setPosition(ArrayList position) { - - // Change the position variable only if the incoming list of doubles is - // of the proper size. - int size = this.position.size(); - if (position != null && position.size() == size) { - for (int i = 0; i < size; i++) { - this.position.set(i, position.get(i)); - } - } - - return; - } - - /** - * Returns the position of the SFRData. - * - * @return An ArrayList of doubles representing the position in (x, y, z) - * coordinates. - * @see IData#getPosition() - */ - @Override - public ArrayList getPosition() { - return position; - } - - /** - * Returns the value of the SFRData. - * - * @return The value of the SFRData - * @see IData#getValue() - */ - @Override - public double getValue() { - return value; - } - - /** - * Returns the uncertainty of the SFRData. - * - * @return The uncertainty of the SFRData. - * @see IData#getUncertainty() - */ - @Override - public double getUncertainty() { - return uncertainty; - } - - /** - * Returns the units of the SFRData. - * - * @return The units of the SFRData. - * @see IData#getUnits() - */ - @Override - public String getUnits() { - return units; - } - - /** - * Returns the feature of the SFRData. - * - * @return The feature of the SFRData. - * @see IData#getFeature() - */ - @Override - public String getFeature() { - return feature; - } - - /** - *

- * Overrides the equals operation to check the attributes on this object - * with another object of the same type. Returns true if the objects are - * equal. False otherwise. - *

- * - * @param otherObject - * The object to be compared. - * @return True if otherObject is equal. False otherwise. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof SFRData) { - // Cast the other object to an SFRComponent. - SFRData data = (SFRData) otherObject; - - // Compare all the variables. Save the biggest for last (Java should - // short-circuit the logical operators as soon as it detects a - // mismatch). - equals = (position.equals(data.position) && value == data.value - && uncertainty == data.uncertainty - && units.equals(data.units) && feature.equals(data.feature)); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return The hash of the object. - */ - @Override - public int hashCode() { - - // Static hash at 31. - int hash = 31; - - // Add local hashes. - hash += 31 * position.hashCode(); - hash += 31 * value; - hash += 31 * uncertainty; - hash += 31 * units.hashCode(); - hash += 31 * feature.hashCode(); - - return hash; - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param data - * The object to be copied from. - */ - public void copy(SFRData data) { - - // Check the parameters. - if (data == null) { - return; - } - - // Deep copy the position data. - position.clear(); - position.addAll(data.position); - - // Update the other variables. - feature = data.feature; - uncertainty = data.uncertainty; - units = data.units; - value = data.value; - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated copied object. - */ - @Override - public Object clone() { - - // Initialize a new object. - SFRData object = new SFRData(); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFReactorIOHandler.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFReactorIOHandler.java deleted file mode 100644 index cd2291a8b..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/base/SFReactorIOHandler.java +++ /dev/null @@ -1,2023 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.base; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Stack; -import java.util.TreeSet; - -import ncsa.hdf.hdf5lib.H5; -import ncsa.hdf.hdf5lib.HDF5Constants; -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; -import ncsa.hdf.hdf5lib.exceptions.HDF5LibraryException; -import ncsa.hdf.hdf5lib.structs.H5O_info_t; - -import org.eclipse.ice.analysistool.IData; -import org.eclipse.ice.reactor.sfr.core.AssemblyType; -import org.eclipse.ice.reactor.sfr.core.Material; -import org.eclipse.ice.reactor.sfr.core.MaterialBlock; -import org.eclipse.ice.reactor.sfr.core.SFReactor; -import org.eclipse.ice.reactor.sfr.core.assembly.PinAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.PinType; -import org.eclipse.ice.reactor.sfr.core.assembly.ReflectorAssembly; -import org.eclipse.ice.reactor.sfr.core.assembly.Ring; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRPin; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRRod; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - *

- * Class acts as an intermediary between the reactor and HDF5 data. This class - * both reads HDF5 data into the SFReactor, and writes from the SFReactor into - * HDF5 data. - *

- * - * @author Anna Wojtowicz - */ -public class SFReactorIOHandler { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(SFReactorIOHandler.class); - - /** - *

- * Nullary constructor. - *

- * - */ - public SFReactorIOHandler() { - - // Nothing to do here. - - } - - /** - * Reads data from an input HDF5 file into a SFReactor. - * - * @return A valid {@link SFReactor} if the file could be completely read, - * {@code null} if the file could not be opened. - */ - public SFReactor readHDF5(URI uri) { - - // The SFReactor that will receive the data from the file. - SFReactor reactor = null; - - // Check the parameters. - if (uri == null) { - return reactor; - } - // Check the file associated with the URI. We need to be able to read - // from it. - File file = new File(uri); - String path = file.getPath(); - if (!file.canRead()) { - System.err.println("SFReactorIOHandler error: File \"" + path - + "\" cannot be read."); - return reactor; - } - - // HDF5 constants. Writing out "HDF5Constants." every time is annoying. - int H5P_DEFAULT = HDF5Constants.H5P_DEFAULT; // Default flag. - int H5F_ACC_RDONLY = HDF5Constants.H5F_ACC_RDONLY; // Open read-only. - int H5T_NATIVE_INT = HDF5Constants.H5T_NATIVE_INT; // int - int H5T_NATIVE_DOUBLE = HDF5Constants.H5T_NATIVE_DOUBLE; // double - int H5O_TYPE_GROUP = HDF5Constants.H5O_TYPE_GROUP; - - // The status of the previous HDF5 operation. Generally, if it is - // negative, there was some error. - int status; - - // Other IDs for HDF5 components. - int fileId, groupId; - - // A stack representing the currently opened groups. - Stack groupIds = new Stack(); - - Integer[] intBuffer = new Integer[1]; - Double[] doubleBuffer = new Double[1]; - - try { - // Open the H5 file with read-only access. - status = H5.H5Fopen(path, H5F_ACC_RDONLY, H5P_DEFAULT); - if (status < 0) { - throwException("Opening file \"" + path + "\"", status); - } - fileId = status; - - // Currently, we only support a single reactor. - groupId = groupIds.push(openGroup(fileId, "/SFReactor")); - - // Get the size of the reactor in the file and initialize it. - int size = (Integer) readAttribute(groupId, "size", H5T_NATIVE_INT, - intBuffer); - reactor = new SFReactor(size); - - /* ---- Read the reactor's attributes. ---- */ - // Attributes inherited from SFRComponent. - readSFRComponent(reactor, groupId); - - // Attributes inherited from SFRComposite. - // none - - // SFReactor-specific attributes. - // size has already been read. - reactor.setLatticePitch((Double) readAttribute(groupId, - "latticePitch", H5T_NATIVE_DOUBLE, doubleBuffer)); - reactor.setOuterFlatToFlat((Double) readAttribute(groupId, - "outerFlatToFlat", H5T_NATIVE_DOUBLE, doubleBuffer)); - /* ---------------------------------------- */ - - /* ---- Read the reactor's Pin Assemblies. ---- */ - List pinAssemblyTypes = new ArrayList(); - pinAssemblyTypes.add(AssemblyType.Fuel); - pinAssemblyTypes.add(AssemblyType.Control); - pinAssemblyTypes.add(AssemblyType.Shield); - pinAssemblyTypes.add(AssemblyType.Test); - - for (AssemblyType assemblyType : pinAssemblyTypes) { - // Open the group for this assembly type. - groupId = groupIds.push(openGroup(groupIds.peek(), - assemblyType.toString())); - - // Loop over the child groups in this assembly type's group. - // These groups should have the assembly names. - for (String assemblyName : getChildNames(groupId, - H5O_TYPE_GROUP)) { - - // Open the group for this assembly. - groupId = groupIds.push(openGroup(groupIds.peek(), - assemblyName)); - - // Read the name, pinType, and size of the assembly. - PinType pinType = PinType.valueOf((Integer) readAttribute( - groupId, "pinType", H5T_NATIVE_INT, intBuffer)); - size = (Integer) readAttribute(groupId, "size", - H5T_NATIVE_INT, intBuffer); - - // Initialize the assembly. - PinAssembly assembly = new PinAssembly(assemblyName, - pinType, size); - - /* --- Read the assembly's attributes. --- */ - // Attributes inherited from SFRComponent. - readSFRComponent(assembly, groupId); - - // Attributes inherited from SFRComposite. - // none - - // Attributes inherited from SFRAssembly. - // size has already been read. - assembly.setDuctThickness((Double) readAttribute(groupId, - "ductThickness", H5T_NATIVE_DOUBLE, doubleBuffer)); - - // PinAssembly-specific attributes. - assembly.setPinPitch((Double) readAttribute(groupId, - "pinPitch", H5T_NATIVE_DOUBLE, doubleBuffer)); - // pinType has already been read. - assembly.setInnerDuctFlatToFlat((Double) readAttribute( - groupId, "innerDuctFlatToFlat", H5T_NATIVE_DOUBLE, - doubleBuffer)); - assembly.setInnerDuctThickness((Double) readAttribute( - groupId, "innerDuctThickness", H5T_NATIVE_DOUBLE, - doubleBuffer)); - /* --------------------------------------- */ - - /* --- Read the assembly's reactor locations. --- */ - // Add the assembly to the reactor. - reactor.addAssembly(assemblyType, assembly); - - // Set the assembly's locations in the reactor. - for (int location : readLocationData(groupId)) { - reactor.setAssemblyLocation(assemblyType, assemblyName, - location / reactor.getSize(), location - % reactor.getSize()); - } - /* ---------------------------------------------- */ - - /* --- Read the assembly's pins. --- */ - // Open the group that holds the pins. - groupId = groupIds.push(openGroup(groupId, "Pins")); - - // Loop over the child groups in this assembly's Pins group. - // These groups should have the pin names. - for (String pinName : getChildNames(groupId, H5O_TYPE_GROUP)) { - - // Open the group for this pin. - groupId = groupIds.push(openGroup(groupIds.peek(), - pinName)); - - // So we don't waste time creating default properties - // for the pin that will soon be replaced, we should - // first read in the physical structure of the pin. - Ring cladding = null; - Material fillGas = null; - TreeSet materialBlocks = null; - - /* -- Read in the cladding. -- */ - groupId = openGroup(groupId, "cladding"); - cladding = readRing(groupId); - closeGroup(groupId); - /* --------------------------- */ - - /* -- Read in the fill gas. -- */ - // Initialize the container for the fill gas. - fillGas = new Material(); - - // Read the material's attributes. - groupId = openGroup(groupIds.peek(), "fillGas"); - readSFRComponent(fillGas, groupId); - closeGroup(groupId); - /* --------------------------- */ - - /* -- Read in the material blocks. -- */ - // Initialize the container for the material blocks. - materialBlocks = new TreeSet(); - - // Open the material blocks group. - groupId = groupIds.push(openGroup(groupIds.peek(), - "materialBlocks")); - - // Loop over the child groups of materialBlocks. They - // correspond to individual MaterialBlocks in the - // TreeSet. - for (String groupName : getChildNames(groupIds.peek(), - H5O_TYPE_GROUP)) { - // Initialize a MaterialBlock. - MaterialBlock block = new MaterialBlock(); - - // Open the MaterialBlock's group. - groupId = groupIds.push(openGroup(groupIds.peek(), - groupName)); - - // Read the block's SFRComponent attributes. - readSFRComponent(block, groupId); - - // Read the block's other attributes. - block.setVertPosition((Double) readAttribute( - groupId, "vertPosition", H5T_NATIVE_DOUBLE, - doubleBuffer)); - - /* - Read the block's rings. - */ - - // Open the Rings group. - groupId = groupIds - .push(openGroup(groupId, "Rings")); - - // Loop over the child groups of the block. They - // correspond to individual rings in the block's - // TreeSet. - for (String ringGroupName : getChildNames(groupId, - H5O_TYPE_GROUP)) { - groupId = openGroup(groupIds.peek(), - ringGroupName); - block.addRing(readRing(groupId)); - closeGroup(groupId); - } - - // Close the Rings group. - closeGroup(groupIds.pop()); - /* --------------------------- */ - - // Close the MaterialBlock's group. - closeGroup(groupIds.pop()); - - // Add the block to materialBlocks (TreeSet). - materialBlocks.add(block); - } - - // Close the material blocks group. - closeGroup(groupIds.pop()); - /* ---------------------------------- */ - - // Initialize the pin. - SFRPin pin = new SFRPin(pinName, cladding, fillGas, - materialBlocks); - - // Get the pin's groupId. - groupId = groupIds.peek(); - - /* -- Read in the Pin's other attributes. -- */ - // Attributes inherited from SFRComponent. - readSFRComponent(pin, groupId); - - // Pin-specific attributes. - // none - /* ----------------------------------------- */ - - /* -- Read the pin's assembly locations. -- */ - // Add the pin to the assembly. - assembly.addPin(pin); - - // Set the pin's locations in the assembly. - for (int location : readLocationData(groupId)) { - assembly.setPinLocation(pinName, location / size, - location % size); - } - /* ---------------------------------------- */ - - // Close the group for this pin. - closeGroup(groupIds.pop()); - } - - // Close the group that holds the pins. - closeGroup(groupIds.pop()); - /* --------------------------------- */ - - /* --- Read the assembly's GridData. --- */ - groupId = groupIds.peek(); - - List gridData = new ArrayList(); - for (int row = 0; row < assembly.getSize(); row++) { - for (int column = 0; column < assembly.getSize(); column++) { - gridData.add(assembly.getDataProviderByLocation( - row, column)); - } - } - readGridData(gridData, groupId); - /* -------------------------------------- */ - - // Close the group for this assembly. - closeGroup(groupIds.pop()); - } - - // Close the group for this assembly type. - closeGroup(groupIds.pop()); - } - /* -------------------------------------------- */ - - /* ---- Read the reactor's Reflector Assemblies. ---- */ - // Open the group for this assembly type. - groupId = groupIds.push(openGroup(groupIds.peek(), - AssemblyType.Reflector.toString())); - - // Loop over the child groups in this assembly type's group. - // These groups should have the assembly names. - for (String assemblyName : getChildNames(groupId, H5O_TYPE_GROUP)) { - - // Open the group for this assembly. - groupId = groupIds - .push(openGroup(groupIds.peek(), assemblyName)); - - // Read the name, rodType, and size of the assembly. - size = (Integer) readAttribute(groupId, "size", H5T_NATIVE_INT, - intBuffer); - - // Initialize the assembly. - ReflectorAssembly assembly = new ReflectorAssembly( - assemblyName, size); - - /* --- Read the assembly's attributes. --- */ - // Attributes inherited from SFRComponent. - readSFRComponent(assembly, groupId); - - // Attributes inherited from SFRComposite. - // none - - // Attributes inherited from SFRAssembly. - // size has already been read. - assembly.setDuctThickness((Double) readAttribute(groupId, - "ductThickness", H5T_NATIVE_DOUBLE, doubleBuffer)); - - // ReflectorAssembly-specific attributes. - assembly.setRodPitch((Double) readAttribute(groupId, - "rodPitch", H5T_NATIVE_DOUBLE, doubleBuffer)); - /* --------------------------------------- */ - - /* --- Read the assembly's reactor locations. --- */ - // Add the assembly to the reactor. - reactor.addAssembly(AssemblyType.Reflector, assembly); - - // Set the assembly's locations in the reactor. - for (int location : readLocationData(groupId)) { - reactor.setAssemblyLocation(AssemblyType.Reflector, - assemblyName, location / reactor.getSize(), - location % reactor.getSize()); - } - /* ---------------------------------------------- */ - - /* --- Read the assembly's rods. --- */ - // Open the group that holds the rods. - groupId = groupIds.push(openGroup(groupId, "Rods")); - - // Loop over the child groups in this assembly's Rods group. - // These groups should have the rod names. - for (String rodName : getChildNames(groupId, H5O_TYPE_GROUP)) { - - // Open the group for this rod. - groupId = groupIds - .push(openGroup(groupIds.peek(), rodName)); - - // Initialize the rod. - SFRRod rod = new SFRRod(rodName); - - /* -- Read in the Rod's other attributes. -- */ - // Attributes inherited from SFRComponent. - readSFRComponent(rod, groupId); - - // Rod-specific attributes. - // none - /* ----------------------------------------- */ - - /* -- Read in the reflector. -- */ - groupId = openGroup(groupId, "reflector"); - rod.setReflector(readRing(groupId)); - closeGroup(groupId); - /* --------------------------- */ - - // Get the rod's groupId back. - groupId = groupIds.peek(); - - /* -- Read the rod's assembly locations. -- */ - // Add the rod to the assembly. - assembly.addRod(rod); - - // Set the rod's locations in the assembly. - for (int location : readLocationData(groupId)) { - assembly.setRodLocation(rodName, location / size, - location % size); - } - /* ---------------------------------------- */ - - // Close the group for this rod. - closeGroup(groupIds.pop()); - } - - // Close the group that holds the rods. - closeGroup(groupIds.pop()); - /* --------------------------------- */ - - /* --- Read the assembly's GridData. --- */ - groupId = groupIds.peek(); - - List gridData = new ArrayList(); - for (int row = 0; row < assembly.getSize(); row++) { - for (int column = 0; column < assembly.getSize(); column++) { - gridData.add(assembly.getDataProviderByLocation(row, - column)); - } - } - readGridData(gridData, groupId); - /* -------------------------------------- */ - - // Close the group for this assembly. - closeGroup(groupIds.pop()); - } - - // Close the group for this assembly type. - closeGroup(groupIds.pop()); - /* -------------------------------------------------- */ - - // Close the reactor's group. - closeGroup(groupIds.pop()); - - // Close the H5file. - status = H5.H5Fclose(fileId); - if (status < 0) { - throwException("Closing file \"" + path + "\"", status); - } - } catch (HDF5LibraryException e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - } - - // Return the loaded SFReactor. - return reactor; - } - - /** - *

- * Writes data from the input SFReactor into a HDF5 file. - *

- * - * @param reactor - */ - public void writeHDF5(URI uri, SFReactor reactor) { - - // Check the parameters. - if (uri == null || reactor == null) { - return; - } - // Check the file associated with the URI. If it exists, delete it. - File file = new File(uri); - String path = file.getPath(); - if (file.exists()) { - } else { - // Make sure the directory containing this file exists! If we can't - // create the directory, then quit! - String directoryName = file.getParent(); - File directory = new File(directoryName); - if (!directory.exists() && !directory.mkdirs()) { - System.err.println("SFReactorIOHandler error: Directory \"" - + directoryName + "\" could not be created."); - return; - - } - } - - // HDF5 constants. Writing out "HDF5Constants." every time is annoying. - int H5P_DEFAULT = HDF5Constants.H5P_DEFAULT; // Default flag. - int H5F_ACC_TRUNC = HDF5Constants.H5F_ACC_TRUNC; // Create, open, - // truncate. - int H5T_NATIVE_INT = HDF5Constants.H5T_NATIVE_INT; // int - int H5T_NATIVE_DOUBLE = HDF5Constants.H5T_NATIVE_DOUBLE; // double - - // The status of the previous HDF5 operation. Generally, if it is - // negative, there was some error. - int status; - - // Other IDs for HDF5 components. - int fileId, groupId; - - Stack groupIds = new Stack(); - - // Create and open the h5 file. - try { - - // Create the H5 file. This should also open it with RW-access. - status = H5 - .H5Fcreate(path, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) { - throwException("Opening file \"" + path + "\"", status); - } - fileId = status; - - // Create the group for the reactor. - groupId = groupIds.push(createGroup(fileId, "/SFReactor")); - - /* ---- Write the reactor's attributes. ---- */ - // Attributes inherited from SFRComponent. - writeSFRComponent(reactor, groupId); - - // Attributes inherited from SFRComposite. - // none - - // SFReactor-specific attributes. - writeAttribute(groupId, "size", H5T_NATIVE_INT, - new int[] { reactor.getSize() }); - writeAttribute(groupId, "latticePitch", H5T_NATIVE_DOUBLE, - new double[] { reactor.getLatticePitch() }); - writeAttribute(groupId, "outerFlatToFlat", H5T_NATIVE_DOUBLE, - new double[] { reactor.getOuterFlatToFlat() }); - /* ----------------------------------------- */ - - /* ---- Write the reactor's Pin Assemblies. ---- */ - List pinAssemblyTypes = new ArrayList(); - pinAssemblyTypes.add(AssemblyType.Fuel); - pinAssemblyTypes.add(AssemblyType.Control); - pinAssemblyTypes.add(AssemblyType.Shield); - pinAssemblyTypes.add(AssemblyType.Test); - - for (AssemblyType assemblyType : pinAssemblyTypes) { - // Create a group for this assembly type. - groupId = groupIds.push(createGroup(groupIds.peek(), - assemblyType.toString())); - - for (String assemblyName : reactor - .getAssemblyNames(assemblyType)) { - - // Get the assembly object from the reactor. - PinAssembly assembly = (PinAssembly) reactor - .getAssemblyByName(assemblyType, assemblyName); - - // Create a group for this assembly. - groupId = groupIds.push(createGroup(groupIds.peek(), - assemblyName)); - - /* --- Write the assembly's attributes. --- */ - // Attributes inherited from SFRComponent. - writeSFRComponent(assembly, groupId); - - // Attributes inherited from SFRComposite. - // none - - // Attributes inherited from SFRAssembly. - writeAttribute(groupId, "size", H5T_NATIVE_INT, - new int[] { assembly.getSize() }); - writeAttribute(groupId, "ductThickness", H5T_NATIVE_DOUBLE, - new double[] { assembly.getDuctThickness() }); - - // PinAssembly-specific attributes. - writeAttribute(groupId, "pinPitch", H5T_NATIVE_DOUBLE, - new double[] { assembly.getPinPitch() }); - writeAttribute(groupId, "pinType", H5T_NATIVE_INT, - new int[] { assembly.getPinType().getId() }); - writeAttribute(groupId, "innerDuctFlatToFlat", - H5T_NATIVE_DOUBLE, - new double[] { assembly.getInnerDuctFlatToFlat() }); - writeAttribute(groupId, "innerDuctThickness", - H5T_NATIVE_INT, - new double[] { assembly.getInnerDuctThickness() }); - /* ---------------------------------------- */ - - /* --- Write the assembly's reactor locations. --- */ - writeLocationData(reactor.getAssemblyLocations( - assemblyType, assemblyName), groupId); - /* ----------------------------------------------- */ - - // Create a group to hold the pins. - groupId = groupIds - .push(createGroup(groupIds.peek(), "Pins")); - - /* --- Write the assembly's rods/pins. --- */ - for (String pinName : assembly.getPinNames()) { - - // Get the pin object from the assembly. - SFRPin pin = assembly.getPinByName(pinName); - - // Create a group for the pin. - groupId = groupIds.push(createGroup(groupIds.peek(), - pinName)); - - /* -- Write the pin's attributes. -- */ - // Attributes inherited from SFRComponent. - writeSFRComponent(pin, groupId); - - // Pin-specific attributes. - // none - /* --------------------------------- */ - - /* -- Write the pin's physical properties. -- */ - // Material fillGas - Material fillGas = pin.getFillGas(); - groupId = groupIds.push(createGroup(groupIds.peek(), - "fillGas")); - writeSFRComponent(fillGas, groupId); - closeGroup(groupIds.pop()); - - // Ring cladding - Ring cladding = pin.getCladding(); - groupId = groupIds.push(createGroup(groupIds.peek(), - "cladding")); - writeRing(cladding, groupId); - closeGroup(groupIds.pop()); - - // TreeSet materialBlocks - groupId = groupIds.push(createGroup(groupIds.peek(), - "materialBlocks")); - int i = 0; - for (MaterialBlock block : pin.getMaterialBlocks()) { - // Create a Group for the MaterialBlock. - groupId = groupIds.push(createGroup( - groupIds.peek(), Integer.toString(i++))); - - // Write the block's SFRComponent attributes. - writeSFRComponent(block, groupId); - - // Write the block's other attributes. - writeAttribute(groupId, "vertPosition", - H5T_NATIVE_DOUBLE, - new Double[] { block.getVertPosition() }); - - // Create a group to contain the Rings. - groupIds.push(createGroup(groupId, "Rings")); - - // Write the block's rings. - int j = 0; - for (Ring ring : block.getRings()) { - groupId = groupIds - .push(createGroup(groupIds.peek(), - Integer.toString(j++))); - writeRing(ring, groupId); - closeGroup(groupIds.pop()); - } - - // Close the group that contains the Rings. - closeGroup(groupIds.pop()); - - // Close the group for the MaterialBlock. - closeGroup(groupIds.pop()); - } - closeGroup(groupIds.pop()); - /* ------------------------------------------ */ - - // Get the group ID back (subgroups have been created). - groupId = groupIds.peek(); - - /* -- Write the pin's assembly locations. -- */ - writeLocationData(assembly.getPinLocations(pinName), - groupId); - /* ----------------------------------------- */ - - // Close the group for the pin. - closeGroup(groupIds.pop()); - } - /* --------------------------------------- */ - - // Close the group containing the pins. - closeGroup(groupIds.pop()); - - /* --- Write the assembly's GridData. --- */ - groupId = groupIds.peek(); - - List gridData = new ArrayList(); - for (int row = 0; row < assembly.getSize(); row++) { - for (int column = 0; column < assembly.getSize(); column++) { - gridData.add(assembly.getDataProviderByLocation( - row, column)); - } - } - writeGridData(gridData, groupId); - /* -------------------------------------- */ - - // Close this assembly group. - closeGroup(groupIds.pop()); - } - - // Close the group for this assembly type. - closeGroup(groupIds.pop()); - } - /* --------------------------------------------- */ - - /* ---- Write the reactor's Reflector Assemblies. ---- */ - // Create a group for this assembly type. - groupId = groupIds.push(createGroup(groupIds.peek(), - AssemblyType.Reflector.toString())); - - for (String assemblyName : reactor - .getAssemblyNames(AssemblyType.Reflector)) { - - // Get the assembly object from the reactor. - ReflectorAssembly assembly = (ReflectorAssembly) reactor - .getAssemblyByName(AssemblyType.Reflector, assemblyName); - - // Create a group for this assembly. - groupId = groupIds.push(createGroup(groupIds.peek(), - assemblyName)); - - /* --- Write the assembly's attributes. --- */ - // Attributes inherited from SFRComponent. - writeSFRComponent(assembly, groupId); - - // Attributes inherited from SFRComposite. - // none - - // Attributes inherited from SFRAssembly. - writeAttribute(groupId, "size", H5T_NATIVE_INT, - new int[] { assembly.getSize() }); - writeAttribute(groupId, "ductThickness", H5T_NATIVE_DOUBLE, - new double[] { assembly.getDuctThickness() }); - - // ReflectorAssembly-specific attributes. - writeAttribute(groupId, "rodPitch", H5T_NATIVE_DOUBLE, - new double[] { assembly.getRodPitch() }); - /* ---------------------------------------- */ - - /* --- Write the assembly's reactor locations. --- */ - writeLocationData(reactor.getAssemblyLocations( - AssemblyType.Reflector, assemblyName), groupId); - /* ----------------------------------------------- */ - - // Create a group to hold the pins. - groupId = groupIds.push(createGroup(groupIds.peek(), "Rods")); - - /* --- Write the assembly's rods/pins. --- */ - for (String rodName : assembly.getRodNames()) { - - // Get the rod object from the assembly. - SFRRod rod = assembly.getRodByName(rodName); - - // Create a group for the rod. - groupId = groupIds.push(createGroup(groupIds.peek(), - rodName)); - - /* -- Write the rod's attributes. -- */ - // Attributes inherited from SFRComponent. - writeSFRComponent(rod, groupId); - - // Rod-specific attributes. - // none - /* --------------------------------- */ - - /* -- Write the rod's physical properties. -- */ - // Ring reflector. - Ring reflector = rod.getReflector(); - groupId = groupIds.push(createGroup(groupIds.peek(), - "reflector")); - writeRing(reflector, groupId); - closeGroup(groupIds.pop()); - /* ------------------------------------------ */ - - // Get the group ID back (subgroups have been created). - groupId = groupIds.peek(); - - /* -- Write the rod's assembly locations. -- */ - writeLocationData(assembly.getRodLocations(rodName), - groupId); - /* ----------------------------------------- */ - - // Close the group for the rod. - closeGroup(groupIds.pop()); - } - /* --------------------------------------- */ - - // Close the group containing the rods. - closeGroup(groupIds.pop()); - - /* --- Write the assembly's GridData. --- */ - groupId = groupIds.peek(); - - List gridData = new ArrayList(); - for (int row = 0; row < assembly.getSize(); row++) { - for (int column = 0; column < assembly.getSize(); column++) { - gridData.add(assembly.getDataProviderByLocation(row, - column)); - } - } - writeGridData(gridData, groupId); - /* -------------------------------------- */ - - // Close this assembly group. - closeGroup(groupIds.pop()); - } - - // Close the group for this assembly type. - closeGroup(groupIds.pop()); - /* --------------------------------------------------- */ - - // Close the reactor group. - closeGroup(groupIds.pop()); - - // Close the H5file. - status = H5.H5Fclose(fileId); - if (status < 0) { - throwException("Closing file \"" + path + "\"", status); - } - } catch (HDF5LibraryException e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (HDF5Exception e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - } - - return; - } - - /** - * This utility method throws an HDF5LibraryException with a custom message. - * - * @param message - * The message to append to the exception. - * @param status - * The integer flag that indicated a problem. This is usually a - * negative number. - * @throws HDF5LibraryException - */ - private void throwException(String message, int status) - throws HDF5LibraryException { - throw new HDF5LibraryException("SFReactorIOHandler error: " + message - + ": " + Integer.toString(status)); - } - - /** - * Opens an HDF5 Group. - * - * @param parentId - * The ID of the parent's Group, which should be open itself. - * @param name - * The name of the Group to open. - * @return The ID of the newly-opened Group. - * @throws HDF5LibraryException - * @throws NullPointerException - */ - private int openGroup(int parentId, String name) - throws HDF5LibraryException, NullPointerException { - int status = H5.H5Gopen(parentId, name, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Opening group \"" + name + "\"", status); - } - return status; - } - - /** - * Creates and opens an HDF5 Group. - * - * @param parentId - * The ID of the parent's Group, which should be open itself. - * @param name - * The name of the Group to open. - * @return The ID of the newly-opened Group. - * @throws HDF5LibraryException - * @throws NullPointerException - */ - private int createGroup(int parentId, String name) - throws HDF5LibraryException, NullPointerException { - int status = H5.H5Gcreate(parentId, name, HDF5Constants.H5P_DEFAULT, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Creating group \"" + name + "\"", status); - } - return status; - } - - /** - * Closes an HDF5 Group. - * - * @param groupId - * The ID of the Group to close. - * @throws HDF5LibraryException - */ - private void closeGroup(int groupId) throws HDF5LibraryException { - int status = H5.H5Gclose(groupId); - if (status < 0) { - throwException("Closing group \"/SFReactor\"", status); - } - return; - } - - /** - * Gets a List of all child Objects of an HDF5 Group with the specified ID - * and type. - * - * @param parentId - * The ID of the parent Group. - * @param objectType - * The type of object we are looking for, e.g., H5O_TYPE_GROUP or - * H5O_TYPE_DATASET. - * @return A List of names of all child objects that are HDF5 Groups. - * @throws HDF5LibraryException - */ - private List getChildNames(int parentId, int objectType) - throws HDF5LibraryException { - - // Constants used below. - String parentGroup = "."; - int indexType = HDF5Constants.H5_INDEX_NAME; - int indexOrder = HDF5Constants.H5_ITER_INC; - int lapl_id = HDF5Constants.H5P_DEFAULT; - - // Get the number of members in this group. - int status = H5.H5Gn_members(parentId, "."); - if (status < 0) { - throwException("Getting number of children of group with ID " - + parentId + "", status); - } - int nMembers = status; - - // A List of group names within the parent group (which has ID groupId). - List groupNames = new ArrayList(nMembers); - - // Loop over the possible indexes. - for (int i = 0; i < nMembers; i++) { - // Get the info for the object in this position. - H5O_info_t info = H5.H5Oget_info_by_idx(parentId, parentGroup, - indexType, indexOrder, i, lapl_id); - - // See if the object exists and is an HDF5 Group. - if (info != null && info.type == objectType) { - - // Get the name and add it to the List if possible. - String name = H5.H5Lget_name_by_idx(parentId, parentGroup, - indexType, indexOrder, i, lapl_id); - if (name != null) { - groupNames.add(name); - } - } - } - - return groupNames; - } - - /** - * Writes an Attribute for an HDF5 Object, which is typically a Group. Array - * Attributes are not supported. - * - * @param objectId - * The ID for the Object, which should be open, that will get the - * Attribute. - * @param name - * The name of the Attribute. - * @param type - * The HDF5 datatype of the Attribute. Currently supported are - * H5T_NATIVE_INT and H5T_NATIVE_DOUBLE. - * @param buffer - * The buffer used by HDF5 to write the Attribute to the file. - * This should be an array of the appropriate type, e.g., an - * int[1] for an H5T_NATIVE_INT. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void writeAttribute(int objectId, String name, int type, - Object buffer) throws NullPointerException, HDF5Exception { - int status; - - // Create the buffer that holds the data to write to the attribute. - long[] bufferSize = new long[] { 1 }; - - // Create the dataspace to hold the value. - status = H5.H5Screate_simple(1, bufferSize, null); - if (status < 0) { - throwException("Creating dataspace for attribute \"" + name + "\"", - status); - } - int dataspaceId = status; - - // Create the attribute for the dataspace. - status = H5.H5Acreate(objectId, name, type, dataspaceId, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Creating attribute \"" + name + "\"", status); - } - int attributeId = status; - - // Write the attribute. - status = H5.H5Awrite(attributeId, type, buffer); - if (status < 0) { - throwException("Writing attribute \"" + name + "\"", status); - } - - // Close the attribute. - status = H5.H5Aclose(attributeId); - if (status < 0) { - throwException("Closing attribute \"" + name + "\"", status); - } - - // Close the dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException("Closing dataspace for attribute \"" + name + "\"", - status); - } - - return; - } - - /** - * Reads an Attribute for an HDF5 Object, which is typically a Group. Array - * Attributes are not supported. - * - * @param objectId - * The ID for the Object, which should be open, that has the - * Attribute. - * @param name - * The name of the Attribute. - * @param type - * The HDF5 datatype of the Attribute. Currently supported are - * H5T_NATIVE_INT and H5T_NATIVE_DOUBLE. - * @param buffer - * The buffer used by HDF5 to read the Attribute from the file. - * This should be an array of the appropriate type, e.g., an - * Tnteger[1] for an H5T_NATIVE_INT. - * @return Returns the first element in the buffer (buffer[0]), which is the - * value of the Attribute. - * @throws NullPointerException - * @throws HDF5Exception - */ - private Object readAttribute(int objectId, String name, int type, - Object[] buffer) throws NullPointerException, HDF5Exception { - int status; - - // Open the attribute. - status = H5.H5Aopen(objectId, name, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Opening attribute \"" + name + "\"", status); - } - int attributeId = status; - - // Read the attribute. - status = H5.H5Aread(attributeId, type, buffer); - if (status < 0) { - throwException("Reading attribute \"" + name + "\"", status); - } - // Close the attribute. - status = H5.H5Aclose(attributeId); - if (status < 0) { - throwException("Closing attribute \"" + name + "\"", status); - } - return buffer[0]; - } - - /** - * Writes a String as an Attribute for an HDF5 Object, which is typically a - * Group. This requires a special method because the String must first be - * converted to a byte array. - * - * @param objectId - * The ID for the Object, which should be open, that will get the - * Attribute. - * @param name - * The name of the Attribute. - * @param value - * The String value of the Attribute. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void writeStringAttribute(int objectId, String name, String value) - throws NullPointerException, HDF5Exception { - int status; - // HDF5 requires null-terminated strings. Unfortunately, Java's - // String.getBytes() method does not return a byte array that includes a - // null character in the last position, so we have to create a new - // buffer that includes all bytes from the string and a null (0) byte. - - // Method 1: Create byte array of correct size, then copy string bytes - // to byte array. - - // Methd 2: Create array from a new string that has the null character. - byte[] buffer = (value + "\0").getBytes(); - - // We have 1 string, so set rank to 1 and the length of the 1st - // dimension is 1. - int rank = 1; - long[] dims = new long[] { 1 }; - - // Create the dataspace to hold the value. - status = H5.H5Screate_simple(rank, dims, null); - if (status < 0) { - throwException("Creating dataspace for attribute \"" + name + "\"", - status); - } - int dataspaceId = status; - - // Create the datatype for the attribute. Note that we include the size - // of the string byte buffer that includes the null character. - status = H5.H5Tcreate(HDF5Constants.H5T_STRING, buffer.length); - if (status < 0) { - throwException("Creating datatype for attribute \"" + name + "\"", - status); - } - int datatypeId = status; - - // FIXME I don't think this is necessary, but it may be! - // H5.H5Tset_strpad(datatypeId, HDF5Constants.H5T_STR_NULLTERM); - - // Create the attribute for the dataspace. - status = H5.H5Acreate(objectId, name, datatypeId, dataspaceId, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Creating attribute \"" + name + "\"", status); - } - int attributeId = status; - - // Write the attribute. - status = H5.H5Awrite(attributeId, datatypeId, buffer); - if (status < 0) { - throwException("Writing attribute \"" + name + "\"", status); - } - - // Close the attribute. - status = H5.H5Aclose(attributeId); - if (status < 0) { - throwException("Closing attribute \"" + name + "\"", status); - } - - // Close the datatype. - status = H5.H5Tclose(datatypeId); - if (status < 0) { - throwException("Closing datatype for attribute \"" + name + "\"", - status); - } - - // Close the dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException("Closing dataspace for attribute \"" + name + "\"", - status); - } - - return; - } - - /** - * Reads a String Attribute from an HDF5 Object, which is typically a Group. - * This requires a special method because the String must first be converted - * to a byte array. - * - * @param objectId - * The ID for the Object, which should be open, that has the - * Attribute. - * @param name - * The name of the Attribute. - * @return The value of the String stored in the Attribute. - * @throws NullPointerException - * @throws HDF5Exception - */ - private String readStringAttribute(int objectId, String name) - throws NullPointerException, HDF5Exception { - int status; - - // Open the attribute. - status = H5.H5Aopen(objectId, name, HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Opening attribute \"" + name + "\"", status); - } - int attributeId = status; - - // Get the datatype for the String (H5T_STRING with a size in bytes). - status = H5.H5Aget_type(attributeId); - if (status < 0) { - throwException("Reading datatype for attribute \"" + name + "\"", - status); - } - int datatypeId = status; - - // Get the size of the String from the datatype. - status = H5.H5Tget_size(datatypeId); - if (status <= 0) { - throwException("Reading size of datatype for attribute \"" + name - + "\"", status); - } - int size = status; - - // Initialize the buffer. - byte[] buffer = new byte[size]; - - // Read the attribute. - status = H5.H5Aread(attributeId, datatypeId, buffer); - if (status < 0) { - throwException("Reading attribute \"" + name + "\"", status); - } - - // Close the attribute. - status = H5.H5Aclose(attributeId); - if (status < 0) { - throwException("Closing attribute \"" + name + "\"", status); - } - - // Convert the buffer into a String. The null character is only required - // inside HDF5, so strip the null character. - return new String(buffer, 0, size - 1); - } - - /** - * This method writes an HDF5 Dataset containing the data that is stored in - * a buffer. All of the data's properties and the buffer must be allocated - * before calling this method. - * - * @param objectId - * The ID for the Object, which should be open, that will get the - * Dataset. - * @param name - * The name of the Dataset. - * @param rank - * The number of dimensions in the data. - * @param dims - * An array containing the sizes of each dimension in the data. - * @param type - * The HDF5 datatype of the data in the Dataset, e.g., - * H5T_NATIVE_INT or H5T_NATIVE_DOUBLE. This may also be an ID - * for an opened Datatype, e.g., an array of Strings (byte - * arrays). - * @param buffer - * The buffer that contains the data to write. This needs to be - * an array, e.g., a double[n]. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void writeDataset(int objectId, String name, int rank, long[] dims, - int type, Object buffer) throws NullPointerException, HDF5Exception { - int status; - - // Create the dataspace. - status = H5.H5Screate_simple(rank, dims, null); - if (status < 0) { - throwException("Creating dataspace for dataset \"" + name + "\"", - status); - } - int dataspaceId = status; - - // Create the dataset. - status = H5.H5Dcreate(objectId, name, type, dataspaceId, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, - HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException("Creating dataset \"" + name + "\"", status); - } - int datasetId = status; - - // Write the dataset. - status = H5.H5Dwrite(datasetId, type, HDF5Constants.H5S_ALL, - HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, buffer); - if (status < 0) { - throwException("Writing dataset \"" + name + "\"", status); - } - - // Close the dataset. - status = H5.H5Dclose(datasetId); - if (status < 0) { - throwException("Closing dataset \"" + name + "\"", status); - } - - // Close the dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException("Closing dataspace for dataset \"" + name + "\"", - status); - } - - return; - } - - /** - * Writes all of the properties and data stored for an SFRComponent. - * - * @param component - * An initialized SFRComponent from which to write data. - * @param groupId - * The ID of the SFRComponent's HDF5 Group, which should be open. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void writeSFRComponent(SFRComponent component, int groupId) - throws NullPointerException, HDF5Exception { - /* ---- Write the component's properties. ---- */ - writeStringAttribute(groupId, "name", component.getName()); - writeStringAttribute(groupId, "description", component.getDescription()); - writeAttribute(groupId, "id", HDF5Constants.H5T_NATIVE_INT, - new int[] { component.getId() }); - writeStringAttribute(groupId, "sourceInfo", component.getSourceInfo()); - writeAttribute(groupId, "time", HDF5Constants.H5T_NATIVE_DOUBLE, - new double[] { component.getCurrentTime() }); - writeStringAttribute(groupId, "timeUnits", component.getTimeUnits()); - /* ------------------------------------------- */ - - /* ---- Write the data. ---- */ - // Create a Group to contain the feature data. - int dataGroupId = createGroup(groupId, "Data"); - - // Write the component's data. - writeDataProvider(component, dataGroupId); - - // Close the feature data Group. - closeGroup(dataGroupId); - /* ------------------------- */ - - return; - } - - /** - * Reads all of the properties and data into an SFRComponent. - * - * @param component - * An initialized SFRComponent to read data into. - * @param groupId - * The ID of the SFRComponent's HDF5 Group, which should be open. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void readSFRComponent(SFRComponent component, int groupId) - throws NullPointerException, HDF5Exception { - /* ---- Read in the component's properties. ---- */ - component.setName(readStringAttribute(groupId, "name")); - component.setDescription(readStringAttribute(groupId, "description")); - component.setId((Integer) readAttribute(groupId, "id", - HDF5Constants.H5T_NATIVE_INT, new Integer[1])); - component.setSourceInfo(readStringAttribute(groupId, "sourceInfo")); - component.setTime((Double) readAttribute(groupId, "time", - HDF5Constants.H5T_NATIVE_DOUBLE, new Double[1])); - component.setTimeUnits(readStringAttribute(groupId, "timeUnits")); - /* --------------------------------------------- */ - - /* ---- Read the data. ---- */ - // Open the data Group. - int dataGroupId = openGroup(groupId, "Data"); - - // Read the component's data. - readDataProvider(component, dataGroupId); - - // Close the data Group. - closeGroup(dataGroupId); - /* ------------------------ */ - - return; - } - - /** - * Writes the data for a GridDataManager from a pre-constructed List of - * IDataProviders (SFRComponents). - * - * @param providers - * A List of IDataProviders to write the data from. - * @param groupId - * The ID of the parent HDF5 Group, which should be open. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void writeGridData(List providers, int groupId) - throws NullPointerException, HDF5Exception { - - // Create a GridData Group. - int gridDataGroupId = createGroup(groupId, "GridData"); - - // Write all of the IDataProviders' data. - for (int i = 0; i < providers.size(); i++) { - - // Skip non-existent providers (these are places where no pin/rod is - // set). - SFRComponent provider = providers.get(i); - if (provider != null) { - // Create a Group to hold the position's data. - int providerGroupId = createGroup(gridDataGroupId, - Integer.toString(i)); - - // Write the provider. - writeDataProvider(provider, providerGroupId); - - // Close the IDataProvider's group. - closeGroup(providerGroupId); - } - } - - // Close the GridData Group. - closeGroup(gridDataGroupId); - - return; - } - - /** - * Writes all of the data from an IDataProvider (implemented by - * SFRComponent). - * - * @param provider - * The IDataProvider to write the data from. - * @param groupId - * The ID of the parent HDF5 Group, which should be open. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void writeDataProvider(SFRComponent provider, int groupId) - throws NullPointerException, HDF5Exception { - - // Get the times. - ArrayList times = provider.getTimes(); - double currentTime = provider.getCurrentTime(); - - // Use a Map to keep track of the different units used. - double unitsCount = 0; - Map unitsMap = new HashMap(); - List unitsList = new ArrayList(2); - int unitsStringLength = 0; - - // Default properties defining the Dataset of doubles. - int rank = 2; - long[] dims = new long[] { 0, 6 }; - int type = HDF5Constants.H5T_NATIVE_DOUBLE; - - for (String feature : provider.getFeatureList()) { - // Create a group to contain state point data. - int featureGroupId = createGroup(groupId, feature); - - // Loop over the possible times. - for (double time : times) { - provider.setTime(time); - - // Get the data from the pin. - ArrayList dataList = provider - .getDataAtCurrentTime(feature); - int length = dataList.size(); - - // Construct the buffer of data for HDF5 writing. - double[] dataBuffer = new double[dataList.size() * 6]; - int bufferIndex = 0; - for (IData data : dataList) { - dataBuffer[bufferIndex++] = data.getValue(); - dataBuffer[bufferIndex++] = data.getUncertainty(); - dataBuffer[bufferIndex++] = data.getPosition().get(0); - dataBuffer[bufferIndex++] = data.getPosition().get(1); - dataBuffer[bufferIndex++] = data.getPosition().get(2); - - // Get the units. - String units = data.getUnits(); - - // Get the units ID from the Map. If the units are not in - // the Map, then we need to add it. - if (unitsMap.containsKey(units)) { - dataBuffer[bufferIndex++] = unitsMap.get(units); - } else { - unitsMap.put(units, unitsCount); - unitsList.add(units); - dataBuffer[bufferIndex++] = unitsCount++; - if (units.length() > unitsStringLength) { - unitsStringLength = units.length(); - } - } - } - - // Store the length (rows) of the array of data. - dims[0] = length; - - // Write the state point data for this feature. - writeDataset(featureGroupId, Double.toString(time), rank, dims, - type, dataBuffer); - } - - // Close the state point data group. - closeGroup(featureGroupId); - } - - // Write the units lookup Dataset if we have units. - // FIXME - I'm not yet sure how to get variable length String Datasets - // to work with the HDF5 Java library. Instead, we can compute the max - // String length for the units above and write a Dataset of fixed-length - // Strings. - if (unitsCount > 0) { - - // This is a simple array. The index is the ID of the String. - rank = 1; - dims = new long[] { (long) unitsCount }; - - // The byte arrays that will contain the unit strings will need to - // be big enough to contain the longest unit string + a null - // character. - int nullTermLength = unitsStringLength + 1; - - // Create the Datatype for all elements in the Dataset. - type = H5.H5Tcreate(HDF5Constants.H5T_STRING, nullTermLength); - - // The buffer for the bytes is necessary because HDF5 does not - // support Java Strings, but C-style, null-terminated strings. Note - // that the buffer allocation already initializes all the bytes to - // zero (null). - byte[][] unitsBuffer = new byte[(int) unitsCount][nullTermLength]; - for (int i = 0, j = 0; i < (int) unitsCount; i++, j = 0) { - // We need to manually copy each string's bytes to the buffer. - // Note that j is the index for the current string character. - for (byte b : unitsList.get(i).getBytes()) { - unitsBuffer[i][j++] = b; - } - } - - // Write the Units dataset. - writeDataset(groupId, "Units", rank, dims, type, unitsBuffer); - - // Close the Datatype. - H5.H5Tclose(type); - } - // Restore the current time. - provider.setTime(currentTime); - - return; - } - - /** - * Reads in the data for a GridDataManager into a pre-constructed List of - * IDataProviders (SFRComponents). - * - * @param providers - * A List of IDataProviders to read the data into. - * @param groupId - * The ID of the parent HDF5 Group, which should be open. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void readGridData(List providers, int groupId) - throws NullPointerException, HDF5Exception { - - // Open the GridData Group. - int gridDataGroupId = openGroup(groupId, "GridData"); - - // Write all of the IDataProviders' data. - for (int i = 0; i < providers.size(); i++) { - - // Skip non-existent providers (these are places where no pin/rod is - // set). - SFRComponent provider = providers.get(i); - if (provider != null) { - // Open the Group holding the position's data. - int providerGroupId = openGroup(gridDataGroupId, - Integer.toString(i)); - - // Read the provider. - readDataProvider(provider, providerGroupId); - - // Close the IDataProvider's group. - closeGroup(providerGroupId); - } - } - - // Close the GridData Group. - closeGroup(gridDataGroupId); - - return; - } - - /** - * Reads all of the data in for an IDataProvider (implemented by - * SFRComponent). - * - * @param provider - * The IDataProvider to read the data into. - * @param groupId - * The ID of the parent HDF5 Group, which should be open. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void readDataProvider(SFRComponent provider, int groupId) - throws NullPointerException, HDF5Exception { - int status; - - // Commonly-used constants. - int H5P_DEFAULT = HDF5Constants.H5P_DEFAULT; - int H5S_ALL = HDF5Constants.H5S_ALL; - - /* ---- Read in the list of names of Units for the data. ---- */ - // An array to hold the units Strings. - String[] units = null; - - // See if the Units Dataset exists. If it does, read it in. - if (H5.H5Lexists(groupId, "Units", H5P_DEFAULT)) { - - // Open the Dataset. - status = H5.H5Dopen(groupId, "Units", H5P_DEFAULT); - if (status < 0) { - throwException("Opening units Dataset for IDataProvider.", - status); - } - int datasetId = status; - - // Open the Dataspace. - status = H5.H5Dget_space(datasetId); - if (status < 0) { - throwException( - "Opening dataspace for units dataset for IDataProvider.", - status); - } - int dataspaceId = status; - - // Initialize the properties defining the Dataspace. - int rank = 1; - long[] dims = new long[1]; - - // Get the size (rows) of the Dataset. - status = H5.H5Sget_simple_extent_dims(dataspaceId, dims, null); - if (status != rank) { - throwException( - "Getting size of units dataset for IDataProvider.", - status); - } - - // Open the Datatype. - status = H5.H5Dget_type(datasetId); - if (status < 0) { - throwException( - "Opening datatype for units dataset for IDataProvider.", - status); - } - int typeId = status; - - status = H5.H5Tget_size(typeId); - if (status < 0) { - throwException( - "Getting size of datatype for units dataset for IDataProvider.", - status); - } - int stringLength = status; - - int rows = (int) dims[0]; - // Initialize the buffer. - byte[][] buffer = new byte[rows][stringLength]; - - // Read in the Dataset. - status = H5.H5Dread(datasetId, typeId, H5S_ALL, H5S_ALL, - H5P_DEFAULT, buffer); - if (status < 0) { - throwException("Reading units Dataset for IDataProvider.", - status); - } - - // Close the Datatype. - status = H5.H5Tclose(typeId); - if (status < 0) { - throwException( - "Closing datatype for units dataset for IDataProvider.", - status); - } - - // Close the dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException( - "Closing dataspace for units dataset for IDataProvider.", - status); - } - - // Close the Dataset. - status = H5.H5Dclose(datasetId); - if (status < 0) { - throwException("Closing units Dataset for IDataProvider.", - status); - } - - // Fill out the array of units Strings. This converts each byte - // array into a String. - units = new String[rows]; - for (int i = 0; i < rows; i++) { - // Determine how long the string actually is by finding the - // first null terminating character. - int j = 0; - for (j = 0; j < stringLength; j++) { - if (buffer[i][j] == 0) { - break; - } - } - // Create the string from the buffer, excluding the null - // character. - units[i] = new String(buffer[i], 0, j); - } - } - /* ---------------------------------------------------------- */ - - /* ---- Read in the data for each feature. ---- */ - // Loop over the groups in the Data group. These groups are named after - // the feature whose data they contain. - for (String feature : getChildNames(groupId, - HDF5Constants.H5O_TYPE_GROUP)) { - - // Open the feature group. - int featureGroupId = openGroup(groupId, feature); - - // Get the list of times. - for (String timeString : getChildNames(featureGroupId, - HDF5Constants.H5O_TYPE_DATASET)) { - - // Open the dataset. - status = H5.H5Dopen(featureGroupId, timeString, H5P_DEFAULT); - if (status < 0) { - throwException("Opening dataset for IDataProvider.", status); - } - int datasetId = status; - - // Open the dataspace. - status = H5.H5Dget_space(datasetId); - if (status < 0) { - throwException("Opening dataspace for IDataProvider.", - status); - } - int dataspaceId = status; - - // Initialize the properties defining the dataspace. - int rank = 2; - long[] dims = new long[2]; - int type = HDF5Constants.H5T_NATIVE_DOUBLE; - - // Get the size of the data array. - status = H5.H5Sget_simple_extent_dims(dataspaceId, dims, null); - if (status != rank || dims[1] != 6) { - throwException( - "Reading dataspace dimensions for IDataProvider.", - status); - } - - // Initialize the buffer. - int size = (int) dims[0]; - double[][] buffer = new double[size][6]; - - // Read in the data into the buffer. - status = H5.H5Dread(datasetId, type, H5S_ALL, H5S_ALL, - H5P_DEFAULT, buffer); - if (status < 0) { - throwException("Reading dataset for IDataProvider.", status); - } - // Close the dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException("Closing dataspace for IDataProvider.", - status); - } - // Close the dataset. - status = H5.H5Dclose(datasetId); - if (status < 0) { - throwException("Closing dataset for IDataProvider.", status); - } - double time = Double.parseDouble(timeString); - - // Initialize the IData for the timestep. - for (double[] dataBlock : buffer) { - // Initialize an iData. - SFRData data = new SFRData(feature); - - // Set its data. - data.setValue(dataBlock[0]); - data.setUncertainty(dataBlock[1]); - ArrayList position = new ArrayList(3); - position.add(dataBlock[2]); - position.add(dataBlock[3]); - position.add(dataBlock[4]); - data.setPosition(position); - - // Set the units from the pre-constructed array of data. - data.setUnits(units[(int) dataBlock[5]]); - - // Add it to the component. - provider.addData(data, time); - } - } - // Close the feature group. - closeGroup(featureGroupId); - } - /* -------------------------------------------- */ - - return; - } - - /** - * Writes a List of locations, stored as Integers, as a Dataset. - * - * @param locations - * The List of location indexes to write. - * @param groupId - * The ID of the HDF5 Group, which should be open, in which to - * store the location data. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void writeLocationData(ArrayList locations, int groupId) - throws NullPointerException, HDF5Exception { - int length = locations.size(); - - // Set up the buffer for the H5 write operation. - int[] buffer = new int[length]; - for (int i = 0; i < length; i++) { - buffer[i] = locations.get(i); - } - // These properties define the dataspace. - int rank = 1; - long[] dims = new long[] { length }; - int type = HDF5Constants.H5T_NATIVE_INT; - - // Write the dataset. - writeDataset(groupId, "locations", rank, dims, type, buffer); - - return; - } - - /** - * Reads a List of locations, stored as Integers, from a Dataset. - * - * @param groupId - * The ID of the HDF5 Group, which should be open, that holds the - * location Dataset. - * @return Returns an Array (int[]) containing the location data straight - * from the Dataset. - * @throws NullPointerException - * @throws HDF5Exception - */ - private int[] readLocationData(int groupId) throws NullPointerException, - HDF5Exception { - int status; - - // Open the dataset. - status = H5.H5Dopen(groupId, "locations", HDF5Constants.H5P_DEFAULT); - if (status < 0) { - throwException( - "Opening dataset for location data in group with id " - + groupId, status); - } - int datasetId = status; - - // Open the dataspace. - status = H5.H5Dget_space(datasetId); - if (status < 0) { - throwException( - "Opening dataspace for location data in group with id " - + groupId, status); - } - int dataspaceId = status; - - // Initialize the properties defining the dataspace. - int rank = 1; - long[] dims = new long[1]; - int type = HDF5Constants.H5T_NATIVE_INT; - - // Get the size of the location data array. - status = H5.H5Sget_simple_extent_dims(dataspaceId, dims, null); - if (status != rank) { - throwException( - "Reading dataspace dimensions for location data in group with id " - + groupId, status); - } - - // Initialize the buffer. - int size = (int) dims[0]; - int[] buffer = new int[size]; - - // Read in the location data into the buffer. - status = H5.H5Dread(datasetId, type, HDF5Constants.H5S_ALL, - HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, buffer); - if (status < 0) { - throwException( - "Reading dataset for location data in group with id " - + groupId, status); - } - - // Close the dataspace. - status = H5.H5Sclose(dataspaceId); - if (status < 0) { - throwException( - "Closing dataspace for location data in group with id " - + groupId, status); - } - - // Close the dataset. - status = H5.H5Dclose(datasetId); - if (status < 0) { - throwException( - "Closing dataset for location data in group with id " - + groupId, status); - } - - // Return the locations. - return buffer; - } - - /** - * Writes an SFR Ring to an HDF5 Group. This includes its properties and the - * Material stored in the Ring. - * - * @param ring - * The Ring to write to a file. - * @param ringGroupId - * The ID of the Ring's HDF5 Group, which should be open. - * @throws NullPointerException - * @throws HDF5Exception - */ - private void writeRing(Ring ring, int ringGroupId) - throws NullPointerException, HDF5Exception { - - // Write the basic SFRComponent attributes. - writeSFRComponent(ring, ringGroupId); - - // Write ring-specific attributes. - writeAttribute(ringGroupId, "height", HDF5Constants.H5T_NATIVE_DOUBLE, - new double[] { ring.getHeight() }); - writeAttribute(ringGroupId, "innerRadius", - HDF5Constants.H5T_NATIVE_DOUBLE, - new double[] { ring.getInnerRadius() }); - writeAttribute(ringGroupId, "outerRadius", - HDF5Constants.H5T_NATIVE_DOUBLE, - new double[] { ring.getOuterRadius() }); - - // Write the material attributes. - Material material = ring.getMaterial(); - - // Create a group, write attributes to it, and close it. - int materialGroupId = createGroup(ringGroupId, "material"); - writeSFRComponent(material, materialGroupId); - closeGroup(materialGroupId); - - return; - } - - /** - * Reads an SFR Ring from an HDF5 Group. This includes its properties and - * Material stored in the Ring. - * - * @param ringGroupId - * The ID of the Ring's HDF5 Group, which should be open - * @return A new Ring object with the properties read in from the file. - * @throws NullPointerException - * @throws HDF5Exception - */ - private Ring readRing(int ringGroupId) throws NullPointerException, - HDF5Exception { - Ring ring = new Ring(); - - // Read the basic SFRComponent attributes. - readSFRComponent(ring, ringGroupId); - - // Read ring-specific attributes. - Double[] buffer = new Double[1]; - ring.setHeight((Double) readAttribute(ringGroupId, "height", - HDF5Constants.H5T_NATIVE_DOUBLE, buffer)); - ring.setInnerRadius((Double) readAttribute(ringGroupId, "innerRadius", - HDF5Constants.H5T_NATIVE_DOUBLE, buffer)); - ring.setOuterRadius((Double) readAttribute(ringGroupId, "outerRadius", - HDF5Constants.H5T_NATIVE_DOUBLE, buffer)); - - // Read the material. - Material material = new Material(); - - // Read the material's attributes. - int materialGroupId = openGroup(ringGroupId, "material"); - readSFRComponent(material, materialGroupId); - closeGroup(materialGroupId); - - // Update the ring's material. - ring.setMaterial(material); - - return ring; - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/AssemblyType.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/AssemblyType.java deleted file mode 100644 index 4120ef0c1..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/AssemblyType.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core; - -/** - *

- * Represents the three possible types of assemblies: fuel, control or - * reflector. - *

- * - * @author Anna Wojtowicz - */ -public enum AssemblyType { - /** - * Fuel type includes burnable (inner fuel, outer - * fuel) and blanket (optional) assemblies. - * - */ - Fuel("Fuel Assembly"), - /** - * Control type includes primary and secondary - * (shutdown) assemblies. - * - */ - Control("Control Assembly"), - /** - * Reflector type contains only reflector assemblies. - * - */ - Reflector("Reflector Assembly"), - /** - * Shield type only contains shield assemblies. - * - */ - Shield("Shield Assembly"), - /** - * Test type includes materials test and fuel test - * assemblies. - * - */ - Test("Test Assembly"); - - /** - * A user-friendly String for displaying an - * AssemblyType value. - * - */ - private final String name; - - /** - * The default constructor for an AssemblyType. - * - * @param name - * The name of the assembly type. - */ - private AssemblyType(String name) { - // Set the user-friendly name String for this assembly type. - this.name = name; - - return; - } - - /** - * Override the default toString() behavior to give - * the user a better-formatted String representing this AssemblyType. - * - * @return Returns the assembly type as a String. - */ - @Override - public String toString() { - return name; - } - - /** - * Converts a String to an AssemblyType enum value. Returns null if the - * String is invalid. - * - * @param name - * The String to convert. - * @return As AssemblyType if the String is valid, null otherwise. - */ - public static AssemblyType fromString(String name) { - - AssemblyType type = null; - - if (Fuel.name.equals(name)) { - type = Fuel; - } else if (Control.name.equals(name)) { - type = Control; - } else if (Reflector.name.equals(name)) { - type = Reflector; - } else if (Shield.name.equals(name)) { - type = Shield; - } else if (Test.name.equals(name)) { - type = Test; - } - - return type; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/Material.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/Material.java deleted file mode 100644 index 50f727343..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/Material.java +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core; - -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; - -/** - *

- * Class representing the properties of any material that may be present - * throughout the reactor. Can include solid, liquid and gaseous states. - *

- * - * @author Anna Wojtowicz - */ -public class Material extends SFRComponent { - /** - *

- * Nullary constructor. - *

- * - */ - public Material() { - - // Set the name, description and ID - setName("Material 1"); - setDescription("Material 1 Description"); - setId(1); - - } - - /** - *

- * Parameterized constructor specifying the material's name. - *

- * - * @param name - * Name of the material. - */ - public Material(String name) { - - // Call the nullary constructor - this(); - - // Set the specified name - setName(name); - - } - - /** - *

- * Compares the contents of objects and returns true if they are identical, - * otherwise returns false. - *

- * - * @param otherObject - * The other object to compare against. - * @return Returns true if the two objects are equal, otherwise false. - */ - @Override - public boolean equals(Object otherObject) { - - // Check if otherObject is invalid - if (otherObject == null) { - return false; - } - // Create an equality flag, default to false - boolean areEqual = false; - - // Since this class has no variables in addition to those inherited from - // the superclass, we can just call the super.equals() method - if (super.equals(otherObject)) { - areEqual = true; - } - - // Return final result - return areEqual; - - } - - /** - *

- * Returns the hashcode of the object. - *

- * - * @return The hashcode of the object. - */ - @Override - public int hashCode() { - - // Hash based upon superclass hash - int hash = super.hashCode(); - - // Return hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - * The other object to copy the contents of. - */ - public void copy(Material otherObject) { - - // Check the material is valid - if (otherObject == null) { - return; - } - // Call the superclass copy operation - super.copy(otherObject); - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated object. - */ - @Override - public Object clone() { - - // Create a new material - Material material = new Material(); - - // Copy the contents from this material into the new one - material.copy(this); - - // Return the new material - return material; - - } - - /** - * Overrides the default behavior (ignore) from SFRComponent and implements - * the accept operation for this SFRComponent's type. - */ - @Override - public void accept(ISFRComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/MaterialBlock.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/MaterialBlock.java deleted file mode 100644 index 1993fa534..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/MaterialBlock.java +++ /dev/null @@ -1,478 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.TreeSet; - -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.core.assembly.Ring; - -/** - *

- * The MaterialBlock class is a generalized class containing a set of concentric - * and/or radial collection of Rings that constitute the circular structure(s) - * of SFRPins (in the case of a fuel or control assemblies), and SFRRods (in the - * case of reflector assemblies). - *

- * - * @author Anna Wojtowicz - */ -public class MaterialBlock extends SFRComponent implements - Comparable { - - /** - *

- * The vertical position of the MaterialBlock from the bottom of the SFRPin - * (z-displacement where z=0 at bottom). - *

- * - */ - private double vertPosition; - /** - * The collection of rings contained within each - * MaterialBlock. A TreeSet structure is used so that rings are sorted in - * ascending order of radii. Rings cannot overlap (physically impossible). - * - */ - private TreeSet rings; - - /** - *

- * Nullary constructor. - *

- * - */ - public MaterialBlock() { - - // Initialize a default name, description, and ID - setName("MaterialBlock 1"); - setDescription("MaterialBlock 1 Description"); - setId(1); - - // Initialize the z-displacement as zero - vertPosition = 0.0; - - // Create an empty TreeSet of rings - rings = new TreeSet(); - - } - - /** - *

- * Set the vertical position (z-displacement) of the material block, where - * z=0 at the bottom end of the structure. - *

- * - * @param vertPosition - * The vertical position (z-displacement) of the material block. - * Must be non-negative. - */ - public void setVertPosition(double vertPosition) { - - // Vertical position (z-displacement) must be non-negative to set - if (vertPosition >= 0.0) { - this.vertPosition = vertPosition; - } - - } - - /** - *

- * Returns the vertical position (z-displacement) of the material block as a - * double, where z=0 at the bottom end of the structure. - *

- * - * @return The vertical position (z-displacement) of the material block. - */ - public double getVertPosition() { - - // Return the vertical position (z-displacement) - return vertPosition; - } - - /** - *

- * Adds a ring object to the current collection of rings; returns true if - * the operation was successful. - *

- * - * @param ring - * The ring to be added to the material block. - * @return Returns true if the addition was successful, otherwise false. - */ - public boolean addRing(Ring ring) { - - // Check if the ring is null first - if (ring == null) { - return false; - } - // Check if ring to be added overlaps with any rings in current TreeSet. - // To do so, iterate through the TreeSet, comparing rings. - - // Initialize Iterator of rings TreeSet - Iterator i = rings.iterator(); - - // Create a cursor ring to traverse the TreeSet - Ring currRing; - - // Iterate the TreeSet as long as there's another element after it - while (i.hasNext()) { - - // Get the next ring - currRing = i.next(); - - // Check if the rings overlap at all - if (currRing.compareTo(ring) == 0) { - - // If they overlap, don't add ring to the TreeSet - return false; - } - } - - // Otherwise we can add it to the TreeSet and return true - rings.add(ring); - return true; - - } - - /** - *

- * Removes the specified ring from the collection of rings; returns true if - * the operation was successful. - *

- * - * @param name - * The name of the ring to be removed from the material block. - * @return Returns true if the removal was successful, otherwise false. - */ - public boolean removeRing(String name) { - - // Check that the ring name is valid; if not, return null - if (name == null) { - return false; - } - // Initialize an iterator to traverse through the rings TreeSet - Iterator i = rings.iterator(); - - // Create a cursor ring to traverse the TreeSet - Ring currRing; - - // Iterate the TreeSet as long as there's another element after it - while (i.hasNext()) { - - // Get the next ring - currRing = i.next(); - - // Check if the ring names are the same - if (currRing.getName().equals(name)) { - - // If names match, remove the ring and return true - rings.remove(currRing); - return true; - } - } - - // Otherwise no ring with the specified name was found; couldn't remove - // anything so return false - return false; - - } - - /** - *

- * Returns the ring that contains the specified radius in between the - * rings's inner and outer radii, otherwise returns null. - *

- * - * @param radius - * The radius which will be searched for in the collection of - * rings. - * @return Returns the ring that contains the specified radius. Returns null - * if no ring was found. - */ - public Ring getRing(double radius) { - - // Check that the ring radius is valid; if not, return null - if (radius < 0) { - return null; - } - // Initialize an iterator to traverse through the rings TreeSet - Iterator i = rings.iterator(); - - // Create a cursor ring to traverse the TreeSet - Ring currRing; - - // Iterate the TreeSet as long as there's another element after it - while (i.hasNext()) { - - // Get the next ring - currRing = i.next(); - - // Check if the specified radius falls within the inner and outer - // radii of any rings contained in the TreeSet - if (radius >= currRing.getInnerRadius() - && radius <= currRing.getOuterRadius()) { - - // If the radius is between the radii of the current ring - return currRing; - } - } - - // Otherwise no ring with the specified radius was found, return a null - return null; - - } - - /** - *

- * Returns the ring of the specified name if it exists, otherwise returns - * null. - *

- * - * @param name - * The name of the ring being searched for. - * @return Returns the ring with the specified name. Returns null if no ring - * was found. - */ - public Ring getRing(String name) { - - // Check that the ring name is valid; if not, return null - if (name == null) { - return null; - } - // Initialize an iterator to traverse through the rings TreeSet - Iterator i = rings.iterator(); - - // Create a cursor ring to traverse the TreeSet - Ring currRing; - - // Iterate the TreeSet as long as there's another element after it - while (i.hasNext()) { - - // Get the next ring - currRing = i.next(); - - // Check if the ring names are the same - if (currRing.getName().equals(name)) { - - // If names match, return the ring - return currRing; - } - } - - // Otherwise no ring with the specified name was found; return null - return null; - - } - - /** - *

- * Returns an ArrayList of Rings contained in the material block, ordered by - * ascending radii. - *

- * - * @return Returns an ArrayList of rings contained in the material block. - */ - public ArrayList getRings() { - - // Initialize an ArrayList of Rings - ArrayList list = new ArrayList(); - - // Add all the contents of rings to the list - list.addAll(rings); - - // Return the ArrayList - return list; - - } - - /** - *

- * Returns the hashcode of the object. - *

- * - * @return The hashcode of the object. - */ - @Override - public int hashCode() { - - // Hash based upon superclass hash - int hash = super.hashCode(); - - // Add the hashes for all of the variables. - hash += 31 * vertPosition; - hash += 31 * rings.hashCode(); - - // Return hash - return hash; - } - - /** - *

- * Compares the contents of objects and returns true if that are identical. - *

- * - * @param otherObject - * The other object being compared against. - * @return Returns true if the both objects are equal, otherwise false. - */ - @Override - public boolean equals(Object otherObject) { - - // Check if otherObject is invalid - if (otherObject != null && otherObject instanceof MaterialBlock) { - - // Cast to a MaterialBlock so we can access its variables/methods - MaterialBlock otherBlock = (MaterialBlock) otherObject; - - // Method will check for equality on two levels: shallow (within the - // scope of the MaterialBlock class), and deep (all inherited - // variables from superclass). Will only return true if both cases - // are true. - - // Create flags for checking shallow and deep equality, default to - // false - boolean shallowEqual = false; - boolean deepEqual = false; - - // Check if vertical position is equal (shallow scope) - if (vertPosition == otherBlock.vertPosition) { - shallowEqual = true; - } - // Check if rings are equal (shallow scope). TreeSet.equals() fails - // to - // evaluate individual elements at this level, so we must traverse - // and - // compare the TreeSet manually - - // First check the TreeSets are the same size. If they are not, we - // save - // a bunch of time here - if (rings.size() != otherBlock.rings.size()) { - return false; - } - // If they're the same size, initialize rings to traverse through - // the rings TreeSets - Iterator thisItr = rings.iterator(); - Iterator thatItr = otherBlock.rings.iterator(); - - // Iterate the TreeSet as long as there's another element after it - // and everything has matched so far. - while (shallowEqual && thisItr.hasNext()) { - - // Check the rings against eachother - shallowEqual = thisItr.next().equals(thatItr.next()); - } - - // Check if all inherited variables are equal (deep scope) - if (super.equals(otherBlock) && shallowEqual) { - deepEqual = true; - } - - // Return final result - return deepEqual; - } - - // If otherObject was invalid, return false - else { - return false; - } - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - * The other object to copy the contents of. - */ - public void copy(MaterialBlock otherObject) { - - // Check if the material block is invalid - if (otherObject == null) { - return; - } - // Call the superclass copy operation - super.copy(otherObject); - - // Copy the vertical position and rings TreeSet - vertPosition = otherObject.vertPosition; - rings = otherObject.rings; - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated object. - */ - @Override - public Object clone() { - - // Create a new material block - MaterialBlock block = new MaterialBlock(); - - // Copy the contents from this material block into the new one - block.copy(this); - - // Return the new material block - return block; - - } - - /** - *

- * Compares the vertical position of two MaterialBlocks. - *

- * - * @return Returns -1 if this block is below that block, +1 if this block is - * above that block, and 0 otherwise (overlapping). - */ - @Override - public int compareTo(MaterialBlock block) { - - // If this vertical position below that vertical position - if (vertPosition < block.vertPosition) { - return -1; - } - // If this vertical position above that vertical position - else if (vertPosition > block.vertPosition) { - return 1; - } - // Otherwise they must overlap (not possible) - else { - return 0; - } - } - - /** - * Overrides the default behavior (ignore) from SFRComponent and implements - * the accept operation for this SFRComponent's type. - */ - @Override - public void accept(ISFRComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/SFReactor.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/SFReactor.java deleted file mode 100644 index 515beaa1f..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/SFReactor.java +++ /dev/null @@ -1,673 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core; - -import java.util.ArrayList; -import java.util.HashMap; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.reactor.sfr.base.GridManager; -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.base.SFRComposite; -import org.eclipse.ice.reactor.sfr.core.assembly.SFRAssembly; - -/** - *

- * Class represents a sodium fast reactor at the highest core-level view. - *

- * - * @author Anna Wojtowicz - */ -public class SFReactor extends SFRComposite { - /** - *

- * Number of assemblies in the reactor core. - *

- * - */ - private int size; - /** - *

- * Shortest distance between centers of adjacent assemblies. - *

- * - */ - private double latticePitch; - /** - *

- * The physical size of assemblies within the SFR core; all assemblies are - * assumed to be the same size. Defined as the distance from one flat outer - * duct surface to the outer surface parallel to it. - *

- * - */ - private double outerFlatToFlat; - /** - *

- * The map of assembly composites, keyed by AssemblyType, that represent the - * collections of the different assemblies in this reactor. - *

- * - */ - private HashMap assemblyComposites; - /** - *

- * The map of GridManagers, keyed by AssemblyType, that manage the locations - * of assemblies within a reactor. - *

- * - */ - private HashMap assemblyManagers; - - /** - *

- * Parameterized constructor with reactor size (number of assemblies) - * specified. - *

- * - * @param size - * Size of the reactor (number of assemblies). - */ - public SFReactor(int size) { - - // Store the size, but it must be a positive number. - this.size = (size > 0 ? size : 1); - - // Set the default name, description, and ID. - setName("SFReactor 1"); - setDescription("SFReactor 1's Description"); - setId(1); - - // Set the default latticePitch and outerFlatToFlat. This setting means - // each assembly in the core is 1 unit wide and touches its six adjacent - // assemblies. - latticePitch = 1.0; - outerFlatToFlat = 1.0; - - // Initialize the List of assembly SFRComposites. - assemblyComposites = new HashMap(); - - // Initialize the Map of GridManagers. - assemblyManagers = new HashMap(); - - /* ---- Set up basic Composites for each AssemblyType. ---- */ - // An ID counter to generate unique IDs for each Composite in the Map. - int id = 1; - - // Generate a Composite for each AssemblyType and put it in the Map. - for (AssemblyType type : AssemblyType.values()) { - // Get the user-friendly String for the AssemblyType. - String typeName = type.toString(); - - // Create a new Composite for the assembly type. - SFRComposite composite = new SFRComposite(); - composite.setName(typeName + " Composite"); - composite.setDescription("A Composite that contains many " - + typeName + " Components."); - composite.setId(id++); - - // Store the Composite in the SFReactor's assembly Composite Map and - // the Component Map (inherited from SFRComposite). - assemblyComposites.put(type, composite); - super.addComponent(composite); - - // Create a new GridManager for this assembly type. - assemblyManagers.put(type, new GridManager(this.size * this.size)); - } - /* -------------------------------------------------------- */ - - /* ---- Customize individual Composites here as necessary. ---- */ - /* ------------------------------------------------------------ */ - - return; - } - - /** - *

- * Returns the size (number of assemblies) of the reactor core. - *

- * - * @return Size of the reactor (number of assemblies). - */ - public int getSize() { - return size; - } - - /** - *

- * Sets the lattice pitch. - *

- * - * @param latticePitch - * The lattice pitch of the reactor. Must be positive. - */ - public void setLatticePitch(double latticePitch) { - - // Only allow positive lattice pitch. - if (latticePitch > 0.0) { - this.latticePitch = latticePitch; - } - return; - } - - /** - *

- * Returns the lattice pitch (shortest distance between centers of adjacent - * assemblies) as a double. - *

- * - * @return The lattice pitch of the reactor. - */ - public double getLatticePitch() { - return latticePitch; - } - - /** - *

- * Sets the outer flat-to-flat distance. - *

- * - * @param outerFlatToFlat - * The outer flat-to-flat distance. Must be positive. - */ - public void setOuterFlatToFlat(double outerFlatToFlat) { - - // Only allow outer flat-to-flat. - if (outerFlatToFlat > 0.0) { - this.outerFlatToFlat = outerFlatToFlat; - } - return; - } - - /** - *

- * Returns the outer flat-to-flat distance as a double. - *

- * - * @return The outer flat-to-flat distance. - */ - public double getOuterFlatToFlat() { - return outerFlatToFlat; - } - - /** - *

- * An operation that overrides the SFRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param child - * The Component that should be added to the Composite. - */ - @Override - public void addComponent(Component child) { - return; - } - - /** - *

- * An operation that overrides the SFRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param childId - * The ID of the child Component to remove. - */ - @Override - public void removeComponent(int childId) { - return; - } - - /** - *

- * An operation that overrides the SFRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param name - * The name of the child Component to remove. - */ - @Override - public void removeComponent(String name) { - return; - } - - /** - *

- * Adds the specified assembly to the reactor core; returns true if the - * operation was successful. - *

- * - * @param type - * The AssemblyType of assembly being added. - * @param assembly - * The assembly being added to the reactor. - * @return Returns true if the operation was successful, otherwise false. - */ - public boolean addAssembly(AssemblyType type, SFRAssembly assembly) { - - // Set the default initial status. - boolean success = false; - - // Check the parameters. - if (type != null && assembly != null) { - - // Get the Composite that contains all assemblies of the type. - SFRComposite composite = assemblyComposites.get(type); - - // Make sure the assembly is not already in the Composite. - if (composite.getComponent(assembly.getName()) == null) { - - // Add the new assembly to the Composite. - composite.addComponent(assembly); - - // See if the assembly was successfully added. - success = assembly.equals(composite.getComponent(assembly - .getName())); - } - } - - return success; - } - - /** - *

- * Removes the specified assembly from the reactor core; returns true if the - * operation was successful. - *

- * - * @param type - * The AssemblyType of the assembly being removed. - * @param name - * The name of the assembly being removed. - * @return Returns true if the operation was successful, otherwise false. - */ - public boolean removeAssembly(AssemblyType type, String name) { - - // Set the default initial status. - boolean success = false; - - if (type != null && name != null) { - // Get the Composite that contains all assemblies of the type. - SFRComposite composite = assemblyComposites.get(type); - - // Get the Component in question from the appropriate Composite. - SFRComponent component = composite.getComponent(name); - - // Try to remove the Component. - if (component != null) { - // Remove it from the Composite. - composite.removeComponent(name); - - // Remove it from the appropriate GridManager. - assemblyManagers.get(type).removeComponent(name); - - success = true; - } - } - - return success; - } - - /** - *

- * Removes the assembly of AssemblyType, from the specified (x, y) location; - * returns true if the operation was successful. - *

- * - * @param type - * The AssemblyType of the assembly being removed. - * @param row - * The row in which the assembly to be removed is found in the - * AssemblyType's GridManager. - * @param column - * The column in which the assembly to be removed is found in the - * AssemblyType's GridManager. - * @return Returns true if the operation was successful, otherwise false. - */ - public boolean removeAssemblyFromLocation(AssemblyType type, int row, - int column) { - - // Set the default initial status. - boolean success = false; - - // Check the parameters. If they are valid, remove the Component from - // the specified location. - if (type != null && row >= 0 && row < size && column >= 0 - && column < size) { - - // Try removing the location from the corresponding GridManager. - success = assemblyManagers.get(type).removeComponent( - row * size + column); - } - - return success; - } - - /** - *

- * Returns the number of assemblies of AssemblyType in the reactor. - *

- * - * @param type - * The AssemblyType being searched for. - * @return Returns the number of assemblies, of AssemblyType, contained in - * the reactor. - */ - public int getNumberOfAssemblies(AssemblyType type) { - - // Initialize the number of assemblies we have. - int numberOfAssemblies = 0; - - // Only search for non-null AssemblyTypes. - if (type != null) { - // Get the number of Components from the appropriate Composite. - numberOfAssemblies = assemblyComposites.get(type) - .getNumberOfComponents(); - } - - return numberOfAssemblies; - } - - /** - *

- * Returns a string ArrayList of the names of all assemblies of the - * specified type. - *

- * - * @param type - * The AssemblyType being searched for. - * @return An ArrayList of Strings containing names of all AssemblyType - * assemblies in the reactor. - */ - public ArrayList getAssemblyNames(AssemblyType type) { - - // Initialize a List of assembly names. - ArrayList assemblyNames; - - // Only search for non-null AssemblyTypes. - if (type != null) { - // Get the Component names from the appropriate Composite. - assemblyNames = assemblyComposites.get(type).getComponentNames(); - } else { - // We must return an empty List. - assemblyNames = new ArrayList(); - } - - return assemblyNames; - } - - /** - *

- * Returns the assembly of the specified type and name. - *

- * - * @param type - * The AssemblyType of the assembly being searched for. - * @param name - * The name of the assembly being searched for. - * @return The Component with the specified name and type. If no match was - * found, returns a null assembly. - */ - public SFRComponent getAssemblyByName(AssemblyType type, String name) { - - // Set the default return value. - SFRComponent component = null; - - // If the type and name are valid, fetch the Component from the - // appropriate Composite. - if (type != null && name != null) { - component = assemblyComposites.get(type).getComponent(name); - } - return component; - } - - /** - *

- * Returns the assembly of AssemblyType, at the specified (x, y) - * coordinates. - *

- * - * @param type - * The AssemblyType being searched for. - * @param row - * The row of the assembly in the AssemblyType GridManager. - * @param column - * The column of the assembly in the AssemblyType GridManager. - * @return Returns the Component in the specified location or null if one - * could not be found satisfying the arguments. - */ - public SFRComponent getAssemblyByLocation(AssemblyType type, int row, - int column) { - - // Set the default return value. - SFRComponent component = null; - - // Check the parameters. If they are valid, fetch the Component from the - // specified location. - if (type != null && row >= 0 && row < size && column >= 0 - && column < size) { - - // Get the name of the Component from the appropriate GridManager. - String name = assemblyManagers.get(type).getComponentName( - row * size + column); - - // Get the Component from the appropriate Composite. - component = assemblyComposites.get(type).getComponent(name); - } - - return component; - } - - /** - *

- * Adds an assembly of the specified type and name to the reactor in the - * specified location. - *

- * - * @param type - * The type of assembly that will be added. - * @param name - * The name of the assembly to set. The name must correspond to - * an existing assembly. - * @param row - * The row in which to put the assembly. - * @param column - * The column in which to put the assembly. - * @return Returns whether or not the assembly location was successfully - * set. - */ - public boolean setAssemblyLocation(AssemblyType type, String name, int row, - int column) { - - boolean success = false; - - // Check the parameters. - // If the component exists, add it to the appropriate GridManager. - if (type != null && row >= 0 && row < size && column >= 0 - && column < size - && assemblyComposites.get(type).getComponent(name) != null) { - - // Try adding the Component to the corresponding GridManager. - success = assemblyManagers.get(type).addComponent(name, - row * size + column); - } - - return success; - } - - /** - *

- * Returns an ArrayList of locations within the reactor that are occupied by - * the assembly matching the specified type and name. - *

- * - * @param type - * The assembly type (fuel, control, reflector) of the assembly - * being searched for. - * @param name - * The name of the assembly being searched for. - * @return Returns an ArrayList of the locations the specified assembly - * occupies. If no match was found, returns an empty ArrayList. - */ - public ArrayList getAssemblyLocations(AssemblyType type, - String name) { - - // We need to return a List of Integers representing assembly locations. - ArrayList locations; - - // Check the parameters. - if (type != null && name != null) { - // Get the GridManager and the Component for the assembly with the - // specified type and name. - GridManager manager = assemblyManagers.get(type); - - // Get the List of locations found by the GridManager. - locations = (ArrayList) manager - .getComponentLocations(name); - } else { - // If the parameters are invalid, we need to return an empty List. - locations = new ArrayList(); - } - - return locations; - } - - /** - *

- * Overrides the equals operation to check the attributes on this object - * with another object of the same type. Returns true if the objects are - * equal. False otherwise. - *

- * - * @param otherObject - * The object to be compared against. - * @return True if otherObject is equal. False otherwise. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof SFReactor) { - - // We can now cast the other object. - SFReactor reactor = (SFReactor) otherObject; - - // Compare the values between the two objects. - equals = (super.equals(otherObject) && size == reactor.size - && latticePitch == reactor.latticePitch - && outerFlatToFlat == reactor.outerFlatToFlat - && assemblyManagers.equals(reactor.assemblyManagers) && assemblyComposites - .equals(reactor.assemblyComposites)); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return The hashcode of the object. - */ - @Override - public int hashCode() { - - // Hash based on super's hashCode. - int hash = super.hashCode(); - - // Add local hashes. - hash += 31 * size; - hash += 31 * latticePitch; - hash += 31 * outerFlatToFlat; - hash += 31 * assemblyManagers.hashCode(); - hash += 31 * assemblyComposites.hashCode(); - - return hash; - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - * The object to be copied from. - */ - public void copy(SFReactor otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - // Copy the super's values. - super.copy(otherObject); - - // Copy the local values. - size = otherObject.size; - latticePitch = otherObject.latticePitch; - outerFlatToFlat = otherObject.outerFlatToFlat; - assemblyManagers.clear(); - assemblyManagers.putAll(otherObject.assemblyManagers); - assemblyComposites.clear(); - assemblyComposites.putAll(otherObject.assemblyComposites); - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated copied object. - */ - @Override - public Object clone() { - - // Initialize a new object. - SFReactor object = new SFReactor(size); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } - - /** - * Overrides the default behavior (ignore) from SFRComponent and implements - * the accept operation for this SFRComponent's type. - */ - @Override - public void accept(ISFRComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - return; - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/PinAssembly.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/PinAssembly.java deleted file mode 100644 index cbf813b09..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/PinAssembly.java +++ /dev/null @@ -1,685 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core.assembly; - -import java.util.ArrayList; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.reactor.sfr.base.GridDataManager; -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.core.AssemblyType; - -/** - *

- * Class representing any assemblies in a SFR that contain pins. This includes - * both fuel pins (core and blanket), in addition to control assemblies (primary - * or secondary/shutdown), test assemblies, and shield assemblies. The - * distinction between the pin assembly type is made using the pinType - * attribute. - *

- * - * @author Anna Wojtowicz - */ -public class PinAssembly extends SFRAssembly { - /** - *

- * Shortest distance between centers of adjacent pins. - *

- * - */ - private double pinPitch; - /** - *

- * The PinType of the pin assembly; can be either core fuel, blanket fuel, - * primary control or secondary control. - *

- * - */ - private PinType pinType; - /** - *

- * The physical size of the inner duct within the assembly. Defined as the - * distance from one outer duct surface to the outer surface parallel to it. - * Since control assemblies (PrimaryControl, SecondaryControl) are the only - * PinAssembly type with inner ducts, this attribute will be 0 for all other - * PinAssembly types. - *

- * - */ - private double innerDuctFlatToFlat; - /** - *

- * Thickness of the assembly's inner duct wall. Since control assemblies - * (PrimaryControl, SecondaryControl) are the only PinAssembly type with - * inner ducts, this attribute will be 0 for all other PinAssembly types. - *

- * - */ - private double innerDuctThickness; - /** - *

- * A GridManager used to manage the locations of pins within this assembly. - *

- * - */ - private GridDataManager pinManager; - - /** - *

- * Parameterized constructor with the assembly size (number of pins) - * specified. - *

- * - * @param size - * The size (number of pins) of the assembly. - */ - public PinAssembly(int size) { - - // Call the super constructor with some defaults. - super("SFR Pin Assembly 1", AssemblyType.Fuel, size); - - // Set the default description and ID. - setDescription("SFR Pin Assembly 1's Description"); - setId(1); - - // Set the default pin type. - pinType = PinType.InnerFuel; - - // Initialize pinPitch and innerDuct values - pinPitch = 1.0; - innerDuctFlatToFlat = 0.0; - innerDuctThickness = 0.0; - // Inner duct values are assumed to be 0, except for the case of control - // assemblies. Since the nullary constructor sets the pin's type as - // InnerFuel, - // the default inner duct is non-existent. - - // Initialize the pin manager. - pinManager = new GridDataManager(getSize() * getSize()); - - return; - } - - /** - *

- * Parameterized constructor with the assembly size (number of pins), pin - * type, and name specified. - *

- * - * @param name - * The name of the assembly. - * @param pinType - * The type of the pin. - * @param size - * The size (number of pins) of the assembly. - */ - public PinAssembly(String name, PinType pinType, int size) { - - // Call the basic constructor. Sets all defaults. - this(size); - - // Set the name. - setName(name); - - // Set the pin type of this assembly. If null, default to InnerFuel. - this.pinType = (pinType != null ? pinType : PinType.InnerFuel); - - // Initialize the inner duct values; assumed to be 0 unless a control - // assembly - if (this.pinType == PinType.PrimaryControl - || this.pinType == PinType.SecondaryControl) { - innerDuctFlatToFlat = 0.75; - innerDuctThickness = 0.05; - } else { - innerDuctFlatToFlat = 0.0; - innerDuctThickness = 0.0; - } - - // Set the assembly type to Control, Shield or Test if necessary (is - // already Fuel by default) - switch (this.pinType) { - case PrimaryControl: - case SecondaryControl: - assemblyType = AssemblyType.Control; - break; - case Shield: - assemblyType = AssemblyType.Shield; - break; - case MaterialTest: - case FuelTest: - assemblyType = AssemblyType.Test; - break; - case InnerFuel: - case OuterFuel: - case BlanketFuel: - default: - break; - } - - return; - } - - /** - *

- * Sets the pin pitch (shortest distance between a pin center to an adjacent - * pin center). - *

- * - * @param pinPitch - * The pin pitch. - */ - public void setPinPitch(double pinPitch) { - - // Only set the pin pitch if it is 0 or greater. - if (pinPitch >= 0.0) { - this.pinPitch = pinPitch; - } - return; - } - - /** - *

- * Returns the pin pitch (shortest distance between a pin center to an - * adjacent pin center) as a double. - *

- * - * @return Returns the pin pitch as a double. - */ - public double getPinPitch() { - return pinPitch; - } - - /** - *

- * Sets the inner duct's (outer) flat-to-flat distance. - *

- * - * @param flatToFlat - * The inner duct's (outer) flat-to-flat distance. - */ - public void setInnerDuctFlatToFlat(double flatToFlat) { - - // Only set the flat-to-flat if it is 0 or greater. - if (flatToFlat >= 0.0) { - this.innerDuctFlatToFlat = flatToFlat; - } - return; - } - - /** - *

- * Returns the inner duct's (outer) flat-to-flat distance. - *

- * - * @return The inner duct's (outer) flat-to-flat distance. - */ - public double getInnerDuctFlatToFlat() { - return innerDuctFlatToFlat; - } - - /** - *

- * Sets the inner duct's thickness. - *

- * - * @param innerDuctThickness - * The inner duct's thickness. - */ - public void setInnerDuctThickness(double innerDuctThickness) { - - // Only set the thickness if it is 0 or greater. - if (innerDuctThickness >= 0.0) { - this.innerDuctThickness = innerDuctThickness; - } - return; - } - - /** - *

- * Returns the inner duct's thickness. - *

- * - * @return The inner duct's thickness. - */ - public double getInnerDuctThickness() { - return innerDuctThickness; - } - - /** - *

- * Returns the pin type (primary control, secondary control, core fuel or - * blanket fuel). - *

- * - * @return Returns the pin type. - */ - public PinType getPinType() { - return pinType; - } - - /** - *

- * Adds the specified SFRPin to the assembly; returns true if the operation - * was successful. - *

- * - * @param pin - * The pin to be added to the PinAssembly. - * @return Returns true if the operation was successful, otherwise false. - */ - public boolean addPin(SFRPin pin) { - - // By default, we did not succeed in adding the Component. - boolean success = false; - - // Check the parameters. Also make sure that the pin does not already - // exist in the collection of Components. - if (pin != null && !pin.equals(getComponent(pin.getName()))) { - - // Add the new Component to this Composite. - super.addComponent(pin); - - // See if the pin was successfully added. - success = pin.equals(getComponent(pin.getName())); - } - - return success; - } - - /** - *

- * Adds the pin with the specified name to the assembly in the specified - * location. If the pin exists and the location is valid and is not occupied - * by the same pin, this returns true. - *

- * - * @param name - * The name of the pin to set. The name must correspond to an - * existing pin. - * @param row - * The row in which to put the pin. - * @param column - * The column in which to put the pin. - * @return Returns whether or not the pin location was successfully set. - */ - public boolean setPinLocation(String name, int row, int column) { - - // By default, we did not succeed in adding the Component. - boolean success = false; - - // Check the parameters. - // If the Component exists, add it to the GridManager location. - int size = getSize(); - if (name != null && row >= 0 && row < size && column >= 0 - && column < size && getComponent(name) != null) { - success = pinManager.addComponent(name, row * size + column); - } - - return success; - } - - /** - *

- * Removes the specified SFRPin from the assembly; returns true if the - * operation was successful. - *

- * - * @param name - * The name of the pin to be removed. - * @return Returns true if the operation was successful, otherwise false. - */ - public boolean removePin(String name) { - - // By default, we did not succeed in removing the Component. - boolean success = false; - - // Check the parameters. - // If there is a pin with that name, remove it. - if (name != null && getPinByName(name) != null) { - // Remove the Component from this Composite. - super.removeComponent(name); - - // Remove it from the GridManager. - pinManager.removeComponent(name); - - success = true; - - } - - return success; - } - - /** - *

- * Removes the SFRPin from the specified location (x, y coordinates); - * returns true if operation was successful. - *

- * - * @param row - * The row in which the pin can be found. - * @param column - * The column in which the pin can be found. - * @return Returns true if the operation was successful, otherwise false. - */ - public boolean removePinFromLocation(int row, int column) { - - // By default, we did not succeed in removing the Component from the - // location. - boolean success = false; - - // Check the parameters. - int size = getSize(); - if (row >= 0 && row < size && column >= 0 && column < size) { - - // Try removing the location from the GridManager. - success = pinManager.removeComponent(row * size + column); - } - - return success; - } - - /** - *

- * Returns an ArrayList of SFRPin names in the assembly. - *

- * - * @return An ArrayList of pin names contained in the assembly. - */ - public ArrayList getPinNames() { - return getComponentNames(); - } - - /** - *

- * Returns the SFRPin by the specified name. - *

- * - * @param name - * The name of the pin being searched for. - * @return Returns the pin corresponding to the name specified. Returns a - * null pin if no match was found. - */ - public SFRPin getPinByName(String name) { - return (SFRPin) getComponent(name); - } - - /** - *

- * Returns the SFRPin at the specified location (x, y coordinates) in the - * assembly. - *

- * - * @param row - * The row in which the pin is located. - * @param column - * The column in which the pin is located. - * @return Returns the pin at the specified location. Returns a null pin if - * no match was found. - */ - public SFRPin getPinByLocation(int row, int column) { - - // Initialize the default return value. - SFRPin pin = null; - - // Check the parameters. - int size = getSize(); - if (row >= 0 && row < size && column >= 0 && column < size) { - - // Get the name of the Component from the GridManager. - String name = pinManager.getComponentName(row * size + column); - - // Get the Component from this Composite. - pin = getPinByName(name); - } - - return pin; - } - - /** - *

- * Returns an ArrayList of locations within the assembly that are occupied - * by the pin matching the specified name. - *

- * - * @param name - * The name of the pin being searched for. - * @return Returns an ArrayList of the locations the specified pin occupies. - * If no match was found, returns an empty ArrayList. - */ - public ArrayList getPinLocations(String name) { - - // We need to return a List of Integers representing pin locations. - ArrayList locations; - - // Check the parameters. - if (name != null) { - // Get the list of locations found by the GridManager. - locations = (ArrayList) pinManager - .getComponentLocations(name); - } else { - // If the parameters are invalid, we need to return an empty List. - locations = new ArrayList(); - } - - return locations; - } - - /** - *

- * Returns the number of pins in the assembly. - *

- * - * @return The number of pins in the assembly. - */ - public int getNumberOfPins() { - return getNumberOfComponents(); - } - - /** - *

- * Returns an IDataProvider for the location in the assembly. This is - * distinct from the SFRPin, which, as an SFRComponent, is itself an - * IDataProvider. - *

- * - * @param row - * The row in which the IDataProvider is located. - * @param column - * The column in which the IDataProvider is located. - * @return Returns the IDataProvider at the specified location. Returns null - * if no match was found. - */ - public SFRComponent getDataProviderByLocation(int row, int column) { - - // Initialize the default return value. - SFRComponent provider = null; - - // Check the parameters. - int size = getSize(); - if (row >= 0 && row < size && column >= 0 && column < size) { - - // Get the IDataProvider from the GridDataManager. - provider = pinManager.getDataProvider(row * size + column); - } - - return provider; - } - - /** - *

- * An operation that overrides the SFRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param child - * The Component that should be added to the Composite. - */ - @Override - public void addComponent(Component child) { - return; - } - - /** - *

- * An operation that overrides the SFRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param childId - * The ID of the child Component to remove. - */ - @Override - public void removeComponent(int childId) { - return; - } - - /** - *

- * An operation that overrides the SFRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param name - * The name of the child Component to remove. - */ - @Override - public void removeComponent(String name) { - return; - } - - /** - *

- * Overrides the equals operation to check the attributes on this object - * with another object of the same type. Returns true if the objects are - * equal. False otherwise. - *

- * - * @param otherObject - * The object to be compared. - * @return True if otherObject is equal. False otherwise. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof PinAssembly) { - - // We can now cast the other object. - PinAssembly assembly = (PinAssembly) otherObject; - - // Compare the values between the two objects. - equals = (super.equals(otherObject) - && pinPitch == assembly.pinPitch - && pinType == assembly.pinType - && innerDuctFlatToFlat == assembly.innerDuctFlatToFlat - && innerDuctThickness == assembly.innerDuctThickness && pinManager - .equals(assembly.pinManager)); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return The hash of the object. - */ - @Override - public int hashCode() { - - // Hash based on super's hashCode. - int hash = super.hashCode(); - - // Add local hashes. - hash += 31 * pinPitch; - hash += 31 * pinType.hashCode(); - hash += 31 * pinManager.hashCode(); - - return hash; - } - - /** - *

- * Deep copies the contents of the object from another object. - *

- * - * @param otherObject - * The object to be copied from. - */ - public void copy(PinAssembly otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - // Copy the super's values. - super.copy(otherObject); - - // Copy the local values. - pinPitch = otherObject.pinPitch; - pinType = otherObject.pinType; - innerDuctFlatToFlat = otherObject.innerDuctFlatToFlat; - innerDuctThickness = otherObject.innerDuctThickness; - pinManager.copy(otherObject.pinManager); - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return

- * The newly instantiated copied object. - *

- */ - @Override - public Object clone() { - - // Initialize a new object. - PinAssembly object = new PinAssembly(getSize()); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } - - /** - * Overrides the default behavior (ignore) from SFRComponent and implements - * the accept operation for this SFRComponent's type. - */ - @Override - public void accept(ISFRComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/PinType.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/PinType.java deleted file mode 100644 index 318bb2c9f..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/PinType.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core.assembly; - -/** - * This enumeration represents allowed types of pins for - * a PinAssembly. Currently, the PinType corresponds to an attribute of a - * PinAssembly. - * - * @author Anna Wojtowicz - */ -public enum PinType { - /** - * A primary control pin. - * - */ - PrimaryControl("Primary Control", 0), - /** - * A secondary (shutdown) control pin. - * - */ - SecondaryControl("Secondary Control", 1), - /** - * An inner core pin containing burnable fuel. - * - */ - InnerFuel("Inner Fuel", 2), - /** - * An outer core pin containing burnable fuel. - * - */ - OuterFuel("Outer Fuel", 3), - /** - * A shielding pin. - * - */ - Shield("Shield", 4), - /** - * A pin for conducting materials testing. - * - */ - MaterialTest("Material Test", 5), - /** - * A pin for conducting fuels testing. - * - */ - FuelTest("Fuel Test", 6), - /** - * A pin containing fertile blanket fuel. - * - */ - BlanketFuel("Blanket Fuel", 7); - - /** - * A user-friendly String for displaying an PinType - * value. - * - */ - private final String name; - /** - * An ID used to distinguish between enum values in - * lieu of using their String names. - * - */ - private final int id; - - /** - * The default constructor for a PinType. - * - * @param name - * A string representation of the pin type. - * @param id - * A unique ID for the pin type. - */ - private PinType(String name, int id) { - // Set the user-friendly name String for this pin type. - this.name = name; - - // Set the ID used for this pin type. - this.id = id; - - return; - } - - /** - * Override the default toString() behavior to give - * the user a better-formatted String representing this PinType. - * - * @return Returns a string representation of the pin type. - */ - @Override - public String toString() { - return name; - } - - /** - * Gets the Integer ID associated with this enum - * value. The ID is unique for each possible enum value. - * - * @return The Integer ID for the enum value. - */ - public int getId() { - return this.id; - } - - /** - * Gets an PinType enum value for the corresponding - * Integer ID. If the ID is invalid, the CoreFuel type is returned. - * - * @param id - * The integer ID to convert to a PinType value. - * @return The PinType value for the provided ID, or PinType.CoreFuel if the - * ID is invalid. - */ - public static PinType valueOf(int id) { - - // The default return value is InnerFuel. - PinType value = InnerFuel; - - // Set the value depending on the id. - switch (id) { - case 0: - value = PrimaryControl; - break; - case 1: - value = SecondaryControl; - break; - case 3: - value = OuterFuel; - break; - case 4: - value = Shield; - break; - case 5: - value = MaterialTest; - break; - case 6: - value = FuelTest; - break; - case 7: - value = BlanketFuel; - break; - default: - break; - } - - // Return the enum value. - return value; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/ReflectorAssembly.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/ReflectorAssembly.java deleted file mode 100644 index 46d465bdd..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/ReflectorAssembly.java +++ /dev/null @@ -1,536 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core.assembly; - -import java.util.ArrayList; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.reactor.sfr.base.GridDataManager; -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.core.AssemblyType; - -/** - *

- * Class representing radial reflector assemblies. Differentiated from - * PinAssembly, as radial reflectors contain solid rods rather than pins. - *

- * - * @author Anna Wojtowicz - */ -public class ReflectorAssembly extends SFRAssembly { - /** - *

- * The shortest distance between centers of adjacent reflector rods. - *

- * - */ - private double rodPitch; - - /** - *

- * A GridManager used to manage the locations of rods within this assembly. - *

- * - */ - private GridDataManager rodManager; - - /** - *

- * Parameterized constructor with the size (number of rods) specified. - *

- * - * @param size - * Size (number of rods) of the assembly. - */ - public ReflectorAssembly(int size) { - - // Call the super constructor with some defaults. - super("SFR Reflector Assembly 1", AssemblyType.Reflector, size); - - // Set the default description, and ID. - setDescription("SFR Reflector Assembly 1's Description"); - setId(1); - - // Initialize rodPitch. - rodPitch = 1.0; - - // Initialize the rod manager. - rodManager = new GridDataManager(getSize() * getSize()); - - return; - } - - /** - *

- * Parameterized constructor with the name and size (number of rods) - * specified. - *

- * - * @param name - * Name of the assembly. - * @param size - * Size (number of rods) of the assembly. - */ - public ReflectorAssembly(String name, int size) { - - // Call the basic constructor. Sets all defaults. - this(size); - - // Set the name. - setName(name); - - return; - } - - /** - *

- * Sets the rod pitch (shortest distance from rod center to an adjacent rod - * center). - *

- * - * @param rodPitch - * The rod pitch. Must be non-negative. - */ - public void setRodPitch(double rodPitch) { - - // Only set the rod pitch if it is 0 or greater. - if (rodPitch >= 0.0) { - this.rodPitch = rodPitch; - } - return; - } - - /** - *

- * Returns the rod pitch (shortest distance from rod center to an adjacent - * rod center) as a double. - *

- * - * @return Returns the rod pitch as a double. - */ - public double getRodPitch() { - return rodPitch; - } - - /** - *

- * Adds the specified SFRRod to the Reflector assembly; returns true if the - * operation is successful. - *

- * - * @param rod - * The rod to be added to the assembly. - * @return Returns true if the operation was successful, otherwise false. - */ - public boolean addRod(SFRRod rod) { - - // By default, we did not succeed in adding the Component. - boolean success = false; - - // Check the parameters. Also make sure that the rod does not already - // exist in the collection of Components. - if (rod != null && !rod.equals(getComponent(rod.getName()))) { - - // Add the new Component to this Composite. - super.addComponent(rod); - - // See if the rod was successfully added. - success = rod.equals(getComponent(rod.getName())); - } - - return success; - } - - /** - *

- * Adds the rod with the specified name to the assembly in the specified - * location. If the rod exists and the location is valid and is not occupied - * by the same rod, this returns true. - *

- * - * @param name - * The name of the rod to set. The name must correspond to an - * existing rod. - * @param row - * The row in which to put the rod. - * @param column - * The column in which to put the rod. - * @return Returns whether or not the rod location was successfully set. - */ - public boolean setRodLocation(String name, int row, int column) { - - // By default, we did not succeed in adding the Component. - boolean success = false; - - // Check the parameters. - int size = getSize(); - // If the Component exists, add it to the GridManager location. - if (name != null && row >= 0 && row < size && column >= 0 - && column < size && getComponent(name) != null) { - success = rodManager.addComponent(name, row * size + column); - } - - return success; - } - - /** - *

- * Removes the rod with the specified name from the ReflectorAssembly; - * returns true if the operation is successful. - *

- * - * @param name - * The name of the rod to remove. - * @return Returns true if the operation was successful, false otherwise. - */ - public boolean removeRod(String name) { - - // By default, we did not succeed in removing the Component. - boolean success = false; - - // Check the parameters. - // If there is a rod with that name, remove it. - if (name != null && getRodByName(name) != null) { - // Remove the Component from this Composite. - super.removeComponent(name); - - // Remove it from the GridManager. - rodManager.removeComponent(name); - - success = true; - } - - return success; - } - - /** - *

- * Removes the rod with the specified location (x, y coordinates) from the - * ReflectorAssembly; returns true operation is successful. - *

- * - * @param row - * The row in which the rod is located. - * @param column - * The column in which the rod is located. - * @return Returns true if the operation was successful, false otherwise. - */ - public boolean removeRodFromLocation(int row, int column) { - - // By default, we did not succeed in removing the Component from the - // location. - boolean success = false; - - // Check the parameters. - int size = getSize(); - if (row >= 0 && row < size && column >= 0 && column < size) { - - // Try removing the location from the GridManager. - success = rodManager.removeComponent(row * size + column); - } - - return success; - } - - /** - *

- * Returns a String ArrayList of all rod names contained within the - * assembly. - *

- * - * @return ArrayList of Strings representing names of all rods in the - * assembly. - */ - public ArrayList getRodNames() { - return getComponentNames(); - } - - /** - *

- * Returns the SFRRod with the specified name in the assembly. - *

- * - * @param name - * The name of the rod to be searched for. - * @return Returns the rod with the specified name. Returns a null rod if - * none was found. - */ - public SFRRod getRodByName(String name) { - return (SFRRod) getComponent(name); - } - - /** - *

- * Returns the SFRRod at the specified location (x, y coordinates) in the - * assembly. - *

- * - * @param row - * The row in which the rod is located. - * @param column - * The column in which the rod is located. - * @return Returns the rod found in the specified location. Returns a null - * rod if no match is found. - */ - public SFRRod getRodByLocation(int row, int column) { - - // Initialize the default return value. - SFRRod rod = null; - - // Check the parameters. - int size = getSize(); - if (row >= 0 && row < size && column >= 0 && column < size) { - - // Get the Component from this Composite. - rod = getRodByName(rodManager.getComponentName(row * size + column)); - } - - return rod; - } - - /** - *

- * Returns an ArrayList of locations within the assembly that are occupied - * by the rod matching the specified name. - *

- * - * @param name - * The name of the rod being searched for. - * @return Returns an ArrayList of the locations the specified rod occupies. - * If no match was found, returns an empty ArrayList. - */ - public ArrayList getRodLocations(String name) { - - // We need to return a List of Integers representing rod locations. - ArrayList locations; - - // Check the parameters. - if (name != null) { - // Get the list of locations found by the GridManager. - locations = (ArrayList) rodManager - .getComponentLocations(name); - } else { - // If the parameters are invalid, we need to return an empty List. - locations = new ArrayList(); - } - - return locations; - } - - /** - *

- * Returns the number of rods in the assembly. - *

- * - * @return The number of rods in the assembly. - */ - public int getNumberOfRods() { - return getNumberOfComponents(); - } - - /** - *

- * Returns an IDataProvider for the location in the assembly. This is - * distinct from the SFRRod, which, as an SFRComponent, is itself an - * IDataProvider. - *

- * - * @param row - * The row in which the IDataProvider is located. - * @param column - * The column in which the IDataProvider is located. - * @return Returns the IDataProvider at the specified location. Returns null - * if no match was found. - */ - public SFRComponent getDataProviderByLocation(int row, int column) { - - // Initialize the default return value. - SFRComponent provider = null; - - // Check the parameters. - int size = getSize(); - if (row >= 0 && row < size && column >= 0 && column < size) { - - // Get the IDataProvider from the GridDataManager. - provider = rodManager.getDataProvider(row * size + column); - } - - return provider; - } - - /** - *

- * An operation that overrides the SFRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param child - * The Component that should be added to the Composite. - */ - @Override - public void addComponent(Component child) { - return; - } - - /** - *

- * An operation that overrides the SFRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param childId - * The ID of the child Component to remove. - */ - @Override - public void removeComponent(int childId) { - return; - } - - /** - *

- * An operation that overrides the SFRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param name - * The name of the child Component to remove. - */ - @Override - public void removeComponent(String name) { - return; - } - - /** - *

- * Overrides the equals operation to check the attributes on this object - * with another object of the same type. Returns true if the objects are - * equal. False otherwise. - *

- * - * @param otherObject - * The object to be compared. - * @return True if otherObject is equal. False otherwise. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null - && otherObject instanceof ReflectorAssembly) { - - // We can now cast the other object. - ReflectorAssembly assembly = (ReflectorAssembly) otherObject; - - // Compare the values between the two objects. - equals = (super.equals(otherObject) - && rodPitch == assembly.rodPitch && rodManager - .equals(assembly.rodManager)); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return

- * The hash of the object. - *

- */ - @Override - public int hashCode() { - - // Hash based on super's hashCode. - int hash = super.hashCode(); - - // Add local hashes. - hash += 31 * rodPitch; - hash += 31 * rodManager.hashCode(); - - return hash; - } - - /** - *

- * Deep copies the contents of the object from another object. - *

- * - * @param otherObject - *

- * The object to be copied from. - *

- */ - public void copy(ReflectorAssembly otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - // Copy the super's values. - super.copy(otherObject); - - // Copy the local values. - rodPitch = otherObject.rodPitch; - rodManager.copy(otherObject.rodManager); - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return

- * The newly instantiated copied object. - *

- */ - @Override - public Object clone() { - - // Initialize a new object. - ReflectorAssembly object = new ReflectorAssembly(getSize()); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } - - /** - * Overrides the default behavior (ignore) from SFRComponent and implements - * the accept operation for this SFRComponent's type. - */ - @Override - public void accept(ISFRComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/Ring.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/Ring.java deleted file mode 100644 index 8f0d25c44..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/Ring.java +++ /dev/null @@ -1,438 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core.assembly; - -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.core.Material; - -/** - *

- * The ring class represents a single instance of a material at a particular - * radial coordinate within a cylindrical location of a SFRPin or SFRod. The - * height variable on this class should uniformly represent the height from the - * bottom of the MaterialBlock (or z-displacement) to help compensate for - * varying types of materials throughout a vertical segment of a pin or rod. - *

- * - * @author Anna Wojtowicz - */ -public class Ring extends SFRComponent implements Comparable { - /** - *

- * Material the ring is composed of. - *

- * - */ - private Material material; - /** - *

- * Height of the ring within the material block (z=0 at the bottom of the - * material block); must be equal to or greater than 0. - *

- * - */ - private double height; - /** - *

- * Inner radius of the ring, must equal to or greater than zero. - *

- * - */ - private double innerRadius; - /** - *

- * Outer radius of the ring; must be greater than zero. - *

- * - */ - private double outerRadius; - - /** - *

- * Nullary constructor. - *

- * - */ - public Ring() { - - // Set the ring name, description and ID - setName("Ring 1"); - setDescription("Ring 1 Description"); - setId(1); - - // Set the height (z-displacement), inner radius, outer radius and - // material - height = 0.0; - innerRadius = 0.0; - outerRadius = 1.0; - material = new Material(); - - } - - /** - *

- * Parameterized constructor with name specified. - *

- * - * @param name - * Name of the ring. - */ - public Ring(String name) { - - // Call the nullary constructor - this(); - - // Set the passed name - setName(name); - - } - - /** - *

- * Parameterized constructor with name, material, ring height and outer - * radius specified. - *

- * - * @param name - * Name of the ring. - * @param material - * Material the ring is composed of. - * @param height - * Height of the ring within the material block. - * @param innerRadius - * Inner radius of the ring. Must be non-negative. - * @param outerRadius - * Outer radius of the ring. Must be non-negative. - */ - public Ring(String name, Material material, double height, - double innerRadius, double outerRadius) { - - // Call the nullary constructor - this(); - - // Set the name, material, height and radii - setName(name); - setMaterial(material); - setHeight(height); - setInnerRadius(innerRadius); - setOuterRadius(outerRadius); - - } - - /** - *

- * Sets the ring height (z-displacement within the material block). - *

- * - * @param height - * The height of the ring. Must be non-negative. - */ - public void setHeight(double height) { - - // If height is non-negative, set height - if (height >= 0.0) { - this.height = height; - } - } - - /** - *

- * Returns the ring height (z-displacement within the material block) as a - * double. - *

- * - * @return The height of the ring. - */ - public double getHeight() { - - return height; - - } - - /** - *

- * Sets the ring inner radius. - *

- * - * @param innerRadius - * The inner radius of the ring. Must be non-negative. - */ - public void setInnerRadius(double innerRadius) { - - // If inner radius is non-negative - if (innerRadius >= 0.0) { - this.innerRadius = innerRadius; - } - } - - /** - *

- * Returns the ring inner radius as a double. - *

- * - * @return The inner radius of the ring. - */ - public double getInnerRadius() { - - return innerRadius; - - } - - /** - *

- * Sets the ring outer radius. - *

- * - * @param outerRadius - * The outer radius of the ring. Must be non-negative. - */ - public void setOuterRadius(double outerRadius) { - - // If outer radius is non-negative - if (outerRadius >= 0.0) { - this.outerRadius = outerRadius; - } - } - - /** - *

- * Returns the ring's outer radius as a double. - *

- * - * @return The outer radius of the ring. - */ - public double getOuterRadius() { - - return this.outerRadius; - - } - - /** - *

- * Sets the ring material. - *

- * - * @param material - * The material the ring is composed of. Cannot be null. - */ - public void setMaterial(Material material) { - - // If material is non-null - if (material != null) { - this.material = material; - } - } - - /** - *

- * Returns the material of the ring. - *

- * - * @return A reference to the ring's material. - */ - public Material getMaterial() { - - return material; - - } - - /** - * Compares "this" ring to the input parameter ring - * ("that" ring). Returns -1 if this ring is inside that ring; returns +1 if - * this ring is outside that ring; returns 0 if the rings overlap, either - * partially or completely (a physical impossibility). - * - * @param ring - * The ring being compared to. - * @return Returns -1 if this ring is inside that ring; +1 if this ring is - * outside that ring; 0 if the rings overlap. - */ - @Override - public int compareTo(Ring ring) { - - // Check if this ring is inside that ring - if (outerRadius <= ring.innerRadius) { - return -1; - } - // Check if this ring is outside that ring - if (innerRadius >= ring.outerRadius) { - return 1; - } - // If this inner < that inner, this ring could be either inside that - // ring OR overlapping, depending on this.outerRadius - if (innerRadius < ring.innerRadius) { - - // Check if this ring is inside that ring - if (outerRadius <= ring.innerRadius) { - return -1; - } - // Otherwise the rings overlap - else { - return 0; - } - } - - // If this outer > that outer, this ring could be either outside that - // ring, OR overlapping, depending on this.innerRadius - if (outerRadius > ring.outerRadius) { - - // Check if this ring is outside that ring - if (innerRadius >= ring.outerRadius) { - return 1; - } - // Otherwise the rings overlap - else { - return 0; - } - } - - // Otherwise, all other scenarios, the rings must overlap - return 0; - - } - - /** - *

- * Returns the hashcode of the object. - *

- * - * @return The hashcode of the object. - */ - @Override - public int hashCode() { - - // Hash based upon superclass hash - int hash = super.hashCode(); - - // Add the hashes for all of the variables. - hash += 31 * height; - hash += 31 * innerRadius; - hash += 31 * outerRadius; - hash += 31 * material.hashCode(); - - // Return hash - return hash; - } - - /** - *

- * Compares the contents of objects and returns true if that are identical. - *

- * - * @param otherObject - * The other object being compared against. - * @return Returns true if the both objects are equal, otherwise false. - */ - @Override - public boolean equals(Object otherObject) { - - // Check if otherObject is valid - if (otherObject != null && otherObject instanceof Ring) { - - // Cast otherObject to Ring so we can access its attributes/methods - Ring otherRing = (Ring) otherObject; - - // Method will check for equality on two levels: shallow (within the - // scope of the Ring class), and deep (all inherited variables - // from superclass). Will only return true if both cases are true. - - // Create flags for checking shallow and deep equality, default to - // false - boolean shallowEqual = false; - boolean deepEqual = false; - - // Check if height, radii and material (shallow scope) are equal - if (height == otherRing.height - && innerRadius == otherRing.innerRadius - && outerRadius == otherRing.outerRadius - && material.equals(otherRing.material)) { - shallowEqual = true; - } - // Check if all inherited variables are equal (deep scope) - if (super.equals(otherRing) && shallowEqual) { - deepEqual = true; - } - - // Return final result - return deepEqual; - } - - // Otherwise otherObject was invalid, return false - else { - return false; - } - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - * The other object to copy the contents of. - */ - public void copy(Ring otherObject) { - - // Check if otherObject in invalid - if (otherObject == null) { - return; - } - // Call the superclass copy operation - super.copy(otherObject); - - // Copy the height, radii and material - height = otherObject.height; - innerRadius = otherObject.innerRadius; - outerRadius = otherObject.outerRadius; - material = otherObject.material; - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated object. - */ - @Override - public Object clone() { - - // Create a new ring - Ring ring = new Ring(); - - // Copy the contents from this ring into the new one - ring.copy(this); - - // Return the new ring - return ring; - - } - - /** - * Overrides the default behavior (ignore) from SFRComponent and implements - * the accept operation for this SFRComponent's type. - */ - @Override - public void accept(ISFRComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRAssembly.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRAssembly.java deleted file mode 100644 index 8e9bcfe8e..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRAssembly.java +++ /dev/null @@ -1,282 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core.assembly; - -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComposite; -import org.eclipse.ice.reactor.sfr.core.AssemblyType; - -/** - *

- * Class representing the assembly structure of a SFR. The SFR assembly is - * housed in a hexagonal structure called the wrapper tube (or duct), and - * contains a lattice of either pins or rods. - *

- * - * @author Anna Wojtowicz - */ -public class SFRAssembly extends SFRComposite { - /** - *

- * Size of a SFRAssembly. Size represents number of pins in a fuel or - * control assembly, and rods in a reflector assembly. - *

- * - */ - private int size; - /** - *

- * The type of SFR assembly represented, either fuel, control or reflector. - *

- * - */ - protected AssemblyType assemblyType; - /** - *

- * Thickness of the assembly duct wall. - *

- * - */ - private double ductThickness; - - /** - *

- * Parameterized constructor with assemble size specified. Size represents - * number of pins in a fuel or control assembly, and rods in a reflector - * assembly. - *

- * - * @param size - * Size of the assembly. - */ - public SFRAssembly(int size) { - - // Set the size if positive, otherwise default to 1. - this.size = (size > 0 ? size : 1); - - // Set the default name, description, and ID. - setName("SFR Assembly 1"); - setDescription("SFR Assembly 1's Description"); - setId(1); - - // Default the assembly type to Fuel. - assemblyType = AssemblyType.Fuel; - - // Initialize ductThickness. - ductThickness = 0.0; - - return; - } - - /** - *

- * Parameterized constructor with assembly name, type and size specified. - * Size represents number of pins in a fuel or control assembly, and rods in - * a reflector assembly. - *

- * - * @param name - * The name of the assembly. - * @param type - * The assembly type (fuel, control or reflector). - * @param size - * The size of the assembly. - */ - public SFRAssembly(String name, AssemblyType type, int size) { - - // Call the basic constructor first. - this(size); - - // Set the name. - setName(name); - - // Set the assembly type if possible. If null, the other constructor has - // already set the type to the default (Fuel). - if (type != null) { - assemblyType = type; - } - - return; - } - - /** - *

- * Returns the assembly size. Size represents number of pins in a fuel or - * control assembly, and rods in a reflector assembly. - *

- * - * @return The size of the assembly. - */ - public int getSize() { - return size; - } - - /** - *

- * Returns the assembly type (fuel, control or reflector). - *

- * - * @return The assembly type. - */ - public AssemblyType getAssemblyType() { - return assemblyType; - } - - /** - *

- * Sets the thickness of the assembly duct wall. - *

- * - * @param thickness - * The duct thickness. Must be non-negative. - */ - public void setDuctThickness(double thickness) { - - // Only set the duct thickness if it is 0 or larger. - if (thickness >= 0.0) { - ductThickness = thickness; - } - return; - } - - /** - *

- * Returns the duct wall thickness of an assembly as a double. - *

- * - * @return The duct thickness. - */ - public double getDuctThickness() { - return ductThickness; - } - - /** - *

- * Overrides the equals operation to check the attributes on this object - * with another object of the same type. Returns true if the objects are - * equal. False otherwise. - *

- * - * @param otherObject - * The object to be compared. - * @return True if otherObject is equal. False otherwise. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof SFRAssembly) { - - // We can now cast the other object. - SFRAssembly assembly = (SFRAssembly) otherObject; - - // Compare the values between the two objects. - equals = (super.equals(otherObject) && size == assembly.size - && assemblyType == assembly.assemblyType && ductThickness == assembly.ductThickness); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return

- * The hash of the object. - *

- */ - @Override - public int hashCode() { - - // Hash based on super's hashCode. - int hash = super.hashCode(); - - // Add local hashes. - hash += 31 * size; - hash += 31 * assemblyType.hashCode(); - hash += 31 * ductThickness; - - return hash; - } - - /** - *

- * Deep copies the contents of the object from another object. - *

- * - * @param otherObject - *

- * The object to be copied from. - *

- */ - public void copy(SFRAssembly otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - // Copy the super's values. - super.copy(otherObject); - - // Copy the local values. - size = otherObject.size; - assemblyType = otherObject.assemblyType; - ductThickness = otherObject.ductThickness; - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return

- * The newly instantiated copied object. - *

- */ - @Override - public Object clone() { - - // Initialize a new object. - SFRAssembly object = new SFRAssembly(size); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } - - /** - * Overrides the default behavior (ignore) from SFRComponent and implements - * the accept operation for this SFRComponent's type. - */ - @Override - public void accept(ISFRComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRPin.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRPin.java deleted file mode 100644 index 95641a2bb..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRPin.java +++ /dev/null @@ -1,395 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core.assembly; - -import java.util.Iterator; -import java.util.TreeSet; - -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.core.Material; -import org.eclipse.ice.reactor.sfr.core.MaterialBlock; - -/** - *

- * Class representing the SFR pin structure. The pin is the basic unit of the - * FuelAssembly and ControlAssembly lattice, and contains either fissile, - * fertile or absorber pellets, in addition to structural features above and - * below the pellet columns. - *

- * - * @author Anna Wojtowicz - */ -public class SFRPin extends SFRComponent { - - /** - *

- * Type of gas filling the the pellet-clad gap (space between pellet stack - * and cladding). - *

- * - */ - private Material fillGas; - /** - *

- * Cylindrical tubing structure that houses a pin. - *

- * - */ - private Ring cladding; - /** - *

- * Collection of material blocks contained in a single SFRPin; can include - * pellet-clad gap rings, and pellet rings. - *

- * - */ - private TreeSet materialBlocks; - - /** - *

- * Nullary constructor. - *

- * - */ - public SFRPin() { - - this("SFR Pin 1", null, null, null); - - return; - } - - /** - *

- * Parameterized constructor with the name specified. - *

- * - * @param name - * Name of the pin. - */ - public SFRPin(String name) { - - // Set up all of the defaults. - this(name, null, null, null); - - return; - } - - /** - *

- * Parameterized constructor specified pin name, location, fill gas and - * material blocks (if any) specified. - *

- * - * @param name - * Name of the pin. - * @param cladding - * The pin's cladding. - * @param fillGas - * The pin's filler gas. - * @param materialBlocks - * A TreeSet of the pin's material blocks. - */ - public SFRPin(String name, Ring cladding, Material fillGas, - TreeSet materialBlocks) { - - // Call the super constructor with the default value. - super("SFR Pin 1"); - - // Set the other defaults. - setDescription("SFR Pin 1's Description"); - setId(1); - - // Try to set the name. - setName(name); - - // Numbers below are in mm. - - // Try to set the cladding. - setCladding(cladding); - - // If the cladding did not set properly, set the default value. - if (cladding == null || !cladding.equals(this.cladding)) { - // Create a stainless steel material. - Material steel = new Material("SS-316"); - steel.setDescription("Stainless Steel"); - - // Set the default cladding. - this.cladding = new Ring("Cladding", steel, -1, 16.25, 17.5); - } - - // Try to set the fill gas. - setFillGas(fillGas); - - // If the fill gas did not set properly, set the default value. - if (fillGas == null || !fillGas.equals(this.fillGas)) { - // Create a helium material. - Material helium = new Material("He"); - helium.setDescription("Helium"); - - // Set the default fill gas. - this.fillGas = helium; - } - - // Try to set the material blocks. - setMaterialBlocks(materialBlocks); - - // If the material blocks did not set properly, set the default value. - if (materialBlocks == null - || !materialBlocks.equals(this.materialBlocks)) { - // Create a fuel material. - Material fuel = new Material("UO2"); - fuel.setDescription("Uranium Oxide"); - - // Create the default MaterialBlock TreeSet (one block). - this.materialBlocks = new TreeSet(); - - MaterialBlock block = new MaterialBlock(); - block.setVertPosition(0); - - // Add the cladding, fill gas, and fuel to the block. - block.addRing(this.cladding); - - // Try to add fill gas and fuel if the cladding does not take up too - // much space. - double outerRadius = this.cladding.getInnerRadius(); - double innerRadius = outerRadius - 2.9167; - if (innerRadius > 0) { - block.addRing(new Ring("Fill Gas", this.fillGas, -1, - innerRadius, outerRadius)); - block.addRing(new Ring("Fuel", fuel, -1, 0, innerRadius)); - } - - // Add the block to the TreeSet. - this.materialBlocks.add(block); - } - - return; - } - - /** - *

- * Sets the type of gas present inside the pellet-clad (space between pellet - * stack and cladding) gap and gas plenum(s). - *

- * - * @param gas - * The pin's filler gas. Cannot be null. - */ - public void setFillGas(Material gas) { - - // Set the fill gas if the parameter is not null. - if (gas != null) { - fillGas = gas; - } - return; - } - - /** - *

- * Returns the type of fill gas present inside the pellet-stack gap (space - * between pellet stack and cladding) and gas plenum(s). - *

- * - * @return The pin's filler gas. - */ - public Material getFillGas() { - return fillGas; - } - - /** - *

- * Sets a collection of material blocks within the SFRPin. - *

- * - * @param materialBlocks - * A TreeSet of material blocks contained in the pin. Cannot be - * null or empty. - */ - public void setMaterialBlocks(TreeSet materialBlocks) { - - // Set the material blocks if the incoming TreeSet is not null or empty. - if (materialBlocks != null && !materialBlocks.isEmpty()) { - this.materialBlocks = materialBlocks; - } - - return; - } - - /** - *

- * Returns a collection of material blocks within the SFRPin. - *

- * - * @return Returns the TreeSet of material blocks contained in the pin. - */ - public TreeSet getMaterialBlocks() { - return materialBlocks; - } - - /** - *

- * Sets the SFRPin cladding as a Ring. - *

- * - * @param cladding - * The pin's cladding. Cannot be null. - */ - public void setCladding(Ring cladding) { - - // Set the cladding if the parameter is not null. - if (cladding != null) { - this.cladding = cladding; - } - - return; - } - - /** - *

- * Returns the SFRPin's cladding as a Ring. - *

- * - * @return The pin's cladding. - */ - public Ring getCladding() { - return cladding; - } - - /** - *

- * Returns the hashcode of the object. - *

- * - * @return The hashcode of the object. - */ - @Override - public int hashCode() { - - // Hash based on super's hashCode. - int hash = super.hashCode(); - - // Add local hashes. - hash += 31 * fillGas.hashCode(); - hash += 31 * cladding.hashCode(); - hash += 31 * materialBlocks.hashCode(); - - return hash; - } - - /** - *

- * Compares the contents of objects and returns true if that are identical. - *

- * - * @param otherObject - * The other object being compared against. - * @return Returns true if the both objects are equal, otherwise false. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof SFRPin) { - - // We can now cast the other object. - SFRPin pin = (SFRPin) otherObject; - - // Compare the values between the two objects. - equals = (super.equals(otherObject) && fillGas.equals(pin.fillGas) - && cladding.equals(pin.cladding) && materialBlocks.size() == pin.materialBlocks - .size()); - - // Because the TreeSet does not compare the actual MaterialBlock - // objects in the .equals method (it uses the compare function), we - // need to manuall check the material blocks. - Iterator iter1 = materialBlocks.iterator(); - Iterator iter2 = pin.materialBlocks.iterator(); - - // Loop until we have checked every block or we have a mismatch. - while (equals && iter1.hasNext()) { - equals = iter1.next().equals(iter2.next()); - } - - } - - return equals; - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - * The other object to copy the contents of. - */ - public void copy(SFRPin otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - - // Copy the super's values. - super.copy(otherObject); - - // Copy the local values. - fillGas.copy(otherObject.fillGas); - cladding.copy(otherObject.cladding); - materialBlocks.clear(); - materialBlocks.addAll(otherObject.materialBlocks); - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated object. - */ - @Override - public Object clone() { - - // Initialize a new object. - SFRPin object = new SFRPin(); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } - - /** - * Overrides the default behavior (ignore) from SFRComponent and implements - * the accept operation for this SFRComponent's type. - */ - @Override - public void accept(ISFRComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRRod.java b/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRRod.java deleted file mode 100644 index 53846cc8d..000000000 --- a/org.eclipse.ice.reactor.sfr/src/org/eclipse/ice/reactor/sfr/core/assembly/SFRRod.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.sfr.core.assembly; - -import org.eclipse.ice.reactor.sfr.base.ISFRComponentVisitor; -import org.eclipse.ice.reactor.sfr.base.SFRComponent; -import org.eclipse.ice.reactor.sfr.core.Material; - -/** - *

- * Class representing the solid cylindrical structure found inside radial - * reflector assemblies. - *

- * - * @author Anna Wojtowicz - */ -public class SFRRod extends SFRComponent { - - /** - *

- * A solid cylindrical structure of uniform reflector material. - *

- * - */ - private Ring reflector; - - /** - *

- * Nullary constructor. - *

- * - */ - public SFRRod() { - - // Set the default name, description and ID - setName("SFR Rod 1"); - setDescription("SFR Rod 1's Description"); - setId(1); - - // Define the reflector rod as a stainless steel ring with inner radius - // = 0 - Material rodMaterial = new Material("SS-316"); - rodMaterial.setDescription("Stainless Steel"); - - reflector = new Ring(); - reflector.setMaterial(rodMaterial); - reflector.setHeight(0.0); - reflector.setInnerRadius(0.0); - reflector.setOuterRadius(26.666); // Rod diameter = 2 * pin diameter (?) - - } - - /** - *

- * Parameterized constructor with name specified. - *

- * - * @param name - * Name of the SFRRod. - */ - public SFRRod(String name) { - - // Call nullary constructor - this(); - - // Set name - setName(name); - - } - - /** - *

- * Sets the rod. - *

- * - * @param reflector - * The reflector rod. - */ - public void setReflector(Ring reflector) { - - // Check that the reflector is not null - if (reflector != null) { - this.reflector = reflector; - } - return; - } - - /** - *

- * Returns the reflector rod as a Ring. - *

- * - * @return The reflector rod. - */ - public Ring getReflector() { - return reflector; - } - - /** - *

- * Returns the hashcode of the object. - *

- * - * @return The hashcode of the object. - */ - @Override - public int hashCode() { - - // Hash based upon superclass hash - int hash = super.hashCode(); - - // Add hash for local variable - hash += reflector.hashCode(); - - // Return the hash code - return hash; - } - - /** - *

- * Compares the contents of objects and returns true if that are identical. - *

- * - * @param otherObject - * The other object being compared against. - * @return Returns true if the both objects are equal, otherwise false. - */ - @Override - public boolean equals(Object otherObject) { - - // Check if otherObject is invalid - if (otherObject != null && otherObject instanceof SFRRod) { - - // Cast to a SFRRod so we can access its variables/methods - SFRRod otherRod = (SFRRod) otherObject; - - // Method will check for equality on two levels: shallow (within the - // scope of the SFRRod class), and deep (all inherited variables - // from superclass). Will only return true if both cases are true. - - // Create flags for checking shallow and deep equality, default to - // false - boolean shallowEqual = false; - boolean deepEqual = false; - - // Check if reflectors (shallow scope) are equal - if (reflector.equals(otherRod.reflector)) { - shallowEqual = true; - } - // Check if all inherited variables are equal (deep scope) - if (super.equals(otherRod) && shallowEqual) { - deepEqual = true; - } - - // Return final result - return deepEqual; - } - - // If otherObject was invalid, return false - else { - return false; - } - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - * The other object to copy the contents of. - */ - public void copy(SFRRod otherObject) { - - // Check if otherObject in invalid - if (otherObject == null) { - return; - } - // Call the superclass copy operation - super.copy(otherObject); - - // Copy the reflector - reflector = otherObject.reflector; - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated object. - */ - @Override - public Object clone() { - - // Create a new SFRRod - SFRRod rod = new SFRRod(); - - // Copy the contents from this SFRRod into the new one - rod.copy(this); - - // Return the new SFRRod - return rod; - - } - - /** - * Overrides the default behavior (ignore) from SFRComponent and implements - * the accept operation for this SFRComponent's type. - */ - @Override - public void accept(ISFRComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - return; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/.classpath b/org.eclipse.ice.reactor.test/.classpath deleted file mode 100644 index ad32c83a7..000000000 --- a/org.eclipse.ice.reactor.test/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.reactor.test/.gitignore b/org.eclipse.ice.reactor.test/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.reactor.test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.reactor.test/.project b/org.eclipse.ice.reactor.test/.project deleted file mode 100644 index 7569e9179..000000000 --- a/org.eclipse.ice.reactor.test/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.ice.reactor.test - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.reactor.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.reactor.test/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c0096b44f..000000000 --- a/org.eclipse.ice.reactor.test/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Mon Nov 19 10:17:58 EST 2012 -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/org.eclipse.ice.reactor.test/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.reactor.test/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 4d3b66710..000000000 --- a/org.eclipse.ice.reactor.test/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Nov 19 10:17:58 EST 2012 -eclipse.preferences.version=1 -resolve.requirebundle=false -pluginProject.extensions=false diff --git a/org.eclipse.ice.reactor.test/META-INF/MANIFEST.MF b/org.eclipse.ice.reactor.test/META-INF/MANIFEST.MF deleted file mode 100644 index bf29be5b3..000000000 --- a/org.eclipse.ice.reactor.test/META-INF/MANIFEST.MF +++ /dev/null @@ -1,11 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: ReactorTest -Bundle-SymbolicName: org.eclipse.ice.reactor.test -Bundle-Version: 2.1.8 -Fragment-Host: org.eclipse.ice.reactor;bundle-version="2.0.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: org.junit;bundle-version="4.8.2" -Import-Package: org.eclipse.ice.datastructures.test, - org.eclipse.ice.viz.service.datastructures -Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.reactor.test/about.html b/org.eclipse.ice.reactor.test/about.html deleted file mode 100644 index b47b18406..000000000 --- a/org.eclipse.ice.reactor.test/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

July 1, 2014

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/build.properties b/org.eclipse.ice.reactor.test/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/org.eclipse.ice.reactor.test/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/org.eclipse.ice.reactor.test/pom.xml b/org.eclipse.ice.reactor.test/pom.xml deleted file mode 100644 index a0f7deb13..000000000 --- a/org.eclipse.ice.reactor.test/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.reactor.test - eclipse-test-plugin - - true - - diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/FeatureSetTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/FeatureSetTester.java deleted file mode 100644 index 8850331e9..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/FeatureSetTester.java +++ /dev/null @@ -1,262 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.ArrayList; - -import org.eclipse.ice.analysistool.IData; -import org.eclipse.ice.reactor.FeatureSet; -import org.eclipse.ice.reactor.LWRData; -import org.junit.Test; - -/** - *

- * A class that tests the operations on FeatureSet. - *

- * - * @author Scott Forest Hull II - */ -public class FeatureSetTester { - /** - *

- * An operation that checks the constructor and getName operation. - *

- * - */ - @Test - public void checkConstruction() { - - // Local Declarations - FeatureSet featureSet; - String feature = "pin power"; - String nullFeature = null; - String emptyFeature = " "; - - // Test normal construction - featureSet = new FeatureSet(feature); - assertEquals(feature, featureSet.getName()); - - // Invalid construction - null - featureSet = new FeatureSet(nullFeature); - assertEquals(nullFeature, featureSet.getName()); - - // Invalid construction - empty - featureSet = new FeatureSet(emptyFeature); - assertEquals(nullFeature, featureSet.getName()); // Set as null! - - } - - /** - *

- * An operation that checks the getIData and addIData operation. - *

- * - */ - - @Test - public void checkData() { - - // Local Declarations - String feature1 = "Feature 1"; - String feature2 = "Feature 2"; - String nullFeature = null; - String emptyFeature = " "; - ArrayList dataList; - - // Setup Features - FeatureSet set1 = new FeatureSet(feature1); - FeatureSet set2 = new FeatureSet(nullFeature); - FeatureSet set3 = new FeatureSet(emptyFeature); - - // Setup data - LWRData data1 = new LWRData(feature1); - LWRData data2 = new LWRData(feature1); - LWRData data3 = new LWRData(feature2); - - // Try to add data to the feature set - assertTrue(set1.addIData(data1)); - // Check contents - assertEquals(1, set1.getIData().size()); - assertTrue(data1.equals(set1.getIData().get(0))); - - // Try to add data to the feature set - assertTrue(set1.addIData(data2)); - // Check contents - assertEquals(2, set1.getIData().size()); - assertTrue(data1.equals(set1.getIData().get(0))); - assertTrue(data2.equals(set1.getIData().get(0))); - - // Try to add data to the feature set - invalid data - assertFalse(set1.addIData(data3)); - // Check contents - show that only two pieces remain - assertEquals(2, set1.getIData().size()); - assertTrue(data1.equals(set1.getIData().get(0))); - assertTrue(data2.equals(set1.getIData().get(0))); - - // Show that data can be removed from the feature set by manipulating - // the arraylist directly - dataList = set1.getIData(); - dataList.remove(1); - // Check contents - show that the item was removed - assertEquals(1, set1.getIData().size()); - assertTrue(data1.equals(set1.getIData().get(0))); - - // Try to setup bad FeatureSets and show that data can not be added - - // Show the behavior of a null feature set - assertFalse(set2.addIData(data1)); - assertEquals(0, set2.getIData().size()); - dataList = set2.getIData(); - dataList.add(data1); - - // Show the list can not be manipulated - assertEquals(0, set2.getIData().size()); - - // Show the behavior of a empty string feature set - assertFalse(set3.addIData(data1)); - assertEquals(0, set3.getIData().size()); - dataList = set3.getIData(); - dataList.add(data1); - - // Show the list can not be manipulated - assertEquals(0, set3.getIData().size()); - - } - - /** - *

- * An operation that checks the equality operations. - *

- * - */ - @Test - public void checkEquality() { - - // Create an Object - FeatureSet object = new FeatureSet("Feature 1"); - - // Set its data - object.addIData(new LWRData("Feature 1")); - object.addIData(new LWRData("Feature 1")); - - // Create another FeatureSet to assert Equality with the last - FeatureSet equalObject = new FeatureSet("Feature 1"); - - // Set its data, equal to object - for (int i = 0; i < object.getIData().size(); i++) { - equalObject.addIData(object.getIData().get(i)); - } - - // Create a unEqualObject that is not equal to Object - FeatureSet unEqualObject = new FeatureSet("Feature 1"); - - // Set its data, not equal to testLWRComponent - unEqualObject.addIData(equalObject.getIData().get(0)); - - // Create a third object to test Transitivity - FeatureSet transitiveObject = new FeatureSet("Feature 1"); - - // Set it equal - // Set its data, equal to object - for (int i = 0; i < object.getIData().size(); i++) { - transitiveObject.addIData(object.getIData().get(i)); - } - - // Assert that these two LWRComponents are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * An operation that checks the operations on copying routines. - *

- * - */ - - @Test - public void checkCopying() { - - // Create an Object - FeatureSet object = new FeatureSet("Feature 1"); - FeatureSet copyObject, clonedObject; - - // Set its data - object.addIData(new LWRData("Feature 1")); - object.addIData(new LWRData("Feature 1")); - - // Run the copy routine - copyObject = new FeatureSet(null); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (FeatureSet) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/GridLabelProviderTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/GridLabelProviderTester.java deleted file mode 100644 index 87cfa9042..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/GridLabelProviderTester.java +++ /dev/null @@ -1,902 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Dataset; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5Datatype; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.GridLabelProvider; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class tests the GridLabelProvider class. - *

- * - * @author Scott Forest Hull II - */ -public class GridLabelProviderTester { - - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - int size = 5; - GridLabelProvider provider = new GridLabelProvider(size); - String name = "GRID!"; - String description = "LABELS!"; - int id = 4; - HDF5LWRTagType tag = provider.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - ArrayList columnLabels = new ArrayList(); - ArrayList rowLabels = new ArrayList(); - String testFileName = "testWrite.h5"; - - // Setup column Labels - columnLabels.add("Aasdasdasdasdasdasd"); - columnLabels.add("B"); - columnLabels.add("C"); - columnLabels.add("D"); - columnLabels.add("E"); - - // Setup row Labels - rowLabels.add("1"); - rowLabels.add("2"); - rowLabels.add("3"); - rowLabels.add("4"); - rowLabels.add("5"); - - // Setup Provider - provider.setName(name); - provider.setId(id); - provider.setDescription(description); - provider.setColumnLabels(columnLabels); - provider.setRowLabels(rowLabels); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNull(provider.getWriteableChildren()); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(provider.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(5, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - size - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "size"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(size, ((int[]) attribute.getValue())[0]); - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(provider.writeAttributes(null, h5Group)); - assertFalse(provider.writeAttributes(h5File, null)); - - // Check dataSet. Pass null to show it will fail. - assertFalse(provider.writeDatasets(null, null)); - assertFalse(provider.writeDatasets(null, h5Group)); - assertFalse(provider.writeDatasets(h5File, null)); - - // Perform a dataSet Write - assertTrue(provider.writeDatasets(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check the values of the dataset! - assertEquals(2, h5Group.getMemberList().size()); - assertEquals("Labels", h5Group.getMemberList().get(0).getName()); - assertEquals("State Point Data", h5Group.getMemberList().get(1) - .getName()); - // Get the Labels Group - H5Group labelsGroup = (H5Group) h5Group.getMemberList().get(0); - - // Check the values of that dataset - assertEquals("Column Labels", labelsGroup.getMemberList().get(0) - .getName()); - assertEquals("Row Labels", labelsGroup.getMemberList().get(1).getName()); - // Check labels that they are not a group - assertFalse(labelsGroup.getMemberList().get(0) instanceof Group); - assertFalse(labelsGroup.getMemberList().get(1) instanceof Group); - - // Check DataSet information - try { - // Check the rowData and columnData - Dataset rowSet = (Dataset) labelsGroup.getMemberList().get(1); - Dataset columnSet = (Dataset) labelsGroup.getMemberList().get(0); - Object rowData = rowSet.getData(); - Object colData = columnSet.getData(); - - // Iterate over the list and check the arrayLists - for (int i = 0; i < rowLabels.size(); i++) { - // Check contents of rowData and columnData at X - assertEquals(rowLabels.get(i), ((String[]) rowData)[i]); - assertEquals(columnLabels.get(i), ((String[]) colData)[i]); - } - - } catch (Exception e) { - // Fail out of the test - e.printStackTrace(); - fail(); - } - - // Check Group Creation - H5Group group = provider.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(3, h5Group.getMemberList().size()); - // Check that it has the same name as the root provider - assertEquals(provider.getName(), h5Group.getMemberList().get(2) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(2)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * This operation checks the constructor and it's default values. - *

- * - */ - @Test - public void checkConstruction() { - - // Local declarations - GridLabelProvider provider; - int defaultSize = 1; - String defaultName = "GridLabelProvider 1"; - String defaultDescription = "GridLabelProvider 1's Description"; - int defaultId = 1; - HDF5LWRTagType type = HDF5LWRTagType.GRID_LABEL_PROVIDER; - - // new declarations - int newSize = 10; - - // Show default value for constructor - provider = new GridLabelProvider(defaultSize); - // Check values - assertEquals(defaultSize, provider.getSize()); - assertEquals(defaultName, provider.getName()); - assertEquals(defaultDescription, provider.getDescription()); - assertEquals(defaultId, provider.getId()); - assertEquals(type, provider.getHDF5LWRTag()); - - // Show a new size set - provider = new GridLabelProvider(newSize); - // Check values - assertEquals(newSize, provider.getSize()); - assertEquals(defaultName, provider.getName()); - assertEquals(defaultDescription, provider.getDescription()); - assertEquals(defaultId, provider.getId()); - assertEquals(type, provider.getHDF5LWRTag()); - - // Show an illegal size, and notice the default value - provider = new GridLabelProvider(-1); - // Check values - assertEquals(defaultSize, provider.getSize()); // Defaults! - assertEquals(defaultName, provider.getName()); - assertEquals(defaultDescription, provider.getDescription()); - assertEquals(defaultId, provider.getId()); - assertEquals(type, provider.getHDF5LWRTag()); - - // Show an illegal size, and notice the default value - provider = new GridLabelProvider(0); - // Check values - assertEquals(defaultSize, provider.getSize()); // Defaults! - assertEquals(defaultName, provider.getName()); - assertEquals(defaultDescription, provider.getDescription()); - assertEquals(defaultId, provider.getId()); - assertEquals(type, provider.getHDF5LWRTag()); - - } - - /** - *

- * This operation tests the getters and setter of rowLabels. - *

- * - */ - @Test - public void checkRows() { - // Local Declarations - GridLabelProvider provider; - int size = 5; - ArrayList validList = new ArrayList(); - ArrayList invalidList = new ArrayList(); - - // Setup list - validList.add("A"); - validList.add("B"); - validList.add("C"); - validList.add("D"); - validList.add("E"); - - invalidList.add("A"); - invalidList.add("B"); - - // Check the default row size - provider = new GridLabelProvider(size); - assertEquals(size, provider.getSize()); - - // Get the default values for rows - should all be null - assertNull(provider.getLabelFromRow(1)); - assertNull(provider.getLabelFromRow(0)); - assertNull(provider.getLabelFromRow(-1)); - assertNull(provider.getLabelFromRow(6)); // Even though out of range, - // shouldn't break it - - // Check the default values for strings - should return null - assertEquals(-1, provider.getRowFromLabel(null)); - assertEquals(-1, - provider.getRowFromLabel("Not in there string191248015/*/*")); - - // Set invalid arraylist size - provider.setRowLabels(invalidList); - - // Get the default values for rows - should all be null - assertNull(provider.getLabelFromRow(1)); - assertNull(provider.getLabelFromRow(0)); - assertNull(provider.getLabelFromRow(-1)); - assertNull(provider.getLabelFromRow(6)); // Even though out of range, - // shouldn't break it - - // Check the default values for strings - should return null - assertEquals(-1, provider.getRowFromLabel(null)); - assertEquals(-1, - provider.getRowFromLabel("Not in there string191248015/*/*")); - - // Set a valid list - provider.setRowLabels(validList); - - // Check list size - assertEquals(validList.size(), provider.getSize()); - - // Check each label to see it is in there - for (int i = 0; i < validList.size(); i++) { - // Check row count and label identification - assertEquals(validList.get(i), provider.getLabelFromRow(i)); - assertEquals(i, provider.getRowFromLabel(validList.get(i))); - } - - // Show that the rows can be set again and that the data is separated - // from the list - // Set a valid list - validList.remove(0); - validList.add("DD"); - provider.setRowLabels(validList); - - // Check list size - assertEquals(validList.size(), provider.getSize()); - - // Check each label to see it is in there - for (int i = 0; i < validList.size(); i++) { - // Check row count and label identification - assertEquals(validList.get(i), provider.getLabelFromRow(i)); - assertEquals(i, provider.getRowFromLabel(validList.get(i))); - } - - // Check ArrayList separation - ArrayList newList = (ArrayList) validList.clone(); - validList.remove(0); - validList.add(0, "BOBBY!"); - - // Check list size - assertEquals(newList.size(), provider.getSize()); - - // Check each label to see it is in there - for (int i = 0; i < newList.size(); i++) { - // Check row count and label identification - assertEquals(newList.get(i), provider.getLabelFromRow(i)); - assertEquals(i, provider.getRowFromLabel(newList.get(i))); - } - - } - - /** - *

- * This operation checks the getters and setter of columnLabels. - *

- * - */ - @Test - public void checkColumns() { - // Local Declarations - GridLabelProvider provider; - int size = 5; - ArrayList validList = new ArrayList(); - ArrayList invalidList = new ArrayList(); - - // Setup list - validList.add("A"); - validList.add("B"); - validList.add("C"); - validList.add("D"); - validList.add("E"); - - invalidList.add("A"); - invalidList.add("B"); - - // Check the default Column size - provider = new GridLabelProvider(size); - assertEquals(size, provider.getSize()); - - // Get the default values for Columns - should all be null - assertNull(provider.getLabelFromColumn(1)); - assertNull(provider.getLabelFromColumn(0)); - assertNull(provider.getLabelFromColumn(-1)); - assertNull(provider.getLabelFromColumn(6)); // Even though out of range, - // shouldn't break it - - // Check the default values for strings - should return null - assertEquals(-1, provider.getColumnFromLabel(null)); - assertEquals(-1, - provider.getColumnFromLabel("Not in there string191248015/*/*")); - - // Set invalid arraylist size - provider.setColumnLabels(invalidList); - - // Get the default values for Columns - should all be null - assertNull(provider.getLabelFromColumn(1)); - assertNull(provider.getLabelFromColumn(0)); - assertNull(provider.getLabelFromColumn(-1)); - assertNull(provider.getLabelFromColumn(6)); // Even though out of range, - // shouldn't break it - - // Check the default values for strings - should return null - assertEquals(-1, provider.getColumnFromLabel(null)); - assertEquals(-1, - provider.getColumnFromLabel("Not in there string191248015/*/*")); - - // Set a valid list - provider.setColumnLabels(validList); - - // Check list size - assertEquals(validList.size(), provider.getSize()); - - // Check each label to see it is in there - for (int i = 0; i < validList.size(); i++) { - // Check Column count and label identification - assertEquals(validList.get(i), provider.getLabelFromColumn(i)); - assertEquals(i, provider.getColumnFromLabel(validList.get(i))); - } - - // Show that the Columns can be set again and that the data is separated - // from the list - // Set a valid list - validList.remove(0); - validList.add("DD"); - provider.setColumnLabels(validList); - - // Check list size - assertEquals(validList.size(), provider.getSize()); - - // Check each label to see it is in there - for (int i = 0; i < validList.size(); i++) { - // Check Column count and label identification - assertEquals(validList.get(i), provider.getLabelFromColumn(i)); - assertEquals(i, provider.getColumnFromLabel(validList.get(i))); - } - - // Check ArrayList separation - ArrayList newList = (ArrayList) validList.clone(); - validList.remove(0); - validList.add(0, "BOBBY!"); - - // Check list size - assertEquals(newList.size(), provider.getSize()); - - // Check each label to see it is in there - for (int i = 0; i < newList.size(); i++) { - // Check Column count and label identification - assertEquals(newList.get(i), provider.getLabelFromColumn(i)); - assertEquals(i, provider.getColumnFromLabel(newList.get(i))); - } - - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - GridLabelProvider object, equalObject, unEqualObject, transitiveObject; - ArrayList rowLabels = new ArrayList(); - ArrayList colLabels = new ArrayList(); - int size = 3; - - // Add rows and columns - rowLabels.add("Iffy"); - rowLabels.add("Biffy"); - rowLabels.add("Sissy"); - - colLabels.add("Silly"); - colLabels.add("Billy"); - colLabels.add("Milling"); - - // Setup root object - object = new GridLabelProvider(size); - object.setColumnLabels(colLabels); - object.setRowLabels(rowLabels); - - // Setup equalObject equal to object - equalObject = new GridLabelProvider(size); - equalObject.setColumnLabels(colLabels); - equalObject.setRowLabels(rowLabels); - - // Setup transitiveObject equal to object - transitiveObject = new GridLabelProvider(size); - transitiveObject.setColumnLabels(colLabels); - transitiveObject.setRowLabels(rowLabels); - - // Set its data, not equal to object - unEqualObject = new GridLabelProvider(size); - unEqualObject.setRowLabels(rowLabels); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - GridLabelProvider object, copyObject, clonedObject; - ArrayList rowLabels = new ArrayList(); - ArrayList colLabels = new ArrayList(); - int size = 3; - - // Add rows and columns - rowLabels.add("Iffy"); - rowLabels.add("Biffy"); - rowLabels.add("Sissy"); - - colLabels.add("Silly"); - colLabels.add("Billy"); - colLabels.add("Milling"); - - // Setup root object - object = new GridLabelProvider(size); - object.setColumnLabels(colLabels); - object.setRowLabels(rowLabels); - - // Run the copy routine - copyObject = new GridLabelProvider(0); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (GridLabelProvider) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - int size = 5; - GridLabelProvider component = new GridLabelProvider(size); - GridLabelProvider newComponent = new GridLabelProvider(-1); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - ArrayList columnLabels = new ArrayList(); - ArrayList rowLabels = new ArrayList(); - - // Setup column Labels - columnLabels.add("Aasdasdasdasdasdasd"); - columnLabels.add("B"); - columnLabels.add("C"); - columnLabels.add("D"); - columnLabels.add("E"); - - // Setup row Labels - rowLabels.add("1"); - rowLabels.add("2"); - rowLabels.add("3"); - rowLabels.add("4"); - rowLabels.add("5"); - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setRowLabels(rowLabels); - component.setColumnLabels(columnLabels); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup LWRComponent with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Write size attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "size", - size); - - // Create Datasets - String[] rowValues = new String[size]; - String[] columnValues = new String[size]; - - // Declare biggest size variables - int biggestRowSize = 0; - int biggestColumnSize = 0; - - // Loop over the labels - for (int i = 0; i < size; i++) { - - // Assign the current label - String rowLabel = rowLabels.get(i); - String columnLabel = columnLabels.get(i); - - // Get the biggest size label - biggestRowSize = Math.max(biggestRowSize, rowLabel.length()); - biggestColumnSize = Math.max(biggestColumnSize, - columnLabel.length()); - - // Assign the label to the String array - rowValues[i] = rowLabel; - columnValues[i] = columnLabel; - - } - - // Create datatypes for the row and column labels - H5Datatype rowH5Datatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, biggestRowSize, Datatype.NATIVE, - Datatype.NATIVE); - - H5Datatype columnH5Datatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, biggestColumnSize, Datatype.NATIVE, - Datatype.NATIVE); - - // Set the dimensions of the String array - long[] dims = { size }; - - H5Group labelsGroup = HdfWriterFactory.createH5Group(h5File, - "Labels", subGroup); - H5Group asdGroup = HdfWriterFactory.createH5Group(h5File, - "State Point Data", subGroup); - - // Create the row and column datasets - Dataset h5RowDataset = h5File.createScalarDS("Row Labels", - labelsGroup, rowH5Datatype, dims, null, null, 0, null); - Dataset h5ColumnDataset = h5File.createScalarDS("Column Labels", - labelsGroup, columnH5Datatype, dims, null, null, 0, null); - - // Write the String arrays to the right dataset - h5RowDataset.write(rowValues); - h5ColumnDataset.write(columnValues); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - - // Datasets should return false if null is passed - assertFalse(newComponent.readDatasets(null)); - - // Read the group in correctly - assertTrue(newComponent.readDatasets(subGroup)); - // Check with setup component - assertTrue(component.equals(newComponent)); - - // FIXME - We may need to remove this test pending a review on - // getMemberList(). - // //Now, lets try to set an erroneous H5Group with missing data - // subGroup.getMetadata().remove(1); - // subGroup.getMemberList().remove(0); - // subGroup.getMemberList().remove(0); - - // //Run it through - // assertFalse(newComponent.readAttributes(subGroup)); - // assertTrue(newComponent.readDatasets(subGroup)); //This will pass - // if a Dataset does not exist! - // //Check it does not change - // assertTrue(component.equals(newComponent)); - - // Check for null - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5 file! - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/GridLocationTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/GridLocationTester.java deleted file mode 100644 index f0c7939ac..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/GridLocationTester.java +++ /dev/null @@ -1,262 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.ice.reactor.GridLocation; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.junit.Test; - -/** - *

- * This class checks the operations on GridLocation. - *

- * - * @author Scott Forest Hull II - */ -public class GridLocationTester { - /** - *

- * This operation checks the construction and default values. - *

- * - */ - @Test - public void checkConstruction() { - - // Local Declarations - GridLocation location; - int defaultRow = 1; - int defaultCol = 1; - - // new values - int newRow = 5; - int newCol = 6; - - // Create a normal gridLocation with normal values - location = new GridLocation(newRow, newCol); - // Check values - assertEquals(newRow, location.getRow()); - assertEquals(newCol, location.getColumn()); - - // Create a normal gridLocation with normal values - 0 column and 0 row - location = new GridLocation(0, 0); - // Check values - defaults - assertEquals(0, location.getRow()); - assertEquals(0, location.getColumn()); - assertNotNull(location.getLWRDataProvider()); - - // Create a normal gridLocation with normal values of default - location = new GridLocation(defaultRow, defaultCol); - // Check values - assertEquals(defaultRow, location.getRow()); - assertEquals(defaultCol, location.getColumn()); - assertNotNull(location.getLWRDataProvider()); - - // Create a normal gridLocation with bad values - negative row and - // column - location = new GridLocation(-1, -1); - // Check values - defaults - assertEquals(defaultRow, location.getRow()); - assertEquals(defaultCol, location.getColumn()); - assertNotNull(location.getLWRDataProvider()); - - } - - /** - *

- * This operation tests the comparable operation. - *

- * - */ - @Test - public void checkComparable() { - - // Local declaration - GridLocation location1; - GridLocation location2; - int row1 = 2; - int col1 = 9; - int row2 = 6; - int col2 = 7; - - // Instantiate a GridLocation with same row and col - location1 = new GridLocation(row1, col1); - location2 = new GridLocation(row1, col1); - - // Check compareTo - should be 0 - assertEquals(0, location1.compareTo(location2)); - - // Instantiate a GridLocation with different row and col - location1 = new GridLocation(row1, col1); - location2 = new GridLocation(row2, col2); - - // Check compareTo - should be equal to row1-row2 - assertEquals(row1 - row2, location1.compareTo(location2)); - - // Instantiate a GridLocation with same row but different col - location1 = new GridLocation(row1, col1); - location2 = new GridLocation(row1, col2); - - // Check compareTo - should be equal to col1 - col2 - assertEquals(col1 - col2, location1.compareTo(location2)); - - // Instantiate a GridLocation with same col but different row - location1 = new GridLocation(row1, col1); - location2 = new GridLocation(row2, col1); - - // Check compareTo - should be false - assertEquals(row1 - row2, location1.compareTo(location2)); - - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - GridLocation object, equalObject, unEqualObject, transitiveObject; - int row1 = 3, col1 = 4; - int row2 = 3, col2 = 5; - - // Setup root object - object = new GridLocation(row1, col1); - - // Setup equalObject equal to object - equalObject = new GridLocation(row1, col1); - - // Setup transitiveObject equal to object - transitiveObject = new GridLocation(row1, col1); - - // Set its data, not equal to object - unEqualObject = new GridLocation(row2, col2); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - @Test - public void checkCopying() { - - // Local declarations - GridLocation object, copyObject, clonedObject; - int row1 = 3, col1 = 4; - - // Setup root object - object = new GridLocation(row1, col1); - - // Run the copy routine - copyObject = new GridLocation(0, 0); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (GridLocation) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * Checks the getter and setter for LWRDataProvider. - *

- * - */ - @Test - public void checkDataProvider() { - - // Local Declarations - LWRDataProvider provider1 = new LWRDataProvider(); - provider1.setSourceInfo("Source Info 3"); - GridLocation location1 = new GridLocation(0, 0); - - // Try to set - location1.setLWRDataProvider(provider1); - - // Check comparison - assertTrue(location1.getLWRDataProvider().equals(provider1)); - - // Try null - location1.setLWRDataProvider(null); - - // Show that it does not change - assertTrue(location1.getLWRDataProvider().equals(provider1)); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/HDF5LWRTagTypeTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/HDF5LWRTagTypeTester.java deleted file mode 100644 index 65d7944ec..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/HDF5LWRTagTypeTester.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; - -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.junit.Test; - -/** - *

- * A class that tests the HDF5LWRTagType's methods. - *

- * - * @author Scott Forest Hull II - */ -public class HDF5LWRTagTypeTester { - /** - *

- * Checks the toString and toType operations on HDF5LWRTagType. - *

- * - */ - @Test - public void checkTyping() { - - // Local Declarations - HDF5LWRTagType type; - - // Check the toString implementations of the HDF5 enum - assertEquals("BWReactor", HDF5LWRTagType.BWREACTOR.toString()); - assertEquals("Control Bank", HDF5LWRTagType.CONTROL_BANK.toString()); - assertEquals("Fuel Assembly", HDF5LWRTagType.FUEL_ASSEMBLY.toString()); - assertEquals("Incore Instrument", - HDF5LWRTagType.INCORE_INSTRUMENT.toString()); - assertEquals("LWRComponent", HDF5LWRTagType.LWRCOMPONENT.toString()); - assertEquals("LWRComposite", HDF5LWRTagType.LWRCOMPOSITE.toString()); - assertEquals("LWReactor", HDF5LWRTagType.LWREACTOR.toString()); - assertEquals("LWRRod", HDF5LWRTagType.LWRROD.toString()); - assertEquals("Material", HDF5LWRTagType.MATERIAL.toString()); - assertEquals("PWRAssembly", HDF5LWRTagType.PWRASSEMBLY.toString()); - assertEquals("PWReactor", HDF5LWRTagType.PWREACTOR.toString()); - assertEquals("Ring", HDF5LWRTagType.RING.toString()); - assertEquals("Rod Cluster Assembly", - HDF5LWRTagType.ROD_CLUSTER_ASSEMBLY.toString()); - assertEquals("Tube", HDF5LWRTagType.TUBE.toString()); - assertEquals("Grid Label Provider", - HDF5LWRTagType.GRID_LABEL_PROVIDER.toString()); - assertEquals("LWRGridManager", HDF5LWRTagType.LWRGRIDMANAGER.toString()); - assertEquals("MaterialBlock", HDF5LWRTagType.MATERIALBLOCK.toString()); - - // Check the toType implementations of the HDf5 enum - - // Specify the type - type = HDF5LWRTagType.BWREACTOR; - // Check the type - assertEquals(type.toType("BWReactor"), HDF5LWRTagType.BWREACTOR); - - // Specify the type - type = HDF5LWRTagType.CONTROL_BANK; - // Check the type - assertEquals(type.toType("Control Bank"), HDF5LWRTagType.CONTROL_BANK); - - // Specify the type - type = HDF5LWRTagType.FUEL_ASSEMBLY; - // Check the type - assertEquals(type.toType("Fuel Assembly"), HDF5LWRTagType.FUEL_ASSEMBLY); - - // Specify the type - type = HDF5LWRTagType.INCORE_INSTRUMENT; - // Check the type - assertEquals(type.toType("Incore Instrument"), - HDF5LWRTagType.INCORE_INSTRUMENT); - - // Specify the type - type = HDF5LWRTagType.LWRCOMPONENT; - // Check the type - assertEquals(type.toType("LWRComponent"), HDF5LWRTagType.LWRCOMPONENT); - - // Specify the type - type = HDF5LWRTagType.LWRCOMPOSITE; - // Check the type - assertEquals(type.toType("LWRComposite"), HDF5LWRTagType.LWRCOMPOSITE); - - // Specify the type - type = HDF5LWRTagType.LWREACTOR; - // Check the type - assertEquals(type.toType("LWReactor"), HDF5LWRTagType.LWREACTOR); - - // Specify the type - type = HDF5LWRTagType.LWRROD; - // Check the type - assertEquals(type.toType("LWRRod"), HDF5LWRTagType.LWRROD); - - // Specify the type - type = HDF5LWRTagType.MATERIAL; - // Check the type - assertEquals(type.toType("Material"), HDF5LWRTagType.MATERIAL); - - // Specify the type - type = HDF5LWRTagType.PWRASSEMBLY; - // Check the type - assertEquals(type.toType("PWRAssembly"), HDF5LWRTagType.PWRASSEMBLY); - - // Specify the type - type = HDF5LWRTagType.PWREACTOR; - // Check the type - assertEquals(type.toType("PWReactor"), HDF5LWRTagType.PWREACTOR); - - // Specify the type - type = HDF5LWRTagType.RING; - // Check the type - assertEquals(type.toType("Ring"), HDF5LWRTagType.RING); - - // Specify the type - type = HDF5LWRTagType.ROD_CLUSTER_ASSEMBLY; - // Check the type - assertEquals(type.toType("Rod Cluster Assembly"), - HDF5LWRTagType.ROD_CLUSTER_ASSEMBLY); - - // Specify the type - type = HDF5LWRTagType.TUBE; - // Check the type - assertEquals(type.toType("Tube"), HDF5LWRTagType.TUBE); - - // Specify the type - type = HDF5LWRTagType.GRID_LABEL_PROVIDER; - // Check the type - assertEquals(type.toType("Grid Label Provider"), - HDF5LWRTagType.GRID_LABEL_PROVIDER); - - // Specify the type - type = HDF5LWRTagType.LWRGRIDMANAGER; - // Check the type - assertEquals(type.toType("LWRGridManager"), - HDF5LWRTagType.LWRGRIDMANAGER); - - // Specify the type - type = HDF5LWRTagType.MATERIALBLOCK; - // Check the type - assertEquals(type.toType("MaterialBlock"), HDF5LWRTagType.MATERIALBLOCK); - - // Try to return a type that does not exist - assertEquals(type.toType("asdasd1"), null); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRComponentReaderTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRComponentReaderTester.java deleted file mode 100644 index de8edbc5e..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRComponentReaderTester.java +++ /dev/null @@ -1,485 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.TreeSet; - -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.reactor.AssemblyType; -import org.eclipse.ice.reactor.LWRComponentReader; -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRRod; -import org.eclipse.ice.reactor.Material; -import org.eclipse.ice.reactor.MaterialBlock; -import org.eclipse.ice.reactor.MaterialType; -import org.eclipse.ice.reactor.Ring; -import org.eclipse.ice.reactor.Tube; -import org.eclipse.ice.reactor.TubeType; -import org.eclipse.ice.reactor.pwr.ControlBank; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.IncoreInstrument; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.eclipse.ice.reactor.pwr.RodClusterAssembly; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - * @author Eric J. Lingerfelt - */ -public class LWRComponentReaderTester { - /** - * - */ - @BeforeClass - public static void beforeClass() { - - } - - /** - *

- * Creates and returns the same reactor used to write the file - * data/reader_test.h5 - *

- * - * @return - *

- * The same reactor used to write the file data/reader_test.h5 - *

- */ - private PressurizedWaterReactor createPWReactor() { - - // Create a reactor of size 2 X 2 - PressurizedWaterReactor pwReactor = new PressurizedWaterReactor(15); - pwReactor.setName("PWR Reactor"); - pwReactor.setFuelAssemblyPitch(0.12345678912345); - - // PWREACTOR GRID - // LABELS///////////////////////////////////////////////// - // Create a list of row labels - ArrayList rowLabelsReactor = new ArrayList(); - rowLabelsReactor.add("1"); - rowLabelsReactor.add("2"); - rowLabelsReactor.add("3"); - rowLabelsReactor.add("4"); - rowLabelsReactor.add("5"); - rowLabelsReactor.add("6"); - rowLabelsReactor.add("7"); - rowLabelsReactor.add("8"); - rowLabelsReactor.add("9"); - rowLabelsReactor.add("10"); - rowLabelsReactor.add("11"); - rowLabelsReactor.add("12"); - rowLabelsReactor.add("13"); - rowLabelsReactor.add("14"); - rowLabelsReactor.add("15"); - - // Create a list of column labels - ArrayList columnLabelsReactor = new ArrayList(); - columnLabelsReactor.add("R"); - columnLabelsReactor.add("P"); - columnLabelsReactor.add("N"); - columnLabelsReactor.add("M"); - columnLabelsReactor.add("L"); - columnLabelsReactor.add("K"); - columnLabelsReactor.add("J"); - columnLabelsReactor.add("H"); - columnLabelsReactor.add("G"); - columnLabelsReactor.add("F"); - columnLabelsReactor.add("E"); - columnLabelsReactor.add("D"); - columnLabelsReactor.add("C"); - columnLabelsReactor.add("B"); - columnLabelsReactor.add("A"); - - // Assign the label arrays - pwReactor.getGridLabelProvider().setRowLabels(rowLabelsReactor); - pwReactor.getGridLabelProvider().setColumnLabels(columnLabelsReactor); - - // CONTROL - // BANKS////////////////////////////////////////////////////////// - // Add two control banks to the reactor - pwReactor.addAssembly(AssemblyType.ControlBank, - new ControlBank("A", 0.625, 230)); - pwReactor.addAssembly(AssemblyType.ControlBank, - new ControlBank("B", 0.625, 215)); - pwReactor.addAssembly(AssemblyType.ControlBank, - new ControlBank("C", 0.625, 200)); - pwReactor.addAssembly(AssemblyType.ControlBank, - new ControlBank("D", 0.625, 185)); - - // Assign a position for the control banks - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 4, 4); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 4, 10); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 5, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 7, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 7, 9); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 9, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 10, 4); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 10, 10); - - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 1, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 1, 9); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 5, 1); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 5, 13); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 9, 1); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 9, 13); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 13, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 13, 9); - - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 1, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 5, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 5, 9); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 7, 1); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 7, 13); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 9, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 9, 9); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 13, 7); - - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 3, 3); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 3, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 3, 11); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 7, 3); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 7, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 7, 11); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 11, 3); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 11, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 11, 11); - - // INCORE - // INSTRUMENTS///////////////////////////////////////////////////// - // Create incore instruments for the reactor - IncoreInstrument incoreInstrument1 = new IncoreInstrument(); - incoreInstrument1.setName("Incore Instrument 1"); - IncoreInstrument incoreInstrument2 = new IncoreInstrument(); - incoreInstrument2.setName("Incore Instrument 2"); - IncoreInstrument incoreInstrument3 = new IncoreInstrument(); - incoreInstrument3.setName("Incore Instrument 3"); - IncoreInstrument incoreInstrument4 = new IncoreInstrument(); - incoreInstrument4.setName("Incore Instrument 4"); - - // Create the thimble material - Material material = new Material("stainless steel"); - material.setMaterialType(MaterialType.SOLID); - - // Create the thimble - Ring thimble = new Ring("Thimble", material, 155, 0.258, 0.382); - incoreInstrument1.setThimble(thimble); - incoreInstrument2.setThimble((Ring) thimble.clone()); - incoreInstrument3.setThimble((Ring) thimble.clone()); - incoreInstrument4.setThimble((Ring) thimble.clone()); - - // Add the incore instruments - pwReactor.addAssembly(AssemblyType.IncoreInstrument, incoreInstrument1); - pwReactor.addAssembly(AssemblyType.IncoreInstrument, incoreInstrument2); - pwReactor.addAssembly(AssemblyType.IncoreInstrument, incoreInstrument3); - pwReactor.addAssembly(AssemblyType.IncoreInstrument, incoreInstrument4); - - // Assign locations for the incore instruments - pwReactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - incoreInstrument1.getName(), 2, 1); - pwReactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - incoreInstrument2.getName(), 6, 5); - pwReactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - incoreInstrument3.getName(), 11, 2); - pwReactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - incoreInstrument4.getName(), 13, 8); - - // FUEL - // ASSEMBLIES//////////////////////////////////////////////////////// - // Create a fuel assembly - FuelAssembly fuelAssembly = new FuelAssembly("Fuel Assembly A", 17); - - // Create a list of row labels - ArrayList rowLabelsFuelAssembly = new ArrayList(); - rowLabelsFuelAssembly.add("1"); - rowLabelsFuelAssembly.add("2"); - rowLabelsFuelAssembly.add("3"); - rowLabelsFuelAssembly.add("4"); - rowLabelsFuelAssembly.add("5"); - rowLabelsFuelAssembly.add("6"); - rowLabelsFuelAssembly.add("7"); - rowLabelsFuelAssembly.add("8"); - rowLabelsFuelAssembly.add("9"); - rowLabelsFuelAssembly.add("10"); - rowLabelsFuelAssembly.add("11"); - rowLabelsFuelAssembly.add("12"); - rowLabelsFuelAssembly.add("13"); - rowLabelsFuelAssembly.add("14"); - rowLabelsFuelAssembly.add("15"); - rowLabelsFuelAssembly.add("16"); - rowLabelsFuelAssembly.add("17"); - - // Create list of column labels - ArrayList columnLabelsFuelAssembly = new ArrayList(); - columnLabelsFuelAssembly.add("A"); - columnLabelsFuelAssembly.add("B"); - columnLabelsFuelAssembly.add("C"); - columnLabelsFuelAssembly.add("D"); - columnLabelsFuelAssembly.add("E"); - columnLabelsFuelAssembly.add("F"); - columnLabelsFuelAssembly.add("G"); - columnLabelsFuelAssembly.add("H"); - columnLabelsFuelAssembly.add("I"); - columnLabelsFuelAssembly.add("J"); - columnLabelsFuelAssembly.add("K"); - columnLabelsFuelAssembly.add("L"); - columnLabelsFuelAssembly.add("M"); - columnLabelsFuelAssembly.add("N"); - columnLabelsFuelAssembly.add("O"); - columnLabelsFuelAssembly.add("P"); - columnLabelsFuelAssembly.add("Q"); - - // Assign the labels array - fuelAssembly.getGridLabelProvider().setRowLabels(rowLabelsFuelAssembly); - fuelAssembly.getGridLabelProvider() - .setColumnLabels(columnLabelsFuelAssembly); - - // Create a guide tube - Tube guideTube = new Tube("Guide Tube A", TubeType.GUIDE); - guideTube.setHeight(1.56); - guideTube.setInnerRadius(7.89); - guideTube.setOuterRadius(10.0); - - // Create material for the guide tube - Material materialGuideTube = new Material("Guide Tube Material"); - - // Set the material for the guide tube - guideTube.setMaterial(materialGuideTube); - - // Add the guide tube to the fuel assembly - fuelAssembly.addTube(guideTube); - - // Assign the guide tube a location - fuelAssembly.setTubeLocation(guideTube.getName(), 8, 13); - - // Create an instrument tube - Tube instrumentTube = new Tube("Instrument Tube A", - TubeType.INSTRUMENT); - instrumentTube.setHeight(1.2); - instrumentTube.setInnerRadius(0.987); - instrumentTube.setOuterRadius(34.5); - - // Create material for the instrument tube - Material materialInstrumentTube = new Material( - "Instrument Tube Material"); - - // Set the material for the instrument tube - instrumentTube.setMaterial(materialInstrumentTube); - - // Add the instrument tube to the fuel assembly - fuelAssembly.addTube(instrumentTube); - - // Assign the instrument tube a location - fuelAssembly.setTubeLocation(instrumentTube.getName(), 8, 8); - - // Create an lwrrod for this fuel assembly - LWRRod rod = new LWRRod("LWRRod A"); - rod.setPressure(23.56); - - // Create a fill gas for the rod - Material fillGas = new Material("He", MaterialType.GAS); - rod.setFillGas(fillGas); - - // Create a materialBlock for the rod - MaterialBlock materialBlock = new MaterialBlock(); - materialBlock.setName("Stack of Cards"); - - // Create some rings for the materialBlock - Ring ring1 = new Ring("Ring 1"); - ring1.setHeight(155); - ring1.setOuterRadius(0.5); - - // Create a material for ring1 - Material ring1Material = new Material("Ring 1 Material", - MaterialType.SOLID); - ring1.setMaterial(ring1Material); - - // Create some rings for the materialBlock - Ring ring2 = new Ring("Ring 2"); - ring2.setHeight(155); - ring2.setInnerRadius(0.5); - ring2.setOuterRadius(1.0); - - // Create a material for ring1 - Material ring2Material = new Material("Ring 2 Material", - MaterialType.SOLID); - ring2.setMaterial(ring2Material); - - // Add rings to the materialBlock - materialBlock.addRing(ring1); - materialBlock.addRing(ring2); - - TreeSet materialBlockList = new TreeSet(); - materialBlockList.add(materialBlock); - - // Set the MaterialBlock in the rod - rod.setMaterialBlocks(materialBlockList); - - // Create a clad - Ring clad = new Ring("Clad"); - clad.setHeight(155); - clad.setInnerRadius(0.9); - clad.setOuterRadius(1.0); - - // Create a material for the clad - Material materialClad = new Material("Clad Material", - MaterialType.SOLID); - clad.setMaterial(materialClad); - - // Add the clad - rod.setClad(clad); - - // Add the rod to the fuel assembly - fuelAssembly.addLWRRod(rod); - - // Assign the rod a location - fuelAssembly.setLWRRodLocation(rod.getName(), 15, 4); - - // Add the fuel assembly to the reactor - pwReactor.addAssembly(AssemblyType.Fuel, fuelAssembly); - - // Assign a position on the grid of the reactor - pwReactor.setAssemblyLocation(AssemblyType.Fuel, fuelAssembly.getName(), - 4, 4); - - // ROD CLUSTER - // ASSEMBLIES///////////////////////////////////////////////// - // Create a rca - RodClusterAssembly rodClusterAssembly = new RodClusterAssembly( - "Rod Cluster Assembly A", 17); - - // Add the rca to the reactor - pwReactor.addAssembly(AssemblyType.RodCluster, rodClusterAssembly); - - // Assign the rca location - pwReactor.setAssemblyLocation(AssemblyType.RodCluster, - rodClusterAssembly.getName(), 5, 2); - - // Add LWRData - // Setup LWRData - String feature1 = "Feature 1"; - String feature2 = "Feature 2"; - double time1 = 1.0, time2 = 3.0, time3 = 3.5; - LWRData data1, data2, data3, data4, data5; - ArrayList position1 = new ArrayList(), - position2 = new ArrayList(), - position3 = new ArrayList(), - position4 = new ArrayList(), - position5 = new ArrayList(); - - // Setup Positions - - // Setup Position 1 - position1.add(0.0); - position1.add(1.0); - position1.add(0.0); - - // Setup Position 2 - position2.add(0.0); - position2.add(1.0); - position2.add(4.0); - - // Setup Position 3 - position3.add(1.0); - position3.add(1.0); - position3.add(0.0); - - // Setup Position 4 - position4.add(0.0); - position4.add(1.0); - position4.add(1.0); - - // Setup Position 5 - position4.add(0.0); - position4.add(1.0); - position4.add(3.0); - - // Setup data1 - data1 = new LWRData(feature1); - data1.setPosition(position1); - data1.setValue(1.0); - data1.setUncertainty(1.5); - data1.setUnits("Units " + 123456); - - // Setup data2 - data2 = new LWRData(feature1); - data2.setPosition(position2); - data2.setValue(2.0); - data2.setUncertainty(2.5); - data2.setUnits("Units " + 2); - - // Setup data3 - data3 = new LWRData(feature1); - data3.setPosition(position3); - data3.setValue(3.0); - data3.setUncertainty(3.5); - data3.setUnits("Units " + 3); - - // Setup data4 - data4 = new LWRData(feature1); - data4.setPosition(position4); - data4.setValue(4.0); - data4.setUncertainty(4.5); - data4.setUnits("Units " + 4); - - // Setup data5 - data5 = new LWRData(feature2); - data5.setPosition(position5); - data5.setValue(5.0); - data5.setUncertainty(5.5); - data5.setUnits("Units " + 5); - - pwReactor.addData(data1, time1); - pwReactor.addData(data2, time1); - pwReactor.addData(data3, time2); - pwReactor.addData(data4, time3); - pwReactor.addData(data5, time3); - - return pwReactor; - - } - - /** - * - */ - @Test - public void checkReading() { - - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + "reactorData"; - File dataFile = new File(userDir + separator + "reader_test.h5"); - URI uri = dataFile.toURI(); - - // Create a new read - LWRComponentReader lWRComponentReader = new LWRComponentReader(); - - // Read from the URI - IHdfReadable iHdfReadable = lWRComponentReader.read(uri); - - // Cast to a PWReactor - PressurizedWaterReactor reactor = (PressurizedWaterReactor) iHdfReadable; - assertNotNull(reactor); - - // Check values here - assertTrue(createPWReactor().equals(reactor)); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRComponentTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRComponentTester.java deleted file mode 100644 index dc4162113..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRComponentTester.java +++ /dev/null @@ -1,1357 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.Vector; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5CompoundDS; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.datastructures.test.TestComponentListener; -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRComponent; -import org.eclipse.ice.reactor.LWRData; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * A class that tests the LWRComponent - *

- * - * @author Scott Forest Hull II - */ -public class LWRComponentTester { - /** - *

- * The component listener to test with for the notifications on - * LWRComponent. - *

- * - */ - private TestComponentListener testComponentListener; - - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - - // Local declarations - LWRComponent component = new LWRComponent(); - HDF5LWRTagType type = HDF5LWRTagType.LWRCOMPONENT; - - String timeUnit = "seconds"; - - // Check default values - name, id, description - assertEquals("Component 1", component.getName()); - assertEquals(0, component.getId()); - assertEquals("Component 1's Description", component.getDescription()); - assertEquals(type, component.getHDF5LWRTag()); - assertEquals(timeUnit, component.getTimeUnits()); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getNumberOfTimeSteps()); - assertEquals("No Source Available", component.getSourceInfo()); - - // Check nonnullary constructor - name - component = new LWRComponent("Bob"); - - // Check default values - name, id, description - assertEquals("Bob", component.getName()); - assertEquals(0, component.getId()); - assertEquals("Component 1's Description", component.getDescription()); - assertEquals(type, component.getHDF5LWRTag()); - assertEquals(timeUnit, component.getTimeUnits()); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getNumberOfTimeSteps()); - assertEquals("No Source Available", component.getSourceInfo()); - - // Check erroneous value for constructor - name=null - component = new LWRComponent(null); - - // Check default values - name, id, description - assertEquals("Component 1", component.getName()); // Defaults - assertEquals(0, component.getId()); - assertEquals("Component 1's Description", component.getDescription()); - assertEquals(type, component.getHDF5LWRTag()); - assertEquals(timeUnit, component.getTimeUnits()); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getNumberOfTimeSteps()); - assertEquals("No Source Available", component.getSourceInfo()); - - // Check erroneous value for constructor - empty string - component = new LWRComponent(""); - - // Check default values - name, id, description - assertEquals("Component 1", component.getName()); // Defaults - assertEquals(0, component.getId()); - assertEquals("Component 1's Description", component.getDescription()); - assertEquals(type, component.getHDF5LWRTag()); - assertEquals(timeUnit, component.getTimeUnits()); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getNumberOfTimeSteps()); - assertEquals("No Source Available", component.getSourceInfo()); - - } - - /** - *

- * Checks the attribute's getters and setters. - *

- * - */ - @Test - public void checkAttributes() { - // Local declarations - LWRComponent component = new LWRComponent(); - - // Change all values - component.setName("Component 2"); - component.setId(2); - component.setDescription("FooRA!"); - - // Check values - name, id, description - assertEquals("Component 2", component.getName()); - assertEquals(2, component.getId()); - assertEquals("FooRA!", component.getDescription()); - - // Try to set them illegally - component.setName(null); - component.setId(-1); - component.setDescription(null); - - // Check values - name, id, description - does not change! - assertEquals("Component 2", component.getName()); - assertEquals(2, component.getId()); - assertEquals("FooRA!", component.getDescription()); - - // Check setting the name to empty string - component.setName(""); - component.setName(" "); - component.setName(" "); - component.setDescription(""); - component.setDescription(" "); - component.setDescription(" "); - - // See the name will not be the representation of the empty string. - assertEquals("Component 2", component.getName()); - assertEquals(2, component.getId()); - assertEquals("FooRA!", component.getDescription()); - - // Also, see that it will always trim the strings for Name and - // description - component.setName("Component 3 "); - component.setDescription(" FooRA!! "); - - // See the data is trimmed appropriately - assertEquals("Component 3", component.getName()); // Note double space - // inbetween - // Component and 3 - assertEquals(2, component.getId()); - assertEquals("FooRA!!", component.getDescription()); - - } - - /** - *

- * This operation checks equals() and hashCode() operations. - *

- * - */ - @Test - public void checkEquality() { - - // Create a LWRComponent - LWRComponent testLWRComponent = new LWRComponent("ICE LWRComponent"); - - // Set its data - testLWRComponent.setId(12); - testLWRComponent.setDescription("This is a LWRComponent that will " - + "be used for testing equality with other LWRComponents."); - - // Create another LWRComponent to assert Equality with the last - LWRComponent equalObject = new LWRComponent("ICE LWRComponent"); - - // Set its data, equal to testLWRComponent - equalObject.setId(12); - equalObject.setDescription("This is a LWRComponent that will " - + "be used for testing equality with other LWRComponents."); - - // Create a LWRComponent that is not equal to testLWRComponent - LWRComponent unEqualObject = new LWRComponent(); - - // Set its data, not equal to testLWRComponent - unEqualObject.setId(52); - unEqualObject.setName("Bill the LWRComponent"); - unEqualObject - .setDescription("This is a LWRComponent to verify that " - + "LWRComponent.equals() returns false for an object that is not " - + "equivalent to testLWRComponent."); - - // Create a third LWRComponent to test Transitivity - LWRComponent transitiveObject = new LWRComponent("ICE LWRComponent"); - - // Set its data, not equal to testLWRComponent - transitiveObject.setId(12); - transitiveObject.setDescription("This is a LWRComponent that will " - + "be used for testing equality with other LWRComponents."); - - // Assert that these two LWRComponents are equal - assertTrue(testLWRComponent.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(testLWRComponent.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(testLWRComponent.equals(testLWRComponent)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(testLWRComponent.equals(equalObject) - && equalObject.equals(testLWRComponent)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (testLWRComponent.equals(equalObject) - && equalObject.equals(transitiveObject)) { - assertTrue(testLWRComponent.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(testLWRComponent.equals(equalObject) - && testLWRComponent.equals(equalObject) - && testLWRComponent.equals(equalObject)); - assertTrue(!testLWRComponent.equals(unEqualObject) - && !testLWRComponent.equals(unEqualObject) - && !testLWRComponent.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(testLWRComponent==null); - - // Assert that two equal objects have the same hashcode - assertTrue(testLWRComponent.equals(equalObject) - && testLWRComponent.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(testLWRComponent.hashCode() == testLWRComponent.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(testLWRComponent.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the visitor pattern. - *

- * - */ - public void checkVisitation() { - // TODO Auto-generated method stub - - } - - /** - *

- * This operation checks the notifications for changes on the LWRComponent. - *

- * - */ - @Test - public void checkNotifications() { - - // Local declarations - LWRComponent component = new LWRComponent("Bob"); - LWRData data = new LWRData(); - data.setFeature("Billy"); - - // Create the listener - this.testComponentListener = new TestComponentListener(); - - // Register the listener - component.register(this.testComponentListener); - - // Change the name - component.setName("Bob"); - - // See if the listener was notified - assertTrue(testComponentListener.wasNotified()); - - // Reset the listener - testComponentListener.reset(); - - // Change the id - component.setId(55); - - // See if the listener was notified - assertTrue(testComponentListener.wasNotified()); - - // Reset the listener - testComponentListener.reset(); - - // set the SourceInfo - component.setSourceInfo("Bob"); - - // See if the listener was notified - assertTrue(testComponentListener.wasNotified()); - - // Reset the listener - testComponentListener.reset(); - - // set the timeStep - component.setTime(5); - - // See if the listener was notified - assertTrue(testComponentListener.wasNotified()); - - // Reset the listener - testComponentListener.reset(); - - // Add a feature to the tree - component.addData(data, 0.0); - - // See if the listener was notified - assertTrue(testComponentListener.wasNotified()); - - // Reset the listener - testComponentListener.reset(); - - // Remove data - component.removeAllDataFromFeature(data.getFeature()); - - // See if the listener was notified - assertTrue(testComponentListener.wasNotified()); - - // Reset the listener - testComponentListener.reset(); - - } - - /** - *

- * This operation tests all of the IDataOperations and setSourceInfo(), - * addData(), and remove operations that deal with IDataProvider. - *

- * - */ - @Test - public void checkIDataProvider() { - // Local Declarations - LWRComponent component; - String name = "Bob"; - LWRData data1, data2, data3, data4, data5; - String data1Feature = "Data1"; - String data2Feature = "Data2"; - String defaultSource = "No Source Available"; - String newSource = "A source"; - double time1 = 1.1; - double time2 = 1.0; - double time3 = 1.3; - String timeUnit = "Minutes!"; - - // Create a component, set the number of time steps, and show the - // behaviors of setting the current time step - component = new LWRComponent(name); - - // Try to set the time step to 1 - component.setTime(1); - - // Show that it is equal to the set timestep - assertEquals(1.0, component.getCurrentTime(), 0.0); - - // Check invalid - negative - component.setTime(-1); - - // Defaults - assertEquals(1.0, component.getCurrentTime(), 0.0); - - // Check valid - 0 - component.setTime(0); - - // Equal to the set timeStep - assertEquals(0, component.getCurrentTime(), 0.0); - - // Get/set sourceInfo - component = new LWRComponent(name); - - // Check default - assertEquals(defaultSource, component.getSourceInfo()); - - // Try to set it to a new String - component.setSourceInfo(newSource); - // Check values - should be newSource - assertEquals(newSource, component.getSourceInfo()); - - // Try to set it to null - invalid - component.setSourceInfo(null); - // Check values - should be newSource - assertEquals(newSource, component.getSourceInfo()); // Defaults - - // Try to set it to empty string - invalid - component.setSourceInfo(""); - // Check values - should be newSource - assertEquals(newSource, component.getSourceInfo()); // Defaults - - // Show that the string is trimmed - component.setSourceInfo(newSource + " "); - // Check values - should be newSource - assertEquals(newSource, component.getSourceInfo()); // Trimmed - - // Setup timeUnits - component.setTimeUnits(timeUnit); - // Check values - assertEquals(timeUnit, component.getTimeUnits()); - - // Set timeUnits - nullary - component.setTimeUnits(null); - // Check values - nothing has changed - assertEquals(timeUnit, component.getTimeUnits()); - - // Set timeUnits - "empty string" - component.setTimeUnits(" "); - // Check values - nothing has changed <- auto trims strings - assertEquals(timeUnit, component.getTimeUnits()); - - // Check getters for IData - assertEquals(0, component.getFeatureList().size()); - assertEquals(0, component.getFeaturesAtCurrentTime().size()); - assertEquals(-1, component.getTimeStep(0.0)); - assertEquals(0, component.getDataAtCurrentTime(data1Feature).size()); - - // Add a IData - data1 = new LWRData(data1Feature); - component.addData(data1, time1); - - // Check getters - assertEquals(1, component.getFeatureList().size()); - assertEquals(data1Feature, component.getFeatureList().get(0)); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getDataAtCurrentTime(data1Feature).size()); - // Change current time - component.setTime(time1); - // Check values - assertEquals(1, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data1.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - // Check number of timesteps - assertEquals(1, component.getNumberOfTimeSteps()); - - // Add more data to current time with same feature - data2 = new LWRData(data1Feature); - data2.setUncertainty(33.333); - // Check getters - component.addData(data2, time1); - assertEquals(1, component.getFeatureList().size()); - assertEquals(data1Feature, component.getFeatureList().get(0)); - assertEquals(2, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data1.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - assertTrue(data2.equals(component.getDataAtCurrentTime(data1Feature) - .get(1))); - // Check number of timesteps - assertEquals(1, component.getNumberOfTimeSteps()); - // Check times - assertEquals(1, component.getTimes().size()); - assertEquals(time1, component.getTimes().get(0).doubleValue(), 0.0); - assertEquals(0, component.getTimeStep(time1)); - - // Add a LWRData to a different time location - data3 = new LWRData(data1Feature); - data3.setUncertainty(22.2); - component.addData(data3, time2); - // Check getters - assertEquals(1, component.getFeatureList().size()); - assertEquals(data1Feature, component.getFeatureList().get(0)); - assertEquals(2, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data1.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - assertTrue(data2.equals(component.getDataAtCurrentTime(data1Feature) - .get(1))); - // Change time frame - component.setTime(time2); - // Check information - assertEquals(1, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data3.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - // Check number of timesteps - assertEquals(2, component.getNumberOfTimeSteps()); - // Check times - assertEquals(2, component.getTimes().size()); - assertEquals(time2, component.getTimes().get(0).doubleValue(), 0.0); - assertEquals(time1, component.getTimes().get(1).doubleValue(), 0.0); - assertEquals(0, component.getTimeStep(time2)); - assertEquals(1, component.getTimeStep(time1)); - - // Add a LWRData with the same time as time2, but different feature - data4 = new LWRData(data2Feature); - data4.setUncertainty(11.1); - component.addData(data4, time2); - // Check getters - assertEquals(2, component.getFeatureList().size()); - assertTrue(component.getFeatureList().contains(data1Feature)); - assertTrue(component.getFeatureList().contains(data2Feature)); - assertEquals(1, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data3.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - assertEquals(1, component.getDataAtCurrentTime(data2Feature).size()); - assertTrue(data4.equals(component.getDataAtCurrentTime(data2Feature) - .get(0))); - // Check number of timesteps - assertEquals(2, component.getNumberOfTimeSteps()); - // Check times - assertEquals(2, component.getTimes().size()); - assertEquals(time2, component.getTimes().get(0).doubleValue(), 0.0); - assertEquals(time1, component.getTimes().get(1).doubleValue(), 0.0); - assertEquals(0, component.getTimeStep(time2)); - assertEquals(1, component.getTimeStep(time1)); - - // Check nullaries and invalid setters/parameters - assertEquals(-1, component.getTimeStep(time1 + 3333)); - assertEquals(-1, component.getTimeStep(-1.0)); - component.addData(null, time1); - component.addData(data4, -1.0); - assertEquals(0, component.getDataAtCurrentTime(null).size()); - assertEquals(0, component.getDataAtCurrentTime("FeatureDNE!@#12321321") - .size()); - - // Change to invalid time - component.setTime(time3 + 3333333); - assertEquals(time3 + 3333333, component.getCurrentTime(), 0.0); - component.setTime(-1.0); // Try negative - assertEquals(time3 + 3333333, component.getCurrentTime(), 0.0); // Does - // not - // change - assertEquals(0, component.getFeaturesAtCurrentTime().size()); - assertEquals(0, component.getDataAtCurrentTime(data1Feature).size()); - - // Check getters - change time back and show data is not changed - component.setTime(time2); - assertEquals(2, component.getFeatureList().size()); - assertTrue(component.getFeatureList().contains(data1Feature)); - assertTrue(component.getFeatureList().contains(data2Feature)); - assertEquals(1, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data3.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - assertEquals(1, component.getDataAtCurrentTime(data2Feature).size()); - assertTrue(data4.equals(component.getDataAtCurrentTime(data2Feature) - .get(0))); - // Check number of timesteps - assertEquals(2, component.getNumberOfTimeSteps()); - - } - - /** - *

- * This operation checks the copy and clone routines. - *

- * - */ - @Test - public void checkCopying() { - - // Local declarations - LWRComponent object; - LWRComponent copyObject = new LWRComponent(), clonedObject; - - // Values - String name = "A LWRComponent!@!@#!#@56483"; - String description = "Description !@#!@#!@#!46546484328"; - int id = 68468431; - int timeStep = 3; - String sourceInfo = "5465465SOURCEINFO!@#!#!#@!#@"; - - // Setup Object to test - object = new LWRComponent(name); - object.setTime(timeStep); - object.setId(id); - object.setDescription(description); - object.setSourceInfo(sourceInfo); - - // Run the copy routine - copyObject = new LWRComponent(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (LWRComponent) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - LWRComponent component = new LWRComponent(); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - String sourceInfo = "ASDASDASD"; - String timeUnits = "UNITS OF AWESOME"; - String testFileName = "testWrite.h5"; - double time = 1.0; - - // Setup LWRData - String feature1 = "Feature 1"; - String feature2 = "Feature 2"; - double time1 = 1.0, time2 = 3.0, time3 = 3.5; - LWRData data1, data2, data3, data4, data5; - ArrayList position1 = new ArrayList(), position2 = new ArrayList(), position3 = new ArrayList(), position4 = new ArrayList(), position5 = new ArrayList(); - - // Setup Positions - - // Setup Position 1 - position1.add(0.0); - position1.add(1.0); - position1.add(0.0); - - // Setup Position 2 - position2.add(0.0); - position2.add(1.0); - position2.add(4.0); - - // Setup Position 3 - position3.add(1.0); - position3.add(1.0); - position3.add(0.0); - - // Setup Position 4 - position4.add(0.0); - position4.add(1.0); - position4.add(1.0); - - // Setup Position 5 - position4.add(0.0); - position4.add(1.0); - position4.add(3.0); - - // Setup data1 - data1 = new LWRData(feature1); - data1.setPosition(position1); - data1.setValue(1.0); - data1.setUncertainty(1.5); - data1.setUnits("Units " + 1); - - // Setup data2 - data2 = new LWRData(feature1); - data2.setPosition(position2); - data2.setValue(2.0); - data2.setUncertainty(2.5); - data2.setUnits("Units " + 2); - - // Setup data3 - data3 = new LWRData(feature1); - data3.setPosition(position3); - data3.setValue(3.0); - data3.setUncertainty(3.5); - data3.setUnits("Units " + 3); - - // Setup data4 - data4 = new LWRData(feature1); - data4.setPosition(position4); - data4.setValue(4.0); - data4.setUncertainty(4.5); - data4.setUnits("Units " + 4); - - // Setup data5 - data5 = new LWRData(feature2); - data5.setPosition(position5); - data5.setValue(5.0); - data5.setUncertainty(5.5); - data5.setUnits("Units " + 5); - - // Add data to the component - component.addData(data1, time1); - component.addData(data2, time1); - component.addData(data3, time2); - component.addData(data4, time3); - component.addData(data5, time3); - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNull(component.getWriteableChildren()); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(component.writeAttributes(h5File, h5Group)); - - // Check dataSet. Pass null to show it return false - assertFalse(component.writeDatasets(null, null)); - assertFalse(component.writeDatasets(null, h5Group)); - assertFalse(component.writeDatasets(h5File, null)); - - // Check dataset - assertTrue(component.writeDatasets(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there is one group made at this time - assertEquals(1, h5Group.getMemberList().size()); - - // Check the name of the group - assertEquals("State Point Data", h5Group.getMemberList().get(0) - .getName()); - - // Check the meta data - assertEquals(4, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check the Group names and contents - assertEquals("State Point Data", h5Group.getMemberList().get(0) - .getName()); - - // Get the IDataGroup - H5Group dataGroup = (H5Group) h5Group.getMemberList().get(0); - - // Check the size of the data groups - assertEquals(3, dataGroup.getMemberList().size()); - - // Check the names of the groups. These should reflect the number of - // time steps - assertEquals("TimeStep: 0", dataGroup.getMemberList().get(0) - .getName()); - assertEquals("TimeStep: 1", dataGroup.getMemberList().get(1) - .getName()); - assertEquals("TimeStep: 2", dataGroup.getMemberList().get(2) - .getName()); - - // Get the TimeStep Groups and check contents - H5Group timeGroup1 = (H5Group) dataGroup.getMemberList().get(0); - H5Group timeGroup2 = (H5Group) dataGroup.getMemberList().get(1); - H5Group timeGroup3 = (H5Group) dataGroup.getMemberList().get(2); - - // Check that there is a group and attributes - assertEquals(1, timeGroup1.getMemberList().size()); - assertEquals(1, timeGroup2.getMemberList().size()); - assertEquals(2, timeGroup3.getMemberList().size()); - assertEquals(2, timeGroup1.getMetadata().size()); - assertEquals(2, timeGroup2.getMetadata().size()); - assertEquals(2, timeGroup3.getMetadata().size()); - - // Check Attributes on timeGroups - - // Check timeGroup1 - // Check time attribute - attribute = (Attribute) timeGroup1.getMetadata().get(0); - assertEquals(attribute.getName(), "time"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(time1, ((double[]) attribute.getValue())[0], 0.0); - // Check string attribute - attribute = (Attribute) timeGroup1.getMetadata().get(1); - assertEquals(attribute.getName(), "units"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - assertEquals(component.getTimeUnits(), - ((String[]) attribute.getValue())[0]); - - // Check timeGroup2 - // Check time attribute - attribute = (Attribute) timeGroup2.getMetadata().get(0); - assertEquals(attribute.getName(), "time"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(time2, ((double[]) attribute.getValue())[0], 0.0); - // Check string attribute - attribute = (Attribute) timeGroup1.getMetadata().get(1); - assertEquals(attribute.getName(), "units"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - assertEquals(component.getTimeUnits(), - ((String[]) attribute.getValue())[0]); - - // Check timeGroup3 - // Check time attribute - attribute = (Attribute) timeGroup3.getMetadata().get(0); - assertEquals(attribute.getName(), "time"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(time3, ((double[]) attribute.getValue())[0], 0.0); - // Check string attribute - attribute = (Attribute) timeGroup1.getMetadata().get(1); - assertEquals(attribute.getName(), "units"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - assertEquals(component.getTimeUnits(), - ((String[]) attribute.getValue())[0]); - - // Get the Features off the timeGroups - H5CompoundDS featureGroup1 = (H5CompoundDS) timeGroup1 - .getMemberList().get(0); - H5CompoundDS featureGroup2 = (H5CompoundDS) timeGroup2 - .getMemberList().get(0); - - // Feature Group 3 gets two SEPARATE compound datasets because of - // different features within the same time - H5CompoundDS featureGroup3a = (H5CompoundDS) timeGroup3 - .getMemberList().get(0); - H5CompoundDS featureGroup3b = (H5CompoundDS) timeGroup3 - .getMemberList().get(1); - - // Check information on featureGroups - assertEquals("Feature 1", featureGroup1.getName()); - assertEquals("Feature 1", featureGroup2.getName()); - assertEquals("Feature 1", featureGroup3a.getName()); - assertEquals("Feature 2", featureGroup3b.getName()); - - // Check contents of the feature groups - - // Check the names of the grid - // Number of members - Array Attributes stored on this object - featureGroup2.init(); - assertEquals(4, featureGroup2.getMemberCount()); - assertEquals("value", featureGroup2.getMemberNames()[0]); - assertEquals("uncertainty", featureGroup2.getMemberNames()[1]); - assertEquals("units", featureGroup2.getMemberNames()[2]); - assertEquals("position", featureGroup2.getMemberNames()[3]); - - // Check contents of featureGroup1 - featureGroup1.init(); - component.setTime(time1); - - // There are two sets of features here with the same feature name, - // so there is only 1 "height" - assertEquals(1, featureGroup1.getHeight()); - Object data = featureGroup1.getData(); - - // Convert the data to a readable format: Cast it as a Vector, then - // grab the pieces out of it - Vector objects = (Vector) data; - assertEquals(4, objects.size()); - - // Cast the objects to their subsets - // Create the arrays for each dataSet - double[] value = (double[]) objects.get(0); - double[] uncertainty = (double[]) objects.get(1); - String[] units = (String[]) objects.get(2); - double[] pos = (double[]) objects.get(3); - double[] position; - - // Show that there is a correct length on these pieces - assertEquals(2, value.length); - assertEquals(2, uncertainty.length); - assertEquals(2, units.length); - assertEquals(2 * 3, pos.length); - - // Check values - data1 - assertEquals(data1.getValue(), value[0], 0.0); - assertEquals(data1.getUncertainty(), uncertainty[0], 0.0); - assertEquals(data1.getUnits(), units[0]); - position = new double[3]; - position[0] = pos[0]; - position[1] = pos[1]; - position[2] = pos[2]; - assertEquals(data1.getPosition().toArray()[0], position[0]); - assertEquals(data1.getPosition().toArray()[1], position[1]); - assertEquals(data1.getPosition().toArray()[2], position[2]); - - // Check values - data2 - assertEquals(data2.getValue(), value[1], 0.0); - assertEquals(data2.getUncertainty(), uncertainty[1], 0.0); - assertEquals(data2.getUnits(), units[1]); - position = new double[3]; - position[0] = pos[3]; - position[1] = pos[4]; - position[2] = pos[5]; - assertEquals(data2.getPosition().toArray()[0], position[0]); - assertEquals(data2.getPosition().toArray()[1], position[1]); - assertEquals(data2.getPosition().toArray()[2], position[2]); - - // Check contents of featureGroup2 - featureGroup2.init(); - component.setTime(time1); - - assertEquals(1, featureGroup2.getHeight()); - data = featureGroup2.getData(); - - // Convert the data to a readable format: Cast it as a Vector, then - // grab the pieces out of it - objects = (Vector) data; - assertEquals(4, objects.size()); - - // Cast the objects to their subsets - // Create the arrays for each dataSet - value = (double[]) objects.get(0); - uncertainty = (double[]) objects.get(1); - units = (String[]) objects.get(2); - pos = (double[]) objects.get(3); - - // Show that there is a correct length on these pieces - assertEquals(1, value.length); - assertEquals(1, uncertainty.length); - assertEquals(1, units.length); - assertEquals(1 * 3, pos.length); - - // Check values - data3 - assertEquals(data3.getValue(), value[0], 0.0); - assertEquals(data3.getUncertainty(), uncertainty[0], 0.0); - assertEquals(data3.getUnits(), units[0]); - position = new double[3]; - position[0] = pos[0]; - position[1] = pos[1]; - position[2] = pos[2]; - assertEquals(data3.getPosition().toArray()[0], position[0]); - assertEquals(data3.getPosition().toArray()[1], position[1]); - assertEquals(data3.getPosition().toArray()[2], position[2]); - - // Check over contents of featureGroup3a - featureGroup3a.init(); - component.setTime(time1); - - assertEquals(1, featureGroup3a.getHeight()); - data = featureGroup3a.getData(); - - // Convert the data to a readable format: Cast it as a Vector, then - // grab the pieces out of it - objects = (Vector) data; - assertEquals(4, objects.size()); - - // Cast the objects to their subsets - // Create the arrays for each dataSet - value = (double[]) objects.get(0); - uncertainty = (double[]) objects.get(1); - units = (String[]) objects.get(2); - pos = (double[]) objects.get(3); - - // Show that there is a correct length on these pieces - assertEquals(1, value.length); - assertEquals(1, uncertainty.length); - assertEquals(1, units.length); - assertEquals(1 * 3, pos.length); - - // Check values - data4 - assertEquals(data4.getValue(), value[0], 0.0); - assertEquals(data4.getUncertainty(), uncertainty[0], 0.0); - assertEquals(data4.getUnits(), units[0]); - position = new double[3]; - position[0] = pos[0]; - position[1] = pos[1]; - position[2] = pos[2]; - assertEquals(data4.getPosition().toArray()[0], position[0]); - assertEquals(data4.getPosition().toArray()[1], position[1]); - assertEquals(data4.getPosition().toArray()[2], position[2]); - - // Check over contents of featureGroup3b - featureGroup3b.init(); - component.setTime(time1); - - assertEquals(1, featureGroup3b.getHeight()); - data = featureGroup3b.getData(); - - // Convert the data to a readable format: Cast it as a Vector, then - // grab the pieces out of it - objects = (Vector) data; - assertEquals(4, objects.size()); - - // Cast the objects to their subsets - // Create the arrays for each dataSet - value = (double[]) objects.get(0); - uncertainty = (double[]) objects.get(1); - units = (String[]) objects.get(2); - pos = (double[]) objects.get(3); - - // Show that there is a correct length on these pieces - assertEquals(1, value.length); - assertEquals(1, uncertainty.length); - assertEquals(1, units.length); - assertEquals(1 * 3, pos.length); - - // Check values - data5 - assertEquals(data5.getValue(), value[0], 0.0); - assertEquals(data5.getUncertainty(), uncertainty[0], 0.0); - assertEquals(data5.getUnits(), units[0]); - position = new double[3]; - position[0] = pos[0]; - position[1] = pos[1]; - position[2] = pos[2]; - assertEquals(data4.getPosition().toArray()[0], position[0]); - assertEquals(data4.getPosition().toArray()[1], position[1]); - assertEquals(data4.getPosition().toArray()[2], position[2]); - - } catch (Exception e) { - e.printStackTrace(); - fail(); - - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(component.writeAttributes(null, h5Group)); - assertFalse(component.writeAttributes(h5File, null)); - - // Check Group Creation - H5Group group = component.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(2, h5Group.getMemberList().size()); - // Check that it has the same name as the root component - assertEquals(component.getName(), h5Group.getMemberList().get(1) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(1)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - LWRComponent component = new LWRComponent(); - LWRComponent newComponent = new LWRComponent("NOT A DEFAULT ONE"); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - String sourceInfo = "ASDASDASD"; - String timeUnits = "UNITS OF AWESOME"; - double time = 1.0; - - // Setup LWRData - String feature1 = "Feature 1"; - String feature2 = "Feature 2"; - double time1 = 1.0, time2 = 3.0, time3 = 3.5; - LWRData data1, data2, data3, data4, data5; - ArrayList position1 = new ArrayList(), position2 = new ArrayList(), position3 = new ArrayList(), position4 = new ArrayList(), position5 = new ArrayList(); - - // Setup Positions - - // Setup Position 1 - position1.add(0.0); - position1.add(1.0); - position1.add(0.0); - - // Setup Position 2 - position2.add(0.0); - position2.add(1.0); - position2.add(4.0); - - // Setup Position 3 - position3.add(1.0); - position3.add(1.0); - position3.add(0.0); - - // Setup Position 4 - position4.add(0.0); - position4.add(1.0); - position4.add(1.0); - - // Setup Position 5 - position4.add(0.0); - position4.add(1.0); - position4.add(3.0); - - // Setup data1 - data1 = new LWRData(feature1); - data1.setPosition(position1); - data1.setValue(1.0); - data1.setUncertainty(1.5); - data1.setUnits("Units " + 1); - - // Setup data2 - data2 = new LWRData(feature1); - data2.setPosition(position2); - data2.setValue(2.0); - data2.setUncertainty(2.5); - data2.setUnits("Units " + 2); - - // Setup data3 - data3 = new LWRData(feature1); - data3.setPosition(position3); - data3.setValue(3.0); - data3.setUncertainty(3.5); - data3.setUnits("Units " + 3); - - // Setup data4 - data4 = new LWRData(feature1); - data4.setPosition(position4); - data4.setValue(4.0); - data4.setUncertainty(4.5); - data4.setUnits("Units " + 4); - - // Setup data5 - data5 = new LWRData(feature2); - data5.setPosition(position5); - data5.setValue(5.0); - data5.setUncertainty(5.5); - data5.setUnits("Units " + 5); - - // Add data to the component - component.addData(data1, time1); - component.addData(data2, time1); - component.addData(data3, time2); - component.addData(data4, time3); - component.addData(data5, time3); - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - - // Do readChild checks here. For LWRComponent this method always returns - // true - assertTrue(component.readChild(null)); - assertTrue(component.readChild(newComponent)); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup LWRComponent with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // We will cheat a bit with this method, because otherwise its all - // copy paste - assertTrue(component.writeDatasets(h5File, subGroup)); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - assertTrue(newComponent.readDatasets(subGroup)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5 file! - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRComponentWriterTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRComponentWriterTester.java deleted file mode 100644 index 0662c8eae..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRComponentWriterTester.java +++ /dev/null @@ -1,919 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.TreeSet; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.reactor.AssemblyType; -import org.eclipse.ice.reactor.LWRComponentWriter; -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRRod; -import org.eclipse.ice.reactor.Material; -import org.eclipse.ice.reactor.MaterialBlock; -import org.eclipse.ice.reactor.MaterialType; -import org.eclipse.ice.reactor.Ring; -import org.eclipse.ice.reactor.Tube; -import org.eclipse.ice.reactor.TubeType; -import org.eclipse.ice.reactor.pwr.ControlBank; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.IncoreInstrument; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.eclipse.ice.reactor.pwr.RodClusterAssembly; -import org.junit.BeforeClass; -import org.junit.Test; - -import ncsa.hdf.object.FileFormat; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; - -/** - * - * @author Eric J. Lingerfelt - */ -public class LWRComponentWriterTester { - - /** - * - */ - @BeforeClass - public static void beforeClass() { - - } - - /** - * - */ - @Test - public void checkWriting() { - - // Create a reactor of size 2 X 2 - PressurizedWaterReactor pwReactor = new PressurizedWaterReactor(15); - pwReactor.setName("PWR Reactor"); - pwReactor.setFuelAssemblyPitch(0.12345678912345); - - // PWREACTOR GRID - // LABELS///////////////////////////////////////////////// - // Create a list of row labels - ArrayList rowLabelsReactor = new ArrayList(); - rowLabelsReactor.add("1"); - rowLabelsReactor.add("2"); - rowLabelsReactor.add("3"); - rowLabelsReactor.add("4"); - rowLabelsReactor.add("5"); - rowLabelsReactor.add("6"); - rowLabelsReactor.add("7"); - rowLabelsReactor.add("8"); - rowLabelsReactor.add("9"); - rowLabelsReactor.add("10"); - rowLabelsReactor.add("11"); - rowLabelsReactor.add("12"); - rowLabelsReactor.add("13"); - rowLabelsReactor.add("14"); - rowLabelsReactor.add("15"); - - // Create a list of column labels - ArrayList columnLabelsReactor = new ArrayList(); - columnLabelsReactor.add("R"); - columnLabelsReactor.add("P"); - columnLabelsReactor.add("N"); - columnLabelsReactor.add("M"); - columnLabelsReactor.add("L"); - columnLabelsReactor.add("K"); - columnLabelsReactor.add("J"); - columnLabelsReactor.add("H"); - columnLabelsReactor.add("G"); - columnLabelsReactor.add("F"); - columnLabelsReactor.add("E"); - columnLabelsReactor.add("D"); - columnLabelsReactor.add("C"); - columnLabelsReactor.add("B"); - columnLabelsReactor.add("A"); - - // Assign the label arrays - pwReactor.getGridLabelProvider().setRowLabels(rowLabelsReactor); - pwReactor.getGridLabelProvider().setColumnLabels(columnLabelsReactor); - - // CONTROL - // BANKS////////////////////////////////////////////////////////// - // Add two control banks to the reactor - pwReactor.addAssembly(AssemblyType.ControlBank, - new ControlBank("A", 0.625, 230)); - pwReactor.addAssembly(AssemblyType.ControlBank, - new ControlBank("B", 0.625, 215)); - pwReactor.addAssembly(AssemblyType.ControlBank, - new ControlBank("C", 0.625, 200)); - pwReactor.addAssembly(AssemblyType.ControlBank, - new ControlBank("D", 0.625, 185)); - - // Assign a position for the control banks - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 4, 4); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 4, 10); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 5, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 7, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 7, 9); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 9, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 10, 4); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "A", 10, 10); - - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 1, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 1, 9); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 5, 1); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 5, 13); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 9, 1); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 9, 13); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 13, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "B", 13, 9); - - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 1, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 5, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 5, 9); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 7, 1); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 7, 13); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 9, 5); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 9, 9); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "C", 13, 7); - - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 3, 3); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 3, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 3, 11); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 7, 3); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 7, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 7, 11); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 11, 3); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 11, 7); - pwReactor.setAssemblyLocation(AssemblyType.ControlBank, "D", 11, 11); - - // INCORE - // INSTRUMENTS///////////////////////////////////////////////////// - // Create incore instruments for the reactor - IncoreInstrument incoreInstrument1 = new IncoreInstrument(); - incoreInstrument1.setName("Incore Instrument 1"); - IncoreInstrument incoreInstrument2 = new IncoreInstrument(); - incoreInstrument2.setName("Incore Instrument 2"); - IncoreInstrument incoreInstrument3 = new IncoreInstrument(); - incoreInstrument3.setName("Incore Instrument 3"); - IncoreInstrument incoreInstrument4 = new IncoreInstrument(); - incoreInstrument4.setName("Incore Instrument 4"); - - // Create the thimble material - Material material = new Material("stainless steel"); - material.setMaterialType(MaterialType.SOLID); - - // Create the thimble - Ring thimble = new Ring("Thimble", material, 155, 0.258, 0.382); - incoreInstrument1.setThimble(thimble); - incoreInstrument2.setThimble((Ring) thimble.clone()); - incoreInstrument3.setThimble((Ring) thimble.clone()); - incoreInstrument4.setThimble((Ring) thimble.clone()); - - // Add the incore instruments - pwReactor.addAssembly(AssemblyType.IncoreInstrument, incoreInstrument1); - pwReactor.addAssembly(AssemblyType.IncoreInstrument, incoreInstrument2); - pwReactor.addAssembly(AssemblyType.IncoreInstrument, incoreInstrument3); - pwReactor.addAssembly(AssemblyType.IncoreInstrument, incoreInstrument4); - - // Assign locations for the incore instruments - pwReactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - incoreInstrument1.getName(), 2, 1); - pwReactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - incoreInstrument2.getName(), 6, 5); - pwReactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - incoreInstrument3.getName(), 11, 2); - pwReactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - incoreInstrument4.getName(), 13, 8); - - // FUEL - // ASSEMBLIES//////////////////////////////////////////////////////// - // Create a fuel assembly - FuelAssembly fuelAssembly = new FuelAssembly("Fuel Assembly A", 17); - - // Create a list of row labels - ArrayList rowLabelsFuelAssembly = new ArrayList(); - rowLabelsFuelAssembly.add("1"); - rowLabelsFuelAssembly.add("2"); - rowLabelsFuelAssembly.add("3"); - rowLabelsFuelAssembly.add("4"); - rowLabelsFuelAssembly.add("5"); - rowLabelsFuelAssembly.add("6"); - rowLabelsFuelAssembly.add("7"); - rowLabelsFuelAssembly.add("8"); - rowLabelsFuelAssembly.add("9"); - rowLabelsFuelAssembly.add("10"); - rowLabelsFuelAssembly.add("11"); - rowLabelsFuelAssembly.add("12"); - rowLabelsFuelAssembly.add("13"); - rowLabelsFuelAssembly.add("14"); - rowLabelsFuelAssembly.add("15"); - rowLabelsFuelAssembly.add("16"); - rowLabelsFuelAssembly.add("17"); - - // Create list of column labels - ArrayList columnLabelsFuelAssembly = new ArrayList(); - columnLabelsFuelAssembly.add("A"); - columnLabelsFuelAssembly.add("B"); - columnLabelsFuelAssembly.add("C"); - columnLabelsFuelAssembly.add("D"); - columnLabelsFuelAssembly.add("E"); - columnLabelsFuelAssembly.add("F"); - columnLabelsFuelAssembly.add("G"); - columnLabelsFuelAssembly.add("H"); - columnLabelsFuelAssembly.add("I"); - columnLabelsFuelAssembly.add("J"); - columnLabelsFuelAssembly.add("K"); - columnLabelsFuelAssembly.add("L"); - columnLabelsFuelAssembly.add("M"); - columnLabelsFuelAssembly.add("N"); - columnLabelsFuelAssembly.add("O"); - columnLabelsFuelAssembly.add("P"); - columnLabelsFuelAssembly.add("Q"); - - // Assign the labels array - fuelAssembly.getGridLabelProvider().setRowLabels(rowLabelsFuelAssembly); - fuelAssembly.getGridLabelProvider() - .setColumnLabels(columnLabelsFuelAssembly); - - // Create a guide tube - Tube guideTube = new Tube("Guide Tube A", TubeType.GUIDE); - guideTube.setHeight(1.56); - guideTube.setInnerRadius(7.89); - guideTube.setOuterRadius(10.0); - - // Create material for the guide tube - Material materialGuideTube = new Material("Guide Tube Material"); - - // Set the material for the guide tube - guideTube.setMaterial(materialGuideTube); - - // Add the guide tube to the fuel assembly - fuelAssembly.addTube(guideTube); - - // Assign the guide tube a location - fuelAssembly.setTubeLocation(guideTube.getName(), 8, 13); - - // Create an instrument tube - Tube instrumentTube = new Tube("Instrument Tube A", - TubeType.INSTRUMENT); - instrumentTube.setHeight(1.2); - instrumentTube.setInnerRadius(0.987); - instrumentTube.setOuterRadius(34.5); - - // Create material for the instrument tube - Material materialInstrumentTube = new Material( - "Instrument Tube Material"); - - // Set the material for the instrument tube - instrumentTube.setMaterial(materialInstrumentTube); - - // Add the instrument tube to the fuel assembly - fuelAssembly.addTube(instrumentTube); - - // Assign the instrument tube a location - fuelAssembly.setTubeLocation(instrumentTube.getName(), 8, 8); - - // Create an lwrrod for this fuel assembly - LWRRod rod = new LWRRod("LWRRod A"); - rod.setPressure(23.56); - - // Create a fill gas for the rod - Material fillGas = new Material("He", MaterialType.GAS); - rod.setFillGas(fillGas); - - // Create a materialBlock for the rod - MaterialBlock materialBlock = new MaterialBlock(); - materialBlock.setName("Stack of Cards"); - - // Create some rings for the materialBlock - Ring ring1 = new Ring("Ring 1"); - ring1.setHeight(155); - ring1.setOuterRadius(0.5); - - // Create a material for ring1 - Material ring1Material = new Material("Ring 1 Material", - MaterialType.SOLID); - ring1.setMaterial(ring1Material); - - // Create some rings for the materialBlock - Ring ring2 = new Ring("Ring 2"); - ring2.setHeight(155); - ring2.setInnerRadius(0.5); - ring2.setOuterRadius(1.0); - - // Create a material for ring1 - Material ring2Material = new Material("Ring 2 Material", - MaterialType.SOLID); - ring2.setMaterial(ring2Material); - - // Add rings to the materialBlock - materialBlock.addRing(ring1); - materialBlock.addRing(ring2); - - TreeSet materialBlockList = new TreeSet(); - materialBlockList.add(materialBlock); - - // Set the MaterialBlock in the rod - rod.setMaterialBlocks(materialBlockList); - - // Create a clad - Ring clad = new Ring("Clad"); - clad.setHeight(155); - clad.setInnerRadius(0.9); - clad.setOuterRadius(1.0); - - // Create a material for the clad - Material materialClad = new Material("Clad Material", - MaterialType.SOLID); - clad.setMaterial(materialClad); - - // Add the clad - rod.setClad(clad); - - // Add the rod to the fuel assembly - fuelAssembly.addLWRRod(rod); - - // Assign the rod a location - fuelAssembly.setLWRRodLocation(rod.getName(), 15, 4); - - // Add the fuel assembly to the reactor - pwReactor.addAssembly(AssemblyType.Fuel, fuelAssembly); - - // Assign a position on the grid of the reactor - pwReactor.setAssemblyLocation(AssemblyType.Fuel, fuelAssembly.getName(), - 4, 4); - - // ROD CLUSTER - // ASSEMBLIES///////////////////////////////////////////////// - // Create a rca - RodClusterAssembly rodClusterAssembly = new RodClusterAssembly( - "Rod Cluster Assembly A", 17); - - // Add the rca to the reactor - pwReactor.addAssembly(AssemblyType.RodCluster, rodClusterAssembly); - - // Assign the rca location - pwReactor.setAssemblyLocation(AssemblyType.RodCluster, - rodClusterAssembly.getName(), 5, 2); - - // Add LWRData - // Setup LWRData - String feature1 = "Feature 1"; - String feature2 = "Feature 2"; - double time1 = 1.0, time2 = 3.0, time3 = 3.5; - LWRData data1, data2, data3, data4, data5; - ArrayList position1 = new ArrayList(), - position2 = new ArrayList(), - position3 = new ArrayList(), - position4 = new ArrayList(), - position5 = new ArrayList(); - - // Setup Positions - - // Setup Position 1 - position1.add(0.0); - position1.add(1.0); - position1.add(0.0); - - // Setup Position 2 - position2.add(0.0); - position2.add(1.0); - position2.add(4.0); - - // Setup Position 3 - position3.add(1.0); - position3.add(1.0); - position3.add(0.0); - - // Setup Position 4 - position4.add(0.0); - position4.add(1.0); - position4.add(1.0); - - // Setup Position 5 - position4.add(0.0); - position4.add(1.0); - position4.add(3.0); - - // Setup data1 - data1 = new LWRData(feature1); - data1.setPosition(position1); - data1.setValue(1.0); - data1.setUncertainty(1.5); - data1.setUnits("Units " + 123456); - - // Setup data2 - data2 = new LWRData(feature1); - data2.setPosition(position2); - data2.setValue(2.0); - data2.setUncertainty(2.5); - data2.setUnits("Units " + 2); - - // Setup data3 - data3 = new LWRData(feature1); - data3.setPosition(position3); - data3.setValue(3.0); - data3.setUncertainty(3.5); - data3.setUnits("Units " + 3); - - // Setup data4 - data4 = new LWRData(feature1); - data4.setPosition(position4); - data4.setValue(4.0); - data4.setUncertainty(4.5); - data4.setUnits("Units " + 4); - - // Setup data5 - data5 = new LWRData(feature2); - data5.setPosition(position5); - data5.setValue(5.0); - data5.setUncertainty(5.5); - data5.setUnits("Units " + 5); - - pwReactor.addData(data1, time1); - pwReactor.addData(data2, time1); - pwReactor.addData(data3, time2); - pwReactor.addData(data4, time3); - pwReactor.addData(data5, time3); - - // Try it with a non-null argument - // Local declarations - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + "reactorData"; - File dataFile = new File(userDir + separator + "writer_test.h5"); - URI uri = dataFile.toURI(); - - LWRComponentWriter lWRComponentWriter = new LWRComponentWriter(); - assertNotNull(lWRComponentWriter); - - // write the reactor - boolean flag = lWRComponentWriter.write(pwReactor, uri); - assertTrue(flag); - - // Make sure the file exists now - assertTrue(dataFile.exists()); - - // Retrieve an instance of the HDF5 format - FileFormat fileFormat = FileFormat - .getFileFormat(FileFormat.FILE_TYPE_HDF5); - - // Open the file with read/write access and return it. - H5File newH5File = null; - try { - // Open the file in READ ONLY mode - newH5File = (H5File) fileFormat.createInstance( - dataFile.getAbsolutePath(), FileFormat.READ); - newH5File = HdfFileFactory.openH5File(dataFile.toURI()); - // Make sure it exists - assertTrue(newH5File.exists()); - assertTrue(newH5File.canRead()); - // Then open it - newH5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - } - - assertNotNull(newH5File); - // Now, we will open up the file and reverse examine to see if every - // group is in there - - // Get the root group - Group root = (Group) ((javax.swing.tree.DefaultMutableTreeNode) newH5File - .getRootNode()).getUserObject(); - - // Now check each group node - // Check for Root PWReactor - assertEquals("PWR Reactor", root.getMemberList().get(0).getName()); - - // Check PWRReactor's subpieces - Group pWReactor = (Group) root.getMemberList().get(0); - assertEquals(10, pWReactor.getMemberList().size()); - assertEquals("Control Bank Grid", - pWReactor.getMemberList().get(0).getName()); - assertEquals("Control Banks", - pWReactor.getMemberList().get(1).getName()); - assertEquals("Fuel Assemblies", - pWReactor.getMemberList().get(2).getName()); - assertEquals("Fuel Assembly Grid", - pWReactor.getMemberList().get(3).getName()); - assertEquals("Grid Labels", pWReactor.getMemberList().get(4).getName()); - assertEquals("Incore Instrument Grid", - pWReactor.getMemberList().get(5).getName()); - assertEquals("Incore Instruments", - pWReactor.getMemberList().get(6).getName()); - assertEquals("Rod Cluster Assemblies", - pWReactor.getMemberList().get(7).getName()); - assertEquals("Rod Cluster Assembly Grid", - pWReactor.getMemberList().get(8).getName()); - assertEquals("State Point Data", - pWReactor.getMemberList().get(9).getName()); - - // Check the Control Bank Grid - Group controlBankGrid = (Group) pWReactor.getMemberList().get(0); - assertEquals(2, controlBankGrid.getMemberList().size()); - // Check Control Bank Grid Information - assertEquals("Positions", - controlBankGrid.getMemberList().get(0).getName()); - assertEquals("State Point Data", - controlBankGrid.getMemberList().get(1).getName()); - // information below - assertTrue(controlBankGrid.getMemberList().get(0) instanceof Group); - - // Check Control Banks - Group controlBank = (Group) pWReactor.getMemberList().get(1); - assertEquals(5, controlBank.getMemberList().size()); - // Check Control Bank Information - assertEquals("A", controlBank.getMemberList().get(0).getName()); - assertEquals("B", controlBank.getMemberList().get(1).getName()); - assertEquals("C", controlBank.getMemberList().get(2).getName()); - assertEquals("D", controlBank.getMemberList().get(3).getName()); - assertEquals("State Point Data", - controlBank.getMemberList().get(4).getName()); - // Check Groups - Group A = (Group) controlBank.getMemberList().get(0); - Group B = (Group) controlBank.getMemberList().get(1); - Group C = (Group) controlBank.getMemberList().get(2); - Group D = (Group) controlBank.getMemberList().get(3); - // Check contents of Groups - assertEquals(1, A.getMemberList().size()); - assertEquals("State Point Data", A.getMemberList().get(0).getName()); - assertEquals(1, B.getMemberList().size()); - assertEquals("State Point Data", B.getMemberList().get(0).getName()); - assertEquals(1, C.getMemberList().size()); - assertEquals("State Point Data", C.getMemberList().get(0).getName()); - assertEquals(1, D.getMemberList().size()); - assertEquals("State Point Data", D.getMemberList().get(0).getName()); - - // Check Fuel Assemblies - Group fuelAssemblies = (Group) pWReactor.getMemberList().get(2); - assertEquals(2, fuelAssemblies.getMemberList().size()); - // Check Fuel Assemblies Information - assertEquals("Fuel Assembly A", - fuelAssemblies.getMemberList().get(0).getName()); - assertEquals("State Point Data", - fuelAssemblies.getMemberList().get(1).getName()); - // Check Groups - Group fuelAssemblyA = (Group) fuelAssemblies.getMemberList().get(0); - // Check contents of FuelAssemblyA - assertEquals(6, fuelAssemblyA.getMemberList().size()); - assertEquals("Grid Labels", - fuelAssemblyA.getMemberList().get(0).getName()); - assertEquals("LWRRod Grid", - fuelAssemblyA.getMemberList().get(1).getName()); - assertEquals("LWRRods", fuelAssemblyA.getMemberList().get(2).getName()); - assertEquals("State Point Data", - fuelAssemblyA.getMemberList().get(3).getName()); - assertEquals("Tube Grid", - fuelAssemblyA.getMemberList().get(4).getName()); - assertEquals("Tubes", fuelAssemblyA.getMemberList().get(5).getName()); - - // Check Groups of FuelAssembly A - Group gridLabels = (Group) fuelAssemblyA.getMemberList().get(0); - Group lWRRodGrid = (Group) fuelAssemblyA.getMemberList().get(1); - Group lWRRods = (Group) fuelAssemblyA.getMemberList().get(2); - // 3rd one here is state point data - Group tubeGrid = (Group) fuelAssemblyA.getMemberList().get(4); - Group tubes = (Group) fuelAssemblyA.getMemberList().get(5); - // Check Groups - assertEquals(2, gridLabels.getMemberList().size()); - assertEquals(2, lWRRodGrid.getMemberList().size()); - assertEquals(2, lWRRods.getMemberList().size()); - assertEquals(2, tubeGrid.getMemberList().size()); - assertEquals(3, tubes.getMemberList().size()); - // Check gridLabels - Group labelsGroup = (Group) gridLabels.getMemberList().get(0); - - assertEquals("Column Labels", - labelsGroup.getMemberList().get(0).getName()); - assertEquals("Row Labels", - labelsGroup.getMemberList().get(1).getName()); - // Check Groups of GridLabels - assertFalse(labelsGroup.getMemberList().get(0) instanceof Group); - assertFalse(labelsGroup.getMemberList().get(1) instanceof Group); - // Check lWRRodGrid - assertEquals("Positions", lWRRodGrid.getMemberList().get(0).getName()); - assertEquals("State Point Data", - lWRRodGrid.getMemberList().get(1).getName()); - assertTrue(lWRRodGrid.getMemberList().get(0) instanceof Group); - // Check LWRRods - assertEquals("LWRRod A", lWRRods.getMemberList().get(0).getName()); - Group lWRRodsA = (Group) lWRRods.getMemberList().get(0); - assertEquals("State Point Data", - lWRRods.getMemberList().get(1).getName()); - // Check lWRRodsA - assertEquals(4, lWRRodsA.getMemberList().size()); - assertEquals("Clad", lWRRodsA.getMemberList().get(0).getName()); - assertEquals("He", lWRRodsA.getMemberList().get(1).getName()); - assertEquals("Stack of Cards", - lWRRodsA.getMemberList().get(2).getName()); - assertEquals("State Point Data", - lWRRodsA.getMemberList().get(3).getName()); - // Check Groups of lWRRodsA - Group cladRodA = (Group) lWRRodsA.getMemberList().get(0); - Group heRodA = (Group) lWRRodsA.getMemberList().get(1); - Group materialBlockRodA = (Group) lWRRodsA.getMemberList().get(2); - // Check cladRodA - assertEquals(2, cladRodA.getMemberList().size()); - assertEquals("Clad Material", - cladRodA.getMemberList().get(0).getName()); - assertEquals("State Point Data", - cladRodA.getMemberList().get(1).getName()); - // Check Groups - Group materialCladRodA = (Group) cladRodA.getMemberList().get(0); - // Check materialCladRodA - assertEquals(1, materialCladRodA.getMemberList().size()); - assertEquals("State Point Data", - materialCladRodA.getMemberList().get(0).getName()); - // Check heRodA - assertEquals(1, heRodA.getMemberList().size()); - assertEquals("State Point Data", - heRodA.getMemberList().get(0).getName()); - // Check materialBlockRodA - assertEquals(3, materialBlockRodA.getMemberList().size()); - assertEquals("Ring 1", - materialBlockRodA.getMemberList().get(0).getName()); - assertEquals("Ring 2", - materialBlockRodA.getMemberList().get(1).getName()); - assertEquals("State Point Data", - materialBlockRodA.getMemberList().get(2).getName()); - // Check Groups - Group ring1StackA = (Group) materialBlockRodA.getMemberList().get(0); - Group ring2StackA = (Group) materialBlockRodA.getMemberList().get(1); - // Check ring1StackA - assertEquals(2, ring1StackA.getMemberList().size()); - assertEquals("Ring 1 Material", - ring1StackA.getMemberList().get(0).getName()); - assertEquals("State Point Data", - ring1StackA.getMemberList().get(1).getName()); - Group material1Ring = (Group) ring1StackA.getMemberList().get(0); - // Check material1Ring - assertEquals(1, material1Ring.getMemberList().size()); - assertEquals("State Point Data", - material1Ring.getMemberList().get(0).getName()); - // Check ring2StackA - assertEquals(2, ring2StackA.getMemberList().size()); - assertEquals("Ring 2 Material", - ring2StackA.getMemberList().get(0).getName()); - assertEquals("State Point Data", - ring2StackA.getMemberList().get(1).getName()); - Group material2Ring = (Group) ring2StackA.getMemberList().get(0); - // Check material1Ring - assertEquals(1, material2Ring.getMemberList().size()); - assertEquals("State Point Data", - material2Ring.getMemberList().get(0).getName()); - // Check tubeGrid - assertEquals("State Point Data", - tubeGrid.getMemberList().get(1).getName()); - assertEquals("Positions", tubeGrid.getMemberList().get(0).getName()); - assertTrue(tubeGrid.getMemberList().get(0) instanceof Group); - // Check tubes - assertEquals("Guide Tube A", tubes.getMemberList().get(0).getName()); - assertEquals("Instrument Tube A", - tubes.getMemberList().get(1).getName()); - assertEquals("State Point Data", - tubes.getMemberList().get(2).getName()); - // Check Groups - Group guideTubeA = (Group) tubes.getMemberList().get(0); - Group instrTubeA = (Group) tubes.getMemberList().get(1); - // Check guideTubeA - assertEquals(2, guideTubeA.getMemberList().size()); - assertEquals("Guide Tube Material", - guideTubeA.getMemberList().get(0).getName()); - assertEquals("State Point Data", - guideTubeA.getMemberList().get(1).getName()); - Group guideTubeMaterial = (Group) guideTubeA.getMemberList().get(0); - // Check guideTubeMaterial - assertEquals(1, guideTubeMaterial.getMemberList().size()); - assertEquals("State Point Data", - guideTubeMaterial.getMemberList().get(0).getName()); - // Check instrTubeA - assertEquals(2, instrTubeA.getMemberList().size()); - assertEquals("Instrument Tube Material", - instrTubeA.getMemberList().get(0).getName()); - assertEquals("State Point Data", - instrTubeA.getMemberList().get(1).getName()); - Group instrTubeMaterial = (Group) instrTubeA.getMemberList().get(0); - // Check guideTubeMaterial - assertEquals(1, instrTubeMaterial.getMemberList().size()); - assertEquals("State Point Data", - instrTubeMaterial.getMemberList().get(0).getName()); - - // Fuel Assembly Grid - Group fuelAssemblyGrid = (Group) pWReactor.getMemberList().get(3); - assertEquals(2, fuelAssemblyGrid.getMemberList().size()); - // Check FuelAssembly Grid Information - assertEquals("Positions", - fuelAssemblyGrid.getMemberList().get(0).getName()); - // information below - assertTrue(fuelAssemblyGrid.getMemberList().get(0) instanceof Group); - - // Grid Labels - Group reactorGridLabels = (Group) pWReactor.getMemberList().get(4); - assertEquals(2, reactorGridLabels.getMemberList().size()); - assertEquals("State Point Data", - reactorGridLabels.getMemberList().get(1).getName()); - - // Check gridLabels - labelsGroup = (Group) reactorGridLabels.getMemberList().get(0); - - assertEquals("Column Labels", - labelsGroup.getMemberList().get(0).getName()); - assertEquals("Row Labels", - labelsGroup.getMemberList().get(1).getName()); - // Check Groups of GridLabels - assertFalse(labelsGroup.getMemberList().get(0) instanceof Group); - assertFalse(labelsGroup.getMemberList().get(1) instanceof Group); - - // Check Incore Instrument Grid - Group incoreInstrumentGrid = (Group) pWReactor.getMemberList().get(5); - // Check icoreInstrumentGrid - assertEquals(2, incoreInstrumentGrid.getMemberList().size()); - assertEquals("State Point Data", - incoreInstrumentGrid.getMemberList().get(1).getName()); - // Check incoreInstruments infor - assertEquals("Positions", - incoreInstrumentGrid.getMemberList().get(0).getName()); - // Check Groups - assertTrue( - incoreInstrumentGrid.getMemberList().get(0) instanceof Group); - - // Check Incore Instrument - Group incoreInstrument = (Group) pWReactor.getMemberList().get(6); - assertEquals(5, incoreInstrument.getMemberList().size()); - // Check incore instrument information - assertEquals("Incore Instrument 1", - incoreInstrument.getMemberList().get(0).getName()); - assertEquals("Incore Instrument 2", - incoreInstrument.getMemberList().get(1).getName()); - assertEquals("Incore Instrument 3", - incoreInstrument.getMemberList().get(2).getName()); - assertEquals("Incore Instrument 4", - incoreInstrument.getMemberList().get(3).getName()); - assertEquals("State Point Data", - incoreInstrument.getMemberList().get(4).getName()); - // Check Groups - Group incore1 = (Group) incoreInstrument.getMemberList().get(0); - Group incore2 = (Group) incoreInstrument.getMemberList().get(1); - Group incore3 = (Group) incoreInstrument.getMemberList().get(2); - Group incore4 = (Group) incoreInstrument.getMemberList().get(3); - // Check incore1 - assertEquals(2, incore1.getMemberList().size()); - // Check incore1 information - assertEquals("Thimble", incore1.getMemberList().get(1).getName()); - assertEquals("State Point Data", - incore1.getMemberList().get(0).getName()); - // Check Groups - Group thimble1 = (Group) incore1.getMemberList().get(1); - // Check thimble - assertEquals(2, thimble1.getMemberList().size()); - // Check thimble information - assertEquals("stainless steel", - thimble1.getMemberList().get(1).getName()); - assertEquals("State Point Data", - thimble1.getMemberList().get(0).getName()); - // Check Groups - Group steel1 = (Group) thimble1.getMemberList().get(0); - // Check steel information - assertEquals(0, steel1.getMemberList().size()); - // Check incore2 information - assertEquals("State Point Data", - incore2.getMemberList().get(0).getName()); - assertEquals("Thimble", incore2.getMemberList().get(1).getName()); - // Check Groups - Group thimble2 = (Group) incore2.getMemberList().get(1); - // Check thimble - assertEquals(2, thimble2.getMemberList().size()); - assertEquals("State Point Data", - thimble2.getMemberList().get(0).getName()); - // Check thimble information - assertEquals("stainless steel", - thimble2.getMemberList().get(1).getName()); - // Check Groups - Group steel2 = (Group) thimble2.getMemberList().get(1); - // Check steel information - assertEquals(1, steel2.getMemberList().size()); - assertEquals("State Point Data", - steel2.getMemberList().get(0).getName()); - // Check incore3 information - assertEquals("State Point Data", - incore3.getMemberList().get(0).getName()); - assertEquals("Thimble", incore3.getMemberList().get(1).getName()); - // Check Groups - Group thimble3 = (Group) incore3.getMemberList().get(1); - // Check thimble - assertEquals(2, thimble3.getMemberList().size()); - // Check thimble information - assertEquals("State Point Data", - incore1.getMemberList().get(0).getName()); - assertEquals("stainless steel", - thimble3.getMemberList().get(1).getName()); - // Check Groups - Group steel3 = (Group) thimble3.getMemberList().get(1); - // Check steel information - assertEquals(1, steel3.getMemberList().size()); - assertEquals("State Point Data", - steel3.getMemberList().get(0).getName()); - // Check incore4 information - assertEquals("State Point Data", - incore4.getMemberList().get(0).getName()); - assertEquals("Thimble", incore4.getMemberList().get(1).getName()); - // Check Groups - Group thimble4 = (Group) incore4.getMemberList().get(1); - // Check thimble - assertEquals(2, thimble4.getMemberList().size()); - // Check thimble information - assertEquals("State Point Data", - thimble4.getMemberList().get(0).getName()); - assertEquals("stainless steel", - thimble4.getMemberList().get(1).getName()); - // Check Groups - Group steel4 = (Group) thimble4.getMemberList().get(1); - // Check steel information - assertEquals(1, steel4.getMemberList().size()); - assertEquals("State Point Data", - steel4.getMemberList().get(0).getName()); - - // Check Rod Cluster Assemblies - Group rodClusterAssemblies = (Group) pWReactor.getMemberList().get(7); - assertEquals(2, rodClusterAssemblies.getMemberList().size()); - // Check incore instrument information - assertEquals("Rod Cluster Assembly A", - rodClusterAssemblies.getMemberList().get(0).getName()); - assertEquals("State Point Data", - rodClusterAssemblies.getMemberList().get(1).getName()); - // Check Groups - Group rodClusterA = (Group) rodClusterAssemblies.getMemberList().get(0); - // Check RodClusterA - assertEquals(3, rodClusterA.getMemberList().size()); - // Check information - assertEquals("LWRRod Grid", - rodClusterA.getMemberList().get(0).getName()); - assertEquals("LWRRods", rodClusterA.getMemberList().get(1).getName()); - assertEquals("State Point Data", - rodClusterA.getMemberList().get(2).getName()); - // Check Groups - Group rodLWRRodGrid = (Group) rodClusterA.getMemberList().get(0); - Group rodLWRRods = (Group) rodClusterA.getMemberList().get(1); - // Check rodLWRRodGrid - assertEquals(1, rodLWRRodGrid.getMemberList().size()); - // Check information - assertEquals("State Point Data", - rodLWRRodGrid.getMemberList().get(0).getName()); - // Check Groups - // Check rodLWRRods - assertEquals(1, rodLWRRods.getMemberList().size()); - - // Check RodClusterAssembly Grid - // Grid Labels - Group rodClusterAssGrid = (Group) pWReactor.getMemberList().get(8); - assertEquals(2, rodClusterAssGrid.getMemberList().size()); - // Check information - assertEquals("Positions", - rodClusterAssGrid.getMemberList().get(0).getName()); - assertEquals("State Point Data", - rodClusterAssGrid.getMemberList().get(1).getName()); - // Check Groups - assertTrue(rodClusterAssGrid.getMemberList().get(0) instanceof Group); - - // Try to use null in constructor - see results - lWRComponentWriter = new LWRComponentWriter(); - assertNotNull(lWRComponentWriter); - - // write the reactor - assertFalse(lWRComponentWriter.write(pwReactor, null)); - - // Check nullaries on factory - assertFalse(lWRComponentWriter.write(null, dataFile.toURI())); - - // Close and delete the .h5 file produced by this test. - try { - newH5File.close(); - dataFile.delete(); - } catch (Exception e) { - System.err.println( - "LWRComponentWriterTester error: Could not delete file \"" - + dataFile.toURI().toString() + "\"."); - fail(); - } - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRCompositeTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRCompositeTester.java deleted file mode 100644 index cf8a4108c..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRCompositeTester.java +++ /dev/null @@ -1,624 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRComponent; -import org.eclipse.ice.reactor.LWRComposite; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class tests LWRComposite. - *

- * - * @author Scott Forest Hull II - */ -public class LWRCompositeTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructor and it's default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local declarations - LWRComposite composite; - HDF5LWRTagType type = HDF5LWRTagType.LWRCOMPOSITE; - - // Default values - String defaultName = "Composite 1"; - String defaultDescription = "Composite 1's Description"; - int defaultId = 1; - - // Check nullary constructor - composite = new LWRComposite(); - assertEquals(defaultName, composite.getName()); - assertEquals(defaultDescription, composite.getDescription()); - assertEquals(defaultId, composite.getId()); - assertEquals(type, composite.getHDF5LWRTag()); - - } - - /** - *

- * Checks the getters and setters for component. - *

- * - */ - @Test - public void checkComponent() { - // Local Declarations - int compositeSize = 17; - LWRComposite composite = new LWRComposite(); - LWRComponent testComponent = new LWRComponent(), testComponent2 = new LWRComponent(), testComponent3 = new LWRComponent(); - String testComponentName = "Bob"; - String testComponentName2 = "Bill!"; - int rowLoc1 = 5, colLoc1 = 5; - int rowLoc2 = 6, colLoc2 = 6; - int testComponentId = 1000001; - - // Set the ids on the test components - testComponent.setId(1); - testComponent2.setId(2); - testComponent3.setId(3); - - composite = new LWRComposite(); - // Set the second component name - testComponent2.setName(testComponentName2); - - // Check the names, should be empty! - assertEquals(0, composite.getComponentNames().size()); - - // Try to get by name - valid string, empty string, and null - assertNull(composite - .getComponent("validNameThatDoesNotExistInThere152423")); - assertNull(composite.getComponent("")); - assertNull(composite.getComponent(null)); - - // Set the name - testComponent.setName(testComponentName); - - // Add to the composite - composite.addComponent(testComponent); - - // Check the getting of a component - assertTrue(testComponent.equals(composite - .getComponent(testComponentName))); - - // Add it in there - composite.addComponent(testComponent2); - - // Check there are two in there, with separate names - assertEquals(2, composite.getComponents().size()); - assertEquals(2, composite.getComponentNames().size()); - assertEquals(testComponent.getName(), composite.getComponentNames() - .get(0)); - assertEquals(testComponent2.getName(), composite.getComponentNames() - .get(1)); - - // Check values - see the components are different and they reside in - // the table correctly - assertTrue(testComponent.equals(composite - .getComponent(testComponentName))); - assertTrue(testComponent2.equals(composite.getComponent(testComponent2 - .getName()))); - - // Check the names, should contain 2! - assertEquals(2, composite.getComponentNames().size()); - assertEquals(testComponentName, composite.getComponentNames().get(0)); - assertEquals(testComponentName2, composite.getComponentNames().get(1)); - - // Check operation for null - composite.addComponent(null); - assertNull(composite.getComponent(null)); // Make sure null does - // not work! - - // Finally, demonstrate what happens when a component of the same name - // is added, it should not overwrite the previous item in the table! - testComponent3.setName(testComponentName); // Same name as the other - // component - testComponent3.setId(testComponentId); // Id should differ from - // testComponent! - assertFalse(testComponent.getId() == testComponentId); - - // Overwrite in table - composite.addComponent(testComponent3); - - // Check that the object has not been overwritten - assertTrue(testComponent.equals(composite - .getComponent(testComponentName))); - assertFalse(testComponent3.equals(composite - .getComponent(testComponentName))); - - // Test to remove components from the composite - composite.removeComponent(null); - composite.removeComponent(""); - composite - .removeComponent("!--+ANamETHaTDoESNOTEXIST19674376393<><(@#*)%^"); - - // Nothing was removed - // Check the names, should contain 2! - assertEquals(2, composite.getComponentNames().size()); - assertEquals(testComponentName, composite.getComponentNames().get(0)); - assertEquals(testComponentName2, composite.getComponentNames().get(1)); - - // Remove the second component - composite.removeComponent(testComponent2.getName()); - - // Check that it does not exist in the location or getting the name - assertNull(composite.getComponent(testComponent2.getName())); - - // Check that the first exists - assertEquals(1, composite.getComponentNames().size()); - assertEquals(testComponentName, composite.getComponentNames().get(0)); - assertEquals(1, composite.getNumberOfComponents()); - assertTrue(testComponent.equals(composite.getComponent(1))); - assertNull(composite.getComponent(2)); - - // Remove the composite, check that it was removed from the map! - composite.removeComponent(1); - assertNull(composite.getComponent(testComponent.getName())); - assertEquals(0, composite.getComponents().size()); - - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - LWRComposite object, equalObject, unEqualObject, transitiveObject; - LWRComponent component = new LWRComponent("Billy the Plummer"); - LWRComponent component2 = new LWRComponent("Billy the Plummer2"); - - // Setup root object - object = new LWRComposite(); - object.addComponent(component); - object.addComponent(component2); - - // Setup equalObject equal to object - equalObject = new LWRComposite(); - equalObject.addComponent(component); - equalObject.addComponent(component2); - - // Setup transitiveObject equal to object - transitiveObject = new LWRComposite(); - transitiveObject.addComponent(component); - transitiveObject.addComponent(component2); - - // Set its data, not equal to object - // Does not contain components! - unEqualObject = new LWRComposite(); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - @Test - public void checkCopying() { - - // Local declarations - LWRComposite object; - LWRComposite copyObject = new LWRComposite(), clonedObject; - - // Values - String name = "A LWRComponent!@!@#!#@56483"; - String description = "Description !@#!@#!@#!46546484328"; - int id = 68468431; - LWRComponent component = new LWRComponent("Billy!"); - LWRComponent component2 = new LWRComponent("Billy2!"); - - // Initialize and Setup Object to test - object = new LWRComposite(); - object.setName(name); - object.setId(id); - object.setDescription(description); - object.addComponent(component); - object.addComponent(component2); - - // Run the copy routine - copyObject = new LWRComposite(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (LWRComposite) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - LWRComposite composite = new LWRComposite(); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = composite.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - LWRComponent component1 = new LWRComponent("Component 1"); - LWRComponent component2 = new LWRComponent("Component 2"); - String testFileName = "testWrite.h5"; - - // Setup composite - composite.setName(name); - composite.setId(id); - composite.setDescription(description); - composite.addComponent(component1); - composite.addComponent(component2); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(composite.getWriteableChildren()); - // Check Children - assertEquals(composite.getComponents().size(), composite - .getWriteableChildren().size()); - assertTrue(component2.equals(composite.getWriteableChildren().get(0))); - assertTrue(component1.equals(composite.getWriteableChildren().get(1))); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(composite.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(4, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(composite.writeAttributes(null, h5Group)); - assertFalse(composite.writeAttributes(h5File, null)); - - // Check Group Creation - H5Group group = composite.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root composite - assertEquals(composite.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - LWRComposite component = new LWRComposite(); - LWRComposite newComponent = new LWRComposite(); - String name = "Fancy composite"; - String description = "It has stuff"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - LWRComponent c1 = new LWRComponent("Component1"), c2 = new LWRComponent( - "Component2"); - - // Setup composite - component.setName(name); - component.setId(id); - component.setDescription(description); - component.addComponent(c1); - component.addComponent(c2); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup LWRComponent with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - assertTrue(newComponent.readChild(c1)); - assertTrue(newComponent.readChild(c2)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Try to break the readChild operation - assertFalse(newComponent.readChild(null)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5File. - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRDataProviderTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRDataProviderTester.java deleted file mode 100644 index d35ab0b5c..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRDataProviderTester.java +++ /dev/null @@ -1,382 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.junit.Test; - -/** - *

- * A class that tests the operations on LWRDataProvider. - *

- * - * @author Scott Forest Hull II - */ -public class LWRDataProviderTester { - /** - *

- * An operation that checks construction. - *

- * - */ - @Test - public void checkConstruction() { - - // Local Declarations - LWRDataProvider provider = new LWRDataProvider(); - - // Check default values - assertEquals(0.0, provider.getCurrentTime(), 0.0); - assertEquals(0, provider.getFeatureList().size()); - assertEquals(0, provider.getNumberOfTimeSteps()); - assertEquals("No Source Available", provider.getSourceInfo()); - assertEquals("seconds", provider.getTimeUnits()); - assertEquals(0, provider.getTimes().size()); - - } - - /** - *

- * An operation that checks the IDataProvider and LWRDataPRovider - * implementations of IData. - *

- * - */ - @Test - public void checkDataProvider() { - - // Local Declarations - LWRDataProvider component; - String name = "Bob"; - LWRData data1, data2, data3, data4, data5; - String data1Feature = "Data1"; - String data2Feature = "Data2"; - String defaultSource = "No Source Available"; - String newSource = "A source"; - double time1 = 1.1; - double time2 = 1.0; - double time3 = 1.3; - String timeUnit = "Minutes!"; - - // Create a component, set the number of time steps, and show the - // behaviors of setting the current time step - component = new LWRDataProvider(); - - // Try to set the time step to 1 - component.setTime(1); - - // Show that it is equal to the set timestep - assertEquals(1.0, component.getCurrentTime(), 0.0); - - // Check invalid - negative - component.setTime(-1); - - // Defaults - assertEquals(1.0, component.getCurrentTime(), 0.0); - - // Check valid - 0 - component.setTime(0); - - // Equal to the set timeStep - assertEquals(0, component.getCurrentTime(), 0.0); - - // Get/set sourceInfo - component = new LWRDataProvider(); - - // Check default - assertEquals(defaultSource, component.getSourceInfo()); - - // Try to set it to a new String - component.setSourceInfo(newSource); - // Check values - should be newSource - assertEquals(newSource, component.getSourceInfo()); - - // Try to set it to null - invalid - component.setSourceInfo(null); - // Check values - should be newSource - assertEquals(newSource, component.getSourceInfo()); // Defaults - - // Try to set it to empty string - invalid - component.setSourceInfo(""); - // Check values - should be newSource - assertEquals(newSource, component.getSourceInfo()); // Defaults - - // Show that the string is trimmed - component.setSourceInfo(newSource + " "); - // Check values - should be newSource - assertEquals(newSource, component.getSourceInfo()); // Trimmed - - // Setup timeUnits - component.setTimeUnits(timeUnit); - // Check values - assertEquals(timeUnit, component.getTimeUnits()); - - // Set timeUnits - nullary - component.setTimeUnits(null); - // Check values - nothing has changed - assertEquals(timeUnit, component.getTimeUnits()); - - // Set timeUnits - "empty string" - component.setTimeUnits(" "); - // Check values - nothing has changed <- auto trims strings - assertEquals(timeUnit, component.getTimeUnits()); - - // Check getters for IData - assertEquals(0, component.getFeatureList().size()); - assertEquals(0, component.getFeaturesAtCurrentTime().size()); - assertEquals(-1, component.getTimeStep(0.0)); - assertEquals(0, component.getDataAtCurrentTime(data1Feature).size()); - - // Add a IData - data1 = new LWRData(data1Feature); - component.addData(data1, time1); - - // Check getters - assertEquals(1, component.getFeatureList().size()); - assertEquals(data1Feature, component.getFeatureList().get(0)); - assertEquals(0, component.getCurrentTime(), 0.0); - assertEquals(0, component.getDataAtCurrentTime(data1Feature).size()); - // Change current time - component.setTime(time1); - // Check values - assertEquals(1, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data1.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - // Check number of timesteps - assertEquals(1, component.getNumberOfTimeSteps()); - - // Add more data to current time with same feature - data2 = new LWRData(data1Feature); - data2.setUncertainty(33.333); - // Check getters - component.addData(data2, time1); - assertEquals(1, component.getFeatureList().size()); - assertEquals(data1Feature, component.getFeatureList().get(0)); - assertEquals(2, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data1.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - assertTrue(data2.equals(component.getDataAtCurrentTime(data1Feature) - .get(1))); - // Check number of timesteps - assertEquals(1, component.getNumberOfTimeSteps()); - // Check times - assertEquals(1, component.getTimes().size()); - assertEquals(time1, component.getTimes().get(0).doubleValue(), 0.0); - assertEquals(0, component.getTimeStep(time1)); - - // Add a LWRData to a different time location - data3 = new LWRData(data1Feature); - data3.setUncertainty(22.2); - component.addData(data3, time2); - // Check getters - assertEquals(1, component.getFeatureList().size()); - assertEquals(data1Feature, component.getFeatureList().get(0)); - assertEquals(2, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data1.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - assertTrue(data2.equals(component.getDataAtCurrentTime(data1Feature) - .get(1))); - // Change time frame - component.setTime(time2); - // Check information - assertEquals(1, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data3.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - // Check number of timesteps - assertEquals(2, component.getNumberOfTimeSteps()); - // Check times - assertEquals(2, component.getTimes().size()); - assertEquals(time2, component.getTimes().get(0).doubleValue(), 0.0); - assertEquals(time1, component.getTimes().get(1).doubleValue(), 0.0); - assertEquals(0, component.getTimeStep(time2)); - assertEquals(1, component.getTimeStep(time1)); - - // Add a LWRData with the same time as time2, but different feature - data4 = new LWRData(data2Feature); - data4.setUncertainty(11.1); - component.addData(data4, time2); - // Check getters - assertEquals(2, component.getFeatureList().size()); - assertTrue(component.getFeatureList().contains(data1Feature)); - assertTrue(component.getFeatureList().contains(data2Feature)); - assertEquals(1, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data3.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - assertEquals(1, component.getDataAtCurrentTime(data2Feature).size()); - assertTrue(data4.equals(component.getDataAtCurrentTime(data2Feature) - .get(0))); - // Check number of timesteps - assertEquals(2, component.getNumberOfTimeSteps()); - // Check times - assertEquals(2, component.getTimes().size()); - assertEquals(time2, component.getTimes().get(0).doubleValue(), 0.0); - assertEquals(time1, component.getTimes().get(1).doubleValue(), 0.0); - assertEquals(0, component.getTimeStep(time2)); - assertEquals(1, component.getTimeStep(time1)); - - // Check nullaries and invalid setters/parameters - assertEquals(-1, component.getTimeStep(time1 + 3333)); - assertEquals(-1, component.getTimeStep(-1.0)); - component.addData(null, time1); - component.addData(data4, -1.0); - assertEquals(0, component.getDataAtCurrentTime(null).size()); - assertEquals(0, component.getDataAtCurrentTime("FeatureDNE!@#12321321") - .size()); - - // Change to invalid time - component.setTime(time3 + 3333333); - assertEquals(time3 + 3333333, component.getCurrentTime(), 0.0); - component.setTime(-1.0); // Try negative - assertEquals(time3 + 3333333, component.getCurrentTime(), 0.0); // Does - // not - // change - assertEquals(0, component.getFeaturesAtCurrentTime().size()); - assertEquals(0, component.getDataAtCurrentTime(data1Feature).size()); - - // Check getters - change time back and show data is not changed - component.setTime(time2); - assertEquals(2, component.getFeatureList().size()); - assertTrue(component.getFeatureList().contains(data1Feature)); - assertTrue(component.getFeatureList().contains(data2Feature)); - assertEquals(1, component.getDataAtCurrentTime(data1Feature).size()); - assertTrue(data3.equals(component.getDataAtCurrentTime(data1Feature) - .get(0))); - assertEquals(1, component.getDataAtCurrentTime(data2Feature).size()); - assertTrue(data4.equals(component.getDataAtCurrentTime(data2Feature) - .get(0))); - // Check number of timesteps - assertEquals(2, component.getNumberOfTimeSteps()); - - } - - /** - *

- * Checks the copying and cloning operations. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - LWRDataProvider object, copyObject, clonedObject; - LWRData data1 = new LWRData("Feature 1"); - double time1 = 3.0; - - // Setup root object - object = new LWRDataProvider(); - object.addData(data1, time1); - - // Run the copy routine - copyObject = new LWRDataProvider(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (LWRDataProvider) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * Checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - LWRDataProvider object, equalObject, unEqualObject, transitiveObject; - LWRData data1 = new LWRData("Feature 1"); - LWRData data2 = new LWRData("Feature 2"); - double time1 = 3.0; - double time2 = 54.0; - - // Setup root object - object = new LWRDataProvider(); - object.addData(data1, time1); - - // Setup equalObject equal to object - equalObject = new LWRDataProvider(); - equalObject.addData(data1, time1); - - // Setup transitiveObject equal to object - transitiveObject = new LWRDataProvider(); - transitiveObject.addData(data1, time1); - - // Set its data, not equal to object - unEqualObject = new LWRDataProvider(); - unEqualObject.addData(data2, time2); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRDataTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRDataTester.java deleted file mode 100644 index bb399b298..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRDataTester.java +++ /dev/null @@ -1,449 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.ArrayList; - -import org.eclipse.ice.reactor.LWRData; -import org.junit.Test; - -/** - *

- * This class tests the operations on LWRData. - *

- * - * @author Scott Forest Hull II - */ -public class LWRDataTester { - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declarations - LWRData data; - - // Default values for LWRData - - // Setup the defaultPosition data - ArrayList defaultPosition = new ArrayList(); - defaultPosition.add(0.0); - defaultPosition.add(0.0); - defaultPosition.add(0.0); - - // Setup the rest - double defaultValue = 0.0; - double defaultUncertainty = 0.0; - String defaultUnits = "seconds"; - String defaultFeature = "Feature 1"; - - String newFeature = "newFEATURE"; - - // Check Construction of a LWRData. - // Instantiate LWRData - data = new LWRData(); - // Check default values - assertEquals(defaultPosition, data.getPosition()); - assertEquals(defaultValue, data.getValue(), 0.0); - assertEquals(defaultUncertainty, data.getUncertainty(), 0.0); - assertEquals(defaultUnits, data.getUnits()); - assertEquals(defaultFeature, data.getFeature()); - - // Instantiate LWRData - feature - data = new LWRData(newFeature); - // Check default values - assertEquals(defaultPosition, data.getPosition()); - assertEquals(defaultValue, data.getValue(), 0.0); - assertEquals(defaultUncertainty, data.getUncertainty(), 0.0); - assertEquals(defaultUnits, data.getUnits()); - assertEquals(newFeature, data.getFeature()); - - // Instantiate LWRData - erroneous feature (null) - data = new LWRData(null); - // Check default values - assertEquals(defaultPosition, data.getPosition()); - assertEquals(defaultValue, data.getValue(), 0.0); - assertEquals(defaultUncertainty, data.getUncertainty(), 0.0); - assertEquals(defaultUnits, data.getUnits()); - assertEquals(defaultFeature, data.getFeature()); // default when - // erroneous feature - // passed - - // Instantiate LWRData - erroneous feature (empty string) - data = new LWRData(""); - // Check default values - assertEquals(defaultPosition, data.getPosition()); - assertEquals(defaultValue, data.getValue(), 0.0); - assertEquals(defaultUncertainty, data.getUncertainty(), 0.0); - assertEquals(defaultUnits, data.getUnits()); - assertEquals(defaultFeature, data.getFeature()); // default when - // erroneous feature - // passed - - } - - /** - *

- * Checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - // Local Declarations - LWRData object, equalObject, unEqualObject, transitiveObject; - String units = "inches"; - String features = "Billy"; - double uncertainty = 5.0; - double value = 4.0; - ArrayList position = new ArrayList(); - position.add(2.0); - position.add(3.0); - - // Setup the Object data - object = new LWRData(); - object.setUnits(units); - object.setFeature(features); - object.setPosition(position); - object.setValue(value); - object.setUncertainty(uncertainty); - - // Setup equalObject equal to object - equalObject = new LWRData(); - equalObject.setUnits(units); - equalObject.setFeature(features); - equalObject.setPosition(position); - equalObject.setValue(value); - equalObject.setUncertainty(uncertainty); - - // Setup transitiveObject equal to object - transitiveObject = new LWRData(); - transitiveObject.setUnits(units); - transitiveObject.setFeature(features); - transitiveObject.setPosition(position); - transitiveObject.setValue(value); - transitiveObject.setUncertainty(uncertainty); - - // Set its data, not equal to object - // Does not contain components! - unEqualObject = new LWRData(); - unEqualObject.setUnits(units); - unEqualObject.setFeature(features + " asdasd"); // Different feature! - unEqualObject.setPosition(position); - unEqualObject.setValue(value); - unEqualObject.setUncertainty(uncertainty); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * Checks the copy and clone routines. - *

- * - */ - @Test - public void checkCopying() { - // Local declarations - LWRData object; - LWRData copyObject = new LWRData(), clonedObject; - - // Values - String units = "inches"; - String features = "Billy"; - double uncertainty = 5.0; - double value = 4.0; - ArrayList position = new ArrayList(); - position.add(2.0); - position.add(3.0); - - // Setup the Object data - object = new LWRData(); - object.setUnits(units); - object.setFeature(features); - object.setPosition(position); - object.setValue(value); - object.setUncertainty(uncertainty); - - // Run the copy routine - copyObject = new LWRData(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (LWRData) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the getter and setter for position. - *

- * - */ - @Test - public void checkPosition() { - // Local Declarations - LWRData data = new LWRData(); - ArrayList position = new ArrayList(); - - // Setup the nullary constructors default position - ArrayList defaultPosition = new ArrayList(); - defaultPosition.add(0.0); - defaultPosition.add(0.0); - defaultPosition.add(0.0); - - // Add a position - position.add(1.0); - - // Check setter: one position - data.setPosition(position); - // Check value - stays the same - assertEquals(defaultPosition, data.getPosition()); - - // Check setter: two positions - position.add(-1.0); - data.setPosition(position); - - // Check value - assertEquals(defaultPosition, data.getPosition()); - - // Check setter: three positions - position.add(-1.0); - data.setPosition(position); - - // Check value - actually works! - assertEquals(position, data.getPosition()); - - // Check setter: 4 or more positions - position.add(-1.0); - data.setPosition(position); - position.remove(3); // Remove it for checking - // Check value - assertEquals(position, data.getPosition()); // Same as 3 positions - - // Set it back to empty - does not work - data.setPosition(new ArrayList()); - // Check value - assertEquals(position, data.getPosition()); // Same as 3 positions - - } - - /** - *

- * This operation checks the getter and setter for value. - *

- * - */ - @Test - public void checkValue() { - // Local Declarations - LWRData data = new LWRData(); - double posValue = 30.0; - double negValue = -1.0; - double zeroValue = 0.0; - - // Check setter : positive - data.setValue(posValue); - // Check value - assertEquals(posValue, data.getValue(), 0.0); - - // Check setter : negative - data.setValue(negValue); - // Check value - assertEquals(negValue, data.getValue(), 0.0); - - // Check setter : zero - data.setValue(zeroValue); - // Check value - assertEquals(zeroValue, data.getValue(), 0.0); - - } - - /** - *

- * This operation checks the getter and setter for uncertainty. - *

- * - */ - @Test - public void checkUncertainty() { - // Local Declarations - LWRData data = new LWRData(); - double posValue = 30.0; - double negValue = -1.0; - double zeroValue = 0.0; - - // Check setter : positive - data.setUncertainty(posValue); - // Check value - assertEquals(posValue, data.getUncertainty(), 0.0); - - // Check setter : negative - data.setUncertainty(negValue); - // Check value - assertEquals(negValue, data.getUncertainty(), 0.0); - - // Check setter : zero - data.setUncertainty(zeroValue); - // Check value - assertEquals(zeroValue, data.getUncertainty(), 0.0); - } - - /** - *

- * This operation checks the getter and setter for units. - *

- * - */ - @Test - public void checkUnits() { - // Local Declarations - LWRData data = new LWRData(); - - // Values to check - String normalString = "Bob"; - String emptyString = ""; - String spaceString = " "; - String trimableString = "Bob "; - - // Check normal String - data.setUnits(normalString); - // Check value - assertEquals(normalString, data.getUnits()); - - // Check empty String - data.setUnits(emptyString); - // Check value - nothing changed - assertEquals(normalString, data.getUnits()); - - // Check space String - data.setUnits(spaceString); - // Check value - nothing changed - assertEquals(normalString, data.getUnits()); - - // Check trimable String - data.setUnits(trimableString); - // Check value - nothing changed - assertEquals(normalString, data.getUnits()); - - // Check null - data.setUnits(null); - // Check value - nothing changed - assertEquals(normalString, data.getUnits()); - - } - - /** - *

- * This operation checks the getter and setter for feature. - *

- * - */ - @Test - public void checkFeature() { - // Local Declarations - LWRData data = new LWRData(); - - // Values to check - String normalString = "Bob"; - String emptyString = ""; - String spaceString = " "; - String trimableString = "Bob "; - - // Check normal String - data.setFeature(normalString); - // Check value - assertEquals(normalString, data.getFeature()); - - // Check empty String - data.setFeature(emptyString); - // Check value - nothing changed - assertEquals(normalString, data.getFeature()); - - // Check space String - data.setFeature(spaceString); - // Check value - nothing changed - assertEquals(normalString, data.getFeature()); - - // Check trimable String - data.setFeature(trimableString); - // Check value - nothing changed - assertEquals(normalString, data.getFeature()); - - // Check null - data.setFeature(null); - // Check value - nothing changed - assertEquals(normalString, data.getFeature()); - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRGridManagerTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRGridManagerTester.java deleted file mode 100644 index 1e1df0cf3..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRGridManagerTester.java +++ /dev/null @@ -1,1330 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Dataset; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.GridLocation; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRComponent; -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRGridManager; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class checks the operations on LWRGridManager. - *

- * - * @author Scott Forest Hull II - */ -public class LWRGridManagerTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation tests the constructor and default values. - *

- * - */ - @Test - public void checkConstruction() { - - // Local Declarations - LWRGridManager manager; - int defaultSize = 1; - String defaultName = "LWRGridManager 1"; - String defaultDescription = "LWRGridManager 1's Description"; - int defaultId = 1; - HDF5LWRTagType type = HDF5LWRTagType.LWRGRIDMANAGER; - - // New - int newSize = 5; - - // Check normal construction - manager = new LWRGridManager(newSize); - // Check values - assertEquals(newSize, manager.getSize()); - assertEquals(defaultName, manager.getName()); - assertEquals(defaultDescription, manager.getDescription()); - assertEquals(defaultId, manager.getId()); - assertEquals(type, manager.getHDF5LWRTag()); - - // Check defaultSize construction - manager = new LWRGridManager(defaultSize); - // Check values - assertEquals(defaultSize, manager.getSize()); - assertEquals(defaultName, manager.getName()); - assertEquals(defaultDescription, manager.getDescription()); - assertEquals(defaultId, manager.getId()); - assertEquals(type, manager.getHDF5LWRTag()); - - // Check illegal size - zero - manager = new LWRGridManager(0); - // Check value - defaults - assertEquals(defaultSize, manager.getSize()); // Defaults - assertEquals(defaultName, manager.getName()); - assertEquals(defaultDescription, manager.getDescription()); - assertEquals(defaultId, manager.getId()); - assertEquals(type, manager.getHDF5LWRTag()); - - // Check illegal size - negative - manager = new LWRGridManager(-1); - // Check values - defaults - assertEquals(defaultSize, manager.getSize()); // Defaults - assertEquals(defaultName, manager.getName()); - assertEquals(defaultDescription, manager.getDescription()); - assertEquals(defaultId, manager.getId()); - assertEquals(type, manager.getHDF5LWRTag()); - - } - - /** - *

- * This operation checks the adding and removing of components. - *

- * - */ - @Test - public void checkComponent() { - // Local Declarations - LWRGridManager manager; - int size = 10; - - // Setup GridLocations values - GridLocation location1, location2, location3, location4; - int row1 = 1, row2 = 5, row3 = 9, row4 = 22; - int col1 = 1, col2 = 5, col3 = 8, col4 = 15; - - // Use LWRComponent - LWRComponent component1, component2, component3, component4; - String component1Name = "Component 1"; - String component2Name = "Component 2"; - String component3Name = "Component 3"; - String component4Name = "Component 4"; - - // Setup the LWRComponents - component1 = new LWRComponent(component1Name); - component2 = new LWRComponent(component2Name); - component3 = new LWRComponent(component3Name); - component4 = new LWRComponent(component4Name); - - // Set ids - component1.setId(1); - component2.setId(2); - component3.setId(3); - component4.setId(4); - - // Null args - LWRComponent nullComponent = null; - GridLocation nullLocation = null; - - // Create a manager - manager = new LWRGridManager(size); - - // Create a gridLocation and add it to the list for Component1 - location1 = new GridLocation(row1, col1); - - // Add it, and check to see if it exists - manager.addComponent(component1, location1); - // See if it exists and is equal - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - - // add 2 more - location2 = new GridLocation(row2, col2); - manager.addComponent(component2, location2); - - location3 = new GridLocation(row3, col3); - manager.addComponent(component3, location3); - - // See if they both exist - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertTrue(component3.getName().equals( - manager.getComponentName(location3))); - - // Try to add something on top of something that already exists - manager.addComponent(component4, location2); - // Show that it does not exist, and no other items are messed with - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertTrue(component3.getName().equals( - manager.getComponentName(location3))); - - // Try to add with a location out of the size range - location4 = new GridLocation(row4, col4); - manager.addComponent(component4, location4); - // Show that it does not exist, and no other items are messed with - assertNull(manager.getComponentName(location4)); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertTrue(component3.getName().equals( - manager.getComponentName(location3))); - - // Try to add with a location of null - location4 = new GridLocation(row4, col4); - manager.addComponent(component4, nullLocation); - // Show that it does not exist, and no other items are messed with - assertNull(manager.getComponentName(nullLocation)); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertTrue(component3.getName().equals( - manager.getComponentName(location3))); - - // Try to add with a component of null - location4 = new GridLocation(row4, col4); - manager.addComponent(nullComponent, nullLocation); - // Show that it does not exist, and no other items are messed with - assertNull(manager.getComponentName(nullLocation)); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertTrue(component3.getName().equals( - manager.getComponentName(location3))); - - // Try to remove based on location - remove component 3 - manager.removeComponent(location3); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertNull(manager.getComponentName(location3)); // Does not exist - // anymore! - - // Try to remove based on location - bad location (location does not - // exist) - manager.removeComponent(location3); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertNull(manager.getComponentName(location3)); // Does not exist - // anymore! - - // Try to removed based on location - out of range - manager.removeComponent(location4); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertNull(manager.getComponentName(location3)); // Does not exist - // anymore! - - // Try to remove - null Location - manager.removeComponent(nullLocation); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertNull(manager.getComponentName(location3)); // Does not exist - // anymore! - - // Try to remove - null Component - manager.removeComponent(nullComponent); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertTrue(component2.getName().equals( - manager.getComponentName(location2))); - assertNull(manager.getComponentName(location3)); // Does not exist - // anymore! - - // Remove based on Component - manager.removeComponent(component2); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertNull(manager.getComponentName(location2)); // Does not exist - // anymore! - assertNull(manager.getComponentName(location3)); // Does not exist - // anymore! - - // Remove a component that does not exist - manager.removeComponent(component2); - assertTrue(component1.getName().equals( - manager.getComponentName(location1))); - assertNull(manager.getComponentName(location2)); // Does not exist - // anymore! - assertNull(manager.getComponentName(location3)); // Does not exist - // anymore! - - // Remove the last component - manager.removeComponent(component1); - assertNull(manager.getComponentName(location1)); // Does not exist - // anymore! - assertNull(manager.getComponentName(location2)); // Does not exist - // anymore! - assertNull(manager.getComponentName(location3)); // Does not exist - // anymore! - - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - LWRGridManager object, equalObject, unEqualObject, transitiveObject; - LWRComponent component, component2; - GridLocation location1, location2; - - // Setup Components - component = new LWRComponent("Billy Bob"); - component2 = new LWRComponent("Bobby Bill"); - - // Setup Locations - location1 = new GridLocation(1, 6); - location2 = new GridLocation(3, 4); - - // Setup root object - object = new LWRGridManager(15); - object.addComponent(component, location1); - object.addComponent(component2, location2); - - // Setup equalObject equal to object - equalObject = new LWRGridManager(15); - equalObject.addComponent(component, location1); - equalObject.addComponent(component2, location2); - - // Setup transitiveObject equal to object - transitiveObject = new LWRGridManager(15); - transitiveObject.addComponent(component, location1); - transitiveObject.addComponent(component2, location2); - - // Set its data, not equal to object - unEqualObject = new LWRGridManager(15); - unEqualObject.addComponent(component2, location1); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - LWRGridManager object, copyObject, clonedObject; - LWRComponent component, component2; - GridLocation location1, location2; - - // Setup Components - component = new LWRComponent("Billy Bob"); - component2 = new LWRComponent("Bobby Bill"); - - // Setup Locations - location1 = new GridLocation(1, 6); - location2 = new GridLocation(3, 4); - - // Setup root object - object = new LWRGridManager(15); - object.addComponent(component, location1); - object.addComponent(component2, location2); - - // Run the copy routine - copyObject = new LWRGridManager(2); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (LWRGridManager) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * Checks the dataprovider operations or operations specific for obtaining a - * data provider. - *

- * - */ - @Test - public void checkDataProvider() { - - // Local Declarations - int size = 5; - LWRGridManager manager = new LWRGridManager(size); - - String name1 = "Foo1"; - String name2 = "Foo2"; - LWRComponent component1 = new LWRComponent(name1); - LWRComponent component2 = new LWRComponent(name2); - GridLocation location1 = new GridLocation(2, 3); - GridLocation location2 = new GridLocation(3, 3); - GridLocation location3 = new GridLocation(1, 3); - - // Try to get locations when there are no GridLocations or names - assertEquals(0, manager.getGridLocationsAtName(name1).size()); - assertNull(manager.getDataProviderAtLocation(location1)); - - // Add to grid - manager.addComponent(component1, location1); - - // Try to get locations - assertEquals(1, manager.getGridLocationsAtName(name1).size()); - assertTrue(manager.getGridLocationsAtName(name1).get(0) - .equals(location1)); - assertNotNull(manager.getDataProviderAtLocation(location1)); - - // Add to another location - manager.addComponent(component1, location2); - - // Try to get locations - assertEquals(2, manager.getGridLocationsAtName(name1).size()); - assertTrue(manager.getGridLocationsAtName(name1).get(0) - .equals(location1)); - assertTrue(manager.getGridLocationsAtName(name1).get(1) - .equals(location2)); - assertNotNull(manager.getDataProviderAtLocation(location1)); - assertNotNull(manager.getDataProviderAtLocation(location2)); - - // Add to another location - different component - manager.addComponent(component2, location3); - - // Try to get locations - assertEquals(2, manager.getGridLocationsAtName(name1).size()); - assertTrue(manager.getGridLocationsAtName(name1).get(0) - .equals(location1)); - assertTrue(manager.getGridLocationsAtName(name1).get(1) - .equals(location2)); - - // Check second component - assertEquals(1, manager.getGridLocationsAtName(name2).size()); - assertTrue(manager.getGridLocationsAtName(name2).get(0) - .equals(location3)); - - // Check all added locations - assertNotNull(manager.getDataProviderAtLocation(location1)); - assertNotNull(manager.getDataProviderAtLocation(location2)); - assertNotNull(manager.getDataProviderAtLocation(location3)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Setup GridLocation data - // Setup LWRData - String feature1 = "Feature 1"; - String feature2 = "Feature 2"; - double time1 = 1.0, time2 = 3.0, time3 = 3.5; - LWRData data1, data2, data3, data4, data5; - ArrayList position1 = new ArrayList(), position2 = new ArrayList(), position3 = new ArrayList(), position4 = new ArrayList(), position5 = new ArrayList(); - - // Setup Positions - - // Setup Position 1 - position1.add(0.0); - position1.add(1.0); - position1.add(0.0); - - // Setup Position 2 - position2.add(0.0); - position2.add(1.0); - position2.add(4.0); - - // Setup Position 3 - position3.add(1.0); - position3.add(1.0); - position3.add(0.0); - - // Setup Position 4 - position4.add(0.0); - position4.add(1.0); - position4.add(1.0); - - // Setup Position 5 - position4.add(0.0); - position4.add(1.0); - position4.add(3.0); - - // Setup data1 - data1 = new LWRData(feature1); - data1.setPosition(position1); - data1.setValue(1.0); - data1.setUncertainty(1.5); - data1.setUnits("Units " + 1); - - // Setup data2 - data2 = new LWRData(feature1); - data2.setPosition(position2); - data2.setValue(2.0); - data2.setUncertainty(2.5); - data2.setUnits("Units " + 2); - - // Setup data3 - data3 = new LWRData(feature1); - data3.setPosition(position3); - data3.setValue(3.0); - data3.setUncertainty(3.5); - data3.setUnits("Units " + 3); - - // Setup data4 - data4 = new LWRData(feature1); - data4.setPosition(position4); - data4.setValue(4.0); - data4.setUncertainty(4.5); - data4.setUnits("Units " + 4); - - // Setup data5 - data5 = new LWRData(feature2); - data5.setPosition(position5); - data5.setValue(5.0); - data5.setUncertainty(5.5); - data5.setUnits("Units " + 5); - - // Local Declarations - int size = 5; - LWRGridManager manager = new LWRGridManager(size); - String name = "GRID!"; - String description = "LABELS!"; - int id = 4; - HDF5LWRTagType tag = manager.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - LWRComponent component1 = new LWRComponent("Component 1"); - LWRComponent component2 = new LWRComponent("Component 2"); - GridLocation location1 = new GridLocation(0, 1); - GridLocation location2 = new GridLocation(2, 2); - ArrayList list = new ArrayList(); - String testFileName = "testWrite.h5"; - - // Add components to list - list.add(component1.getName()); - list.add(component2.getName()); - - // Setup Manager - manager.setName(name); - manager.setId(id); - manager.setDescription(description); - manager.addComponent(component1, location1); - manager.addComponent(component2, location2); - - // Add data to the location - location1.getLWRDataProvider().addData(data1, time1); - location1.getLWRDataProvider().addData(data2, time1); - location1.getLWRDataProvider().addData(data3, time2); - location1.getLWRDataProvider().addData(data4, time3); - location1.getLWRDataProvider().addData(data5, time3); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNull(manager.getWriteableChildren()); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(manager.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(5, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - size - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "size"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(size, ((int[]) attribute.getValue())[0]); - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(manager.writeAttributes(null, h5Group)); - assertFalse(manager.writeAttributes(h5File, null)); - - // Check dataSet. Pass null to show it will fail. - assertFalse(manager.writeDatasets(null, null)); - assertFalse(manager.writeDatasets(null, h5Group)); - assertFalse(manager.writeDatasets(h5File, null)); - - // Perform a dataSet Write - assertTrue(manager.writeDatasets(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check the values of the Positions - assertEquals(2, h5Group.getMemberList().size()); - // Check the values of that dataset - - // Names of the root group - assertEquals("Positions", h5Group.getMemberList().get(0).getName()); - - // StatePointData for the grid manager - assertEquals("State Point Data", h5Group.getMemberList().get(1) - .getName()); - - H5Group positions = (H5Group) h5Group.getMemberList().get(0); - - // Check size - - // There are two positions with the third and forth group handling the - // units - assertEquals(4, positions.getMemberList().size()); - - // Position 1 - assertEquals( - "Position " + location1.getRow() + " " + location1.getColumn(), - positions.getMemberList().get(0).getName()); - - // Position 2 - assertEquals( - "Position " + location2.getRow() + " " + location2.getColumn(), - positions.getMemberList().get(1).getName()); - - // Position Names table - assertEquals("Simple Position Names Table", positions.getMemberList() - .get(2).getName()); - - // Units table - assertEquals("Units Table", positions.getMemberList().get(3).getName()); - - // Check that they are an instance of group - assertTrue(positions.getMemberList().get(0) instanceof Group); - assertTrue(positions.getMemberList().get(1) instanceof Group); - assertTrue(positions.getMemberList().get(2) instanceof Dataset); - assertTrue(positions.getMemberList().get(3) instanceof Dataset); - - // Check internal information - try { - - // Check the dataset - Dataset unitList = (Dataset) positions.getMemberList().get(3); - Dataset namesList = (Dataset) positions.getMemberList().get(2); - - // Check values - unitList.init(); - namesList.init(); - - // Get data - Object unitListData = unitList.getData(); - Object namesListData = namesList.getData(); - - // Cast to array of Strings - String[] arrayStrings = (String[]) unitListData; - String[] arrayNames = (String[]) namesListData; - - // Check values - assertEquals(data1.getUnits(), arrayStrings[0]); - assertEquals(data2.getUnits(), arrayStrings[1]); - assertEquals(data3.getUnits(), arrayStrings[2]); - assertEquals(data4.getUnits(), arrayStrings[3]); - assertEquals(data5.getUnits(), arrayStrings[4]); - - assertEquals(component1.getName(), arrayNames[0]); - assertEquals(component2.getName(), arrayNames[1]); - - // Check the attributes - get the positions - H5Group h5Position1 = (H5Group) positions.getMemberList().get(0); - H5Group h5Position2 = (H5Group) positions.getMemberList().get(1); - - assertEquals(0, h5Position1.getMetadata().size()); - assertEquals(0, h5Position2.getMetadata().size()); - - // Check Data - Dataset positionsDataset1 = HdfReaderFactory.getDataset( - h5Position1, "Position Dataset"); - Dataset positionsDataset2 = HdfReaderFactory.getDataset( - h5Position2, "Position Dataset"); - - // Convert data - int[] positionData1 = new int[3]; - int[] positionData2 = new int[3]; - positionData1 = (int[]) positionsDataset1.getData(); - positionData2 = (int[]) positionsDataset2.getData(); - - // Check values - assertEquals(location1.getRow(), positionData1[0]); - assertEquals(location1.getColumn(), positionData1[1]); - assertEquals(location2.getRow(), positionData2[0]); - assertEquals(location2.getColumn(), positionData2[1]); - assertEquals(0, positionData1[2]); - assertEquals(1, positionData2[2]); - - // Check for subgroups. These subgroups represent if they have - // LWRData or not - assertEquals(4, h5Position1.getMemberList().size()); - assertEquals(1, h5Position2.getMemberList().size()); - - // Get the IDataGroup - H5Group dataGroup = (H5Group) h5Position1; - - // Check the size of the data groups - assertEquals(4, dataGroup.getMemberList().size()); - - // Check the names of the groups. These should reflect the number of - // time steps - assertEquals("Position Dataset", h5Position2.getMemberList().get(0) - .getName()); - - assertEquals("Position Dataset", dataGroup.getMemberList().get(0) - .getName()); - assertEquals("TimeStep: 0", dataGroup.getMemberList().get(1) - .getName()); - assertEquals("TimeStep: 1", dataGroup.getMemberList().get(2) - .getName()); - assertEquals("TimeStep: 2", dataGroup.getMemberList().get(3) - .getName()); - - // Get the TimeStep Groups and check contents - H5Group timeGroup1 = (H5Group) dataGroup.getMemberList().get(1); - H5Group timeGroup2 = (H5Group) dataGroup.getMemberList().get(2); - H5Group timeGroup3 = (H5Group) dataGroup.getMemberList().get(3); - - // Check that there is a group and attributes - assertEquals(2, timeGroup1.getMemberList().size()); - assertEquals(2, timeGroup2.getMemberList().size()); - assertEquals(4, timeGroup3.getMemberList().size()); - assertEquals(1, timeGroup1.getMetadata().size()); - assertEquals(1, timeGroup2.getMetadata().size()); - assertEquals(1, timeGroup3.getMetadata().size()); - - // Check Attributes on timeGroups - - // Check timeGroup1 - // Check time attribute - attribute = (Attribute) timeGroup1.getMetadata().get(0); - assertEquals(attribute.getName(), "time"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(time1, ((double[]) attribute.getValue())[0], 0.0); - - // Check timeGroup2 - // Check time attribute - attribute = (Attribute) timeGroup2.getMetadata().get(0); - assertEquals(attribute.getName(), "time"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(time2, ((double[]) attribute.getValue())[0], 0.0); - - // Check timeGroup3 - // Check time attribute - attribute = (Attribute) timeGroup3.getMetadata().get(0); - assertEquals(attribute.getName(), "time"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(time3, ((double[]) attribute.getValue())[0], 0.0); - - // Get the Features off the timeGroups - Dataset featureGroup1Data = (Dataset) timeGroup1.getMemberList() - .get(0); - Dataset featureGroup1Head = (Dataset) timeGroup1.getMemberList() - .get(1); - Dataset featureGroup2Data = (Dataset) timeGroup2.getMemberList() - .get(0); - Dataset featureGroup2Head = (Dataset) timeGroup2.getMemberList() - .get(1); - - // Feature Group 3 gets two SEPARATE compound datasets because of - // different features within the same time - Dataset featureGroup3aData = (Dataset) timeGroup3.getMemberList() - .get(0); - Dataset featureGroup3aHead = (Dataset) timeGroup3.getMemberList() - .get(1); - Dataset featureGroup3bData = (Dataset) timeGroup3.getMemberList() - .get(2); - Dataset featureGroup3bHead = (Dataset) timeGroup3.getMemberList() - .get(3); - - // Check information on featureGroups - assertEquals("Feature 1 dataTable", featureGroup1Data.getName()); - assertEquals("Feature 1 headTable", featureGroup1Head.getName()); - assertEquals("Feature 1 dataTable", featureGroup2Data.getName()); - assertEquals("Feature 1 headTable", featureGroup2Head.getName()); - assertEquals("Feature 1 dataTable", featureGroup3aData.getName()); - assertEquals("Feature 1 headTable", featureGroup3aHead.getName()); - assertEquals("Feature 2 dataTable", featureGroup3bData.getName()); - assertEquals("Feature 2 headTable", featureGroup3bHead.getName()); - - // Call init to get data - featureGroup1Data.init(); - featureGroup1Head.init(); - featureGroup2Data.init(); - featureGroup2Head.init(); - featureGroup3aData.init(); - featureGroup3aHead.init(); - featureGroup3bData.init(); - featureGroup3bHead.init(); - - // Confirm the sizes of the data - assertEquals(featureGroup1Data.getDims()[0], 2); - assertEquals(featureGroup1Data.getDims()[1], 5); - assertEquals(featureGroup2Data.getDims()[0], 1); - assertEquals(featureGroup2Data.getDims()[1], 5); - assertEquals(featureGroup3aData.getDims()[0], 1); - assertEquals(featureGroup3aData.getDims()[1], 5); - assertEquals(featureGroup3bData.getDims()[0], 1); - assertEquals(featureGroup3bData.getDims()[1], 5); - - // Confirm the sizes of the head - assertEquals(featureGroup1Head.getDims()[0], 2); - assertEquals(featureGroup1Head.getDims()[1], 2); - assertEquals(featureGroup2Head.getDims()[0], 1); - assertEquals(featureGroup2Head.getDims()[1], 2); - assertEquals(featureGroup3aHead.getDims()[0], 1); - assertEquals(featureGroup3aHead.getDims()[1], 2); - assertEquals(featureGroup3bHead.getDims()[0], 1); - assertEquals(featureGroup3bHead.getDims()[1], 2); - - // Check the contents of those feature groups - - // HDF5 java library converts the 2d data into 1 dimension on a - // read. luckily we know the width and length by dimensions passed. - double[] feature1Data1D = (double[]) featureGroup1Data.getData(); - long[] feature1Head1D = (long[]) featureGroup1Head.getData(); - double[] feature2Data1D = (double[]) featureGroup2Data.getData(); - long[] feature2Head1D = (long[]) featureGroup2Head.getData(); - - double[] feature3aData1D = (double[]) featureGroup3aData.getData(); - long[] feature3aHead1D = (long[]) featureGroup3aHead.getData(); - - double[] feature3bData1D = (double[]) featureGroup3bData.getData(); - long[] feature3bHead1D = (long[]) featureGroup3bHead.getData(); - - // Confirm lengths are equivalent - assertEquals( - featureGroup1Data.getDims()[0] - * featureGroup1Data.getDims()[1], - feature1Data1D.length); - // Reads as Value, Uncertainity, xpos, ypos, zpos - Data1 - assertEquals(feature1Data1D[0], data1.getValue(), 0.0); - assertEquals(feature1Data1D[1], data1.getUncertainty(), 0.0); - assertEquals(feature1Data1D[2], data1.getPosition().get(0), 0.0); - assertEquals(feature1Data1D[3], data1.getPosition().get(1), 0.0); - assertEquals(feature1Data1D[4], data1.getPosition().get(2), 0.0); - - // Reads as Value, Uncertainity, xpos, ypos, zpos - Data2 - assertEquals(feature1Data1D[5], data2.getValue(), 0.0); - assertEquals(feature1Data1D[6], data2.getUncertainty(), 0.0); - assertEquals(feature1Data1D[7], data2.getPosition().get(0), 0.0); - assertEquals(feature1Data1D[8], data2.getPosition().get(1), 0.0); - assertEquals(feature1Data1D[9], data2.getPosition().get(2), 0.0); - - // Check Head data - reads DataTableId and then units - // Confirm the data length is correct - assertEquals( - featureGroup1Head.getDims()[0] - * featureGroup1Head.getDims()[1], - feature1Head1D.length); - assertEquals(feature1Head1D[0], 0); - assertEquals(feature1Head1D[1], 0); // Represents data1.getUnits() - // position - assertEquals(feature1Head1D[2], 1); - assertEquals(feature1Head1D[3], 1); // Represents data2.getUnits() - // position - - // Reads as Value, Uncertainity, xpos, ypos, zpos - Data3 - assertEquals(feature2Data1D[0], data3.getValue(), 0.0); - assertEquals(feature2Data1D[1], data3.getUncertainty(), 0.0); - assertEquals(feature2Data1D[2], data3.getPosition().get(0), 0.0); - assertEquals(feature2Data1D[3], data3.getPosition().get(1), 0.0); - assertEquals(feature2Data1D[4], data3.getPosition().get(2), 0.0); - - // Confirm the data length is correct - assertEquals( - featureGroup2Head.getDims()[0] - * featureGroup2Head.getDims()[1], - feature2Head1D.length); - assertEquals(feature2Head1D[0], 0); - assertEquals(feature2Head1D[1], 2); // Represents data3.getUnits() - // position - - // Reads as Value, Uncertainity, xpos, ypos, zpos - Data4 - assertEquals(feature3aData1D[0], data4.getValue(), 0.0); - assertEquals(feature3aData1D[1], data4.getUncertainty(), 0.0); - assertEquals(feature3aData1D[2], data4.getPosition().get(0), 0.0); - assertEquals(feature3aData1D[3], data4.getPosition().get(1), 0.0); - assertEquals(feature3aData1D[4], data4.getPosition().get(2), 0.0); - - // Confirm the data length is correct - assertEquals( - featureGroup3aHead.getDims()[0] - * featureGroup3aHead.getDims()[1], - feature3aHead1D.length); - assertEquals(feature3aHead1D[0], 0); - assertEquals(feature3aHead1D[1], 3); // Represents data3.getUnits() - // position - - // Reads as Value, Uncertainity, xpos, ypos, zpos - Data5 - assertEquals(feature3bData1D[0], data5.getValue(), 0.0); - assertEquals(feature3bData1D[1], data5.getUncertainty(), 0.0); - assertEquals(feature3bData1D[2], data5.getPosition().get(0), 0.0); - assertEquals(feature3bData1D[3], data5.getPosition().get(1), 0.0); - assertEquals(feature3bData1D[4], data5.getPosition().get(2), 0.0); - - // Confirm the data length is correct - assertEquals( - featureGroup3bHead.getDims()[0] - * featureGroup3bHead.getDims()[1], - feature3aHead1D.length); - assertEquals(feature3bHead1D[0], 0); - assertEquals(feature3bHead1D[1], 4); // Represents data3.getUnits() - // position - - } catch (Exception e) { - // Fail out of the test - e.printStackTrace(); - fail(); - } - - // Check Group Creation - - H5Group group = manager.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(3, h5Group.getMemberList().size()); - // Check that it has the same name as the root manager - assertEquals(manager.getName(), h5Group.getMemberList().get(2) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(2)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Setup GridLocation data - // Setup LWRData - String feature1 = "Feature 1"; - String feature2 = "Feature 2"; - double time1 = 1.0, time2 = 3.0, time3 = 3.5; - LWRData data1, data2, data3, data4, data5; - ArrayList position1 = new ArrayList(), position2 = new ArrayList(), position3 = new ArrayList(), position4 = new ArrayList(), position5 = new ArrayList(); - - // Setup Positions - - // Setup Position 1 - position1.add(0.0); - position1.add(1.0); - position1.add(0.0); - - // Setup Position 2 - position2.add(0.0); - position2.add(1.0); - position2.add(4.0); - - // Setup Position 3 - position3.add(1.0); - position3.add(1.0); - position3.add(0.0); - - // Setup Position 4 - position4.add(0.0); - position4.add(1.0); - position4.add(1.0); - - // Setup Position 5 - position4.add(0.0); - position4.add(1.0); - position4.add(3.0); - - // Setup data1 - data1 = new LWRData(feature1); - data1.setPosition(position1); - data1.setValue(1.0); - data1.setUncertainty(1.5); - data1.setUnits("Units " + 1); - - // Setup data2 - data2 = new LWRData(feature1); - data2.setPosition(position2); - data2.setValue(2.0); - data2.setUncertainty(2.5); - data2.setUnits("Units " + 2); - - // Setup data3 - data3 = new LWRData(feature1); - data3.setPosition(position3); - data3.setValue(3.0); - data3.setUncertainty(3.5); - data3.setUnits("Units " + 3); - - // Setup data4 - data4 = new LWRData(feature1); - data4.setPosition(position4); - data4.setValue(4.0); - data4.setUncertainty(4.5); - data4.setUnits("Units " + 4); - - // Setup data5 - data5 = new LWRData(feature2); - data5.setPosition(position5); - data5.setValue(5.0); - data5.setUncertainty(5.5); - data5.setUnits("Units " + 5); - - // Local Declarations - int size = 5; - LWRGridManager component = new LWRGridManager(size); - LWRGridManager newComponent = new LWRGridManager(size + 5); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - LWRComponent component1 = new LWRComponent("Component 1"); - LWRComponent component2 = new LWRComponent("Component 2"); - LWRComponent component3 = new LWRComponent("Component 3"); - GridLocation location1 = new GridLocation(0, 1); - GridLocation location2 = new GridLocation(2, 2); - GridLocation location3 = new GridLocation(0, 0); - ArrayList list = new ArrayList(); - - // Add components to list - list.add(component1.getName()); - list.add(component2.getName()); - list.add(component3.getName()); - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.addComponent(component1, location1); - component.addComponent(component2, location2); - component.addComponent(component3, location3); - - // Add data to the location - location1.getLWRDataProvider().addData(data1, time1); - location1.getLWRDataProvider().addData(data2, time1); - location1.getLWRDataProvider().addData(data3, time2); - location1.getLWRDataProvider().addData(data4, time3); - location1.getLWRDataProvider().addData(data5, time3); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check Readable Children - // assertTrue(component.readChild(null)); - - // Setup LWRGridManager with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup size attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "size", - size); - - // Setup dataSets - component.writeDatasets(h5File, subGroup); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertTrue(newComponent.readDatasets(subGroup)); - assertFalse(newComponent.readDatasets(null)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5 file! - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRRodTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRRodTester.java deleted file mode 100644 index f9f247667..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWRRodTester.java +++ /dev/null @@ -1,775 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.TreeSet; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRRod; -import org.eclipse.ice.reactor.Material; -import org.eclipse.ice.reactor.MaterialBlock; -import org.eclipse.ice.reactor.MaterialType; -import org.eclipse.ice.reactor.Ring; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class is responsible for testing the LWRRod class. - *

- * - * @author Scott Forest Hull II - */ -public class LWRRodTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local declarations - LWRRod testRod; - - // Default Values - double defaultGasPressure = 2200.0; // psig - String defaultName = "LWRRod"; - String defaultDesc = "LWRRod's Description"; - int defaultId = 1; - Material defaultFillGas = new Material("Void", MaterialType.GAS); - Material defaultCladMaterial = new Material("Zirc", MaterialType.SOLID); - Ring defaultClad = new Ring("Clad", defaultCladMaterial, 0.0, 0.0); - HDF5LWRTagType type = HDF5LWRTagType.LWRROD; - int materialBlockSizeDefault = 0; - - // New Values - Material newFillGas = new Material("Helium", MaterialType.GAS); - double newGasPressure = 2200.34344512434; - String newName = "ControlRod"; - MaterialBlock materialBlock = new MaterialBlock(); - TreeSet materialBlockList = new TreeSet(); - materialBlockList.add(materialBlock); - // New CLad cannot be set through the constructor for now - - // test Nullary - testRod = new LWRRod(); - // Check default values - assertEquals(defaultName, testRod.getName()); - assertEquals(defaultDesc, testRod.getDescription()); - assertEquals(defaultFillGas.getName(), testRod.getFillGas().getName()); - assertEquals(defaultFillGas.getMaterialType(), testRod.getFillGas() - .getMaterialType()); - assertEquals(defaultGasPressure, testRod.getPressure(), 0.0); - assertEquals(defaultId, testRod.getId()); - assertEquals(materialBlockSizeDefault, testRod.getMaterialBlocks() - .size()); - assertEquals(defaultClad.getName(), testRod.getClad().getName()); - assertEquals(defaultClad.getMaterial().getMaterialType(), testRod - .getClad().getMaterial().getMaterialType()); - assertEquals(type, testRod.getHDF5LWRTag()); - - // test non-nullary constructor -name - testRod = new LWRRod(newName); - // Except set name everything else should be Default value - assertEquals(newName, testRod.getName()); - assertEquals(defaultDesc, testRod.getDescription()); - assertEquals(defaultFillGas, testRod.getFillGas()); - assertEquals(defaultGasPressure, testRod.getPressure(), 0.0); - assertEquals(defaultId, testRod.getId()); - assertEquals(materialBlockSizeDefault, testRod.getMaterialBlocks() - .size()); - assertEquals(defaultClad.getName(), testRod.getClad().getName()); - assertEquals(defaultClad.getMaterial().getMaterialType(), testRod - .getClad().getMaterial().getMaterialType()); - assertEquals(type, testRod.getHDF5LWRTag()); - - // test non-nullary constructor -name fillgas pressure, list of - // MaterialBlocks - testRod = new LWRRod(newName, newFillGas, newGasPressure, - materialBlockList); - // Check if the new values are set - assertEquals(newName, testRod.getName()); - assertEquals(newFillGas, testRod.getFillGas()); - assertEquals(newGasPressure, testRod.getPressure(), 0.0); - assertTrue(testRod.getMaterialBlocks().equals(materialBlockList)); - assertEquals(type, testRod.getHDF5LWRTag()); - - // test non-nullary constructor with null name - testRod = new LWRRod(null, newFillGas, newGasPressure, - materialBlockList); - assertEquals(defaultName, testRod.getName()); - assertEquals(type, testRod.getHDF5LWRTag()); - assertTrue(testRod.getMaterialBlocks().equals(materialBlockList)); - - // test non-nullary constructor with null Fill Gas - testRod = new LWRRod(newName, null, newGasPressure, materialBlockList); - assertEquals(defaultFillGas, testRod.getFillGas()); - assertEquals(type, testRod.getHDF5LWRTag()); - assertTrue(testRod.getMaterialBlocks().equals(materialBlockList)); - - // test non-nullary constructor with bad Pressure - testRod = new LWRRod(newName, newFillGas, -1.0, materialBlockList); - assertEquals(defaultGasPressure, testRod.getPressure(), 0.0); - assertTrue(testRod.getMaterialBlocks().equals(materialBlockList)); - - // test non-nullary constructor with null MaterialBlock - testRod = new LWRRod(null, newFillGas, newGasPressure, null); - assertEquals(materialBlockSizeDefault, testRod.getMaterialBlocks() - .size()); - } - - /** - *

- * This operation checks the getter and setter for the fill gas. - *

- * - */ - @Test - public void checkFillGas() { - LWRRod testRod = new LWRRod(); - Material newFillGas = new Material("Helium", MaterialType.GAS); - - // check setter Legal value - testRod.setFillGas(newFillGas); - assertEquals(newFillGas, testRod.getFillGas()); - - // check null, it should return previous value - testRod.setFillGas(null); - assertEquals(newFillGas, testRod.getFillGas()); - } - - /** - *

- * This operation checks the getter and setter for the pressure. - *

- * - */ - @Test - public void checkPressure() { - LWRRod testRod = new LWRRod(); - double newGasPressure = 2200.34344512434; - // check setter Legal value - testRod.setPressure(newGasPressure); - assertEquals(newGasPressure, testRod.getPressure(), 0.0); - - // check setting illegal 0.0 value - testRod.setPressure(0.0); - assertEquals(newGasPressure, testRod.getPressure(), 0.0); - - // check setting illegal negative value - testRod.setPressure(-1.0); - assertEquals(newGasPressure, testRod.getPressure(), 0.0); - } - - /** - *

- * This operation checks the getter and setter for the MaterialBlock. - *

- * - */ - @Test - public void checkMaterialBlock() { - LWRRod testRod = new LWRRod(); - MaterialBlock materialBlock = new MaterialBlock(); - TreeSet materialBlocks = new TreeSet(); - materialBlocks.add(materialBlock); - - // check if list of MaterialBlocks can be set to non-null; - testRod.setMaterialBlocks(materialBlocks); - assertTrue(testRod.getMaterialBlocks().equals(materialBlocks)); - - // check setting illegal null value - testRod.setMaterialBlocks(null); - assertTrue(testRod.getMaterialBlocks().equals(materialBlocks)); - - // Empty check - testRod.setMaterialBlocks(new TreeSet()); - assertTrue(testRod.getMaterialBlocks().equals(materialBlocks)); - - } - - /** - *

- * This operations checks getters and setters for the clad object - *

- * - */ - @Test - public void checkClad() { - - LWRRod testRod = new LWRRod(); - Material cladMaterial = new Material("Steel304", MaterialType.SOLID); - Ring newClad = new Ring("Clad", cladMaterial, 0.0, 0.0); - - // check if clad can be a set to a new clad - testRod.setClad(newClad); - assertEquals(newClad, testRod.getClad()); - - // check setting illegal null value - testRod.setClad(null); - assertEquals(newClad, testRod.getClad()); - - } - - /** - *

- * Checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - LWRRod object, equalObject, unEqualObject, transitiveObject; - Ring clad; - MaterialBlock materialBlock; - Material material; - Ring ring1, ring2; - double pressure = 2.0; - double unEqualPressure = 5.0; - TreeSet blocks = new TreeSet(); - - // Setup Rings - ring1 = new Ring("Bob", new Material("Billy"), 20.0, 5.0, 10.0); - ring2 = new Ring("Bob2", new Material("Billy2"), 22.0, 52.0, 102.0); - clad = new Ring("Bob3", new Material("Billy3"), 0, 52.0, 103.0); - - // Setup material - material = new Material("MAterialSSSS464"); - - // Setup MaterialBlock - materialBlock = new MaterialBlock(); - materialBlock.addRing(ring1); - materialBlock.addRing(ring2); - blocks.add(materialBlock); - - // Setup Clad - clad = new Ring("Bob3", new Material("Billy3"), 0.0, 53.0, 105.0); - - // Setup root object - object = new LWRRod("ROD!", material, pressure, blocks); - object.setClad(clad); - - // Setup equalObject equal to object - equalObject = new LWRRod("ROD!", material, pressure, blocks); - equalObject.setClad(clad); - - // Setup transitiveObject equal to object - transitiveObject = new LWRRod("ROD!", material, pressure, blocks); - transitiveObject.setClad(clad); - - // Set its data, not equal to object - unEqualObject = new LWRRod("ROD!", material, unEqualPressure, blocks); - unEqualObject.setClad(clad); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * Checks the copy and clone routines. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - LWRRod object, copyObject, clonedObject; - Ring clad; - MaterialBlock materialBlock; - Material material; - Ring ring1, ring2; - double pressure = 2.0; - TreeSet blocks = new TreeSet(); - - // Setup Rings - ring1 = new Ring("Bob", new Material("Billy"), 20.0, 5.0, 10.0); - ring2 = new Ring("Bob2", new Material("Billy2"), 22.0, 52.0, 102.0); - clad = new Ring("Bob3", new Material("Billy3"), 0, 52.0, 103.0); - - // Setup material - material = new Material("MAterialSSSS464"); - - // Setup MaterialBlocks - materialBlock = new MaterialBlock(); - materialBlock.addRing(ring1); - materialBlock.addRing(ring2); - blocks.add(materialBlock); - - // Setup Clad - clad = new Ring("Bob3", new Material("Billy3"), 0.0, 53.0, 105.0); - - // Setup root object - object = new LWRRod("ROD!", material, pressure, blocks); - object.setClad(clad); - - // Run the copy routine - copyObject = new LWRRod(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (LWRRod) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - LWRRod rod = new LWRRod(); - String name = "Wacky Waving Inflatable Arm-Flailing Tubeman!"; - String description = "I am overstocked with deals!"; - int id = 4; - HDF5LWRTagType tag = rod.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - Double pressure = 23.898; - String testFileName = "testWrite.h5"; - MaterialBlock materialBlock1, materialBlock2; - TreeSet blocks = new TreeSet(); - - // Setup MaterialBlocks - materialBlock1 = new MaterialBlock(); - materialBlock2 = new MaterialBlock(); - - // Set position - materialBlock1.setPosition(1.0); - materialBlock2.setPosition(2.0); - - blocks.add(materialBlock1); - blocks.add(materialBlock2); - - materialBlock1.setName("Made of inflatable plastic11!"); - materialBlock2.setName("Made of inflatable plastic22!"); - Material material = new Material("Wacky Helium and AIR!"); - Ring ring1 = new Ring("THE WAVING ARMS PART!"); - Ring ring2 = new Ring("THE WAVING ARMS PART2222!"); - - materialBlock1.addRing(ring1); - materialBlock1.addRing(ring2); - materialBlock2.addRing(ring1); - - // Setup composite - rod.setName(name); - rod.setId(id); - rod.setDescription(description); - rod.setClad(ring1); - rod.setFillGas(material); - rod.setMaterialBlocks(blocks); - rod.setPressure(pressure); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(rod.getWriteableChildren()); - // Check Children - assertEquals(4, rod.getWriteableChildren().size()); - assertTrue(rod.getClad().equals(rod.getWriteableChildren().get(0))); - assertTrue(rod.getFillGas().equals(rod.getWriteableChildren().get(1))); - assertTrue(rod.getWriteableChildren().contains( - rod.getMaterialBlocks().toArray()[0])); - assertTrue(rod.getWriteableChildren().contains( - rod.getMaterialBlocks().toArray()[1])); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(rod.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(5, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - pressure - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "pressure"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(((double[]) attribute.getValue())[0], 1.2, pressure); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(rod.writeAttributes(null, h5Group)); - assertFalse(rod.writeAttributes(h5File, null)); - - // Check dataSet. - assertFalse(rod.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = rod.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root rod - assertEquals(rod.getName(), h5Group.getMemberList().get(0).toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - LWRRod component = new LWRRod(); - LWRRod newComponent = new LWRRod(); - String name = "Wacky Waving Inflatable Arm-Flailing Tubeman!"; - String description = "I am overstocked with deals!"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - Double pressure = 23.898; - H5Group subGroup = null; - - MaterialBlock materialBlock1, materialBlock2; - TreeSet blocks = new TreeSet(); - - // Setup MaterialBlocks - materialBlock1 = new MaterialBlock(); - materialBlock2 = new MaterialBlock(); - - // Set position - materialBlock1.setPosition(1.0); - materialBlock2.setPosition(2.0); - - blocks.add(materialBlock1); - blocks.add(materialBlock2); - - materialBlock1.setName("Made of inflatable plastic11!"); - materialBlock2.setName("Made of inflatable plastic22!"); - Material material = new Material("Wacky Helium and AIR!"); - Ring ring1 = new Ring("THE WAVING ARMS PART!"); - Ring ring2 = new Ring("THE WAVING ARMS PART2222!"); - - materialBlock1.addRing(ring1); - materialBlock1.addRing(ring2); - materialBlock2.addRing(ring1); - - // Test readChild here - assertFalse(component.readChild(null)); - assertTrue(component.readChild(newComponent)); - assertTrue(component.readChild(ring1)); - assertTrue(component.readChild(material)); - assertTrue(component.readChild((IHdfReadable) blocks.toArray()[0])); - assertTrue(component.readChild((IHdfReadable) blocks.toArray()[1])); - assertTrue(blocks.containsAll(component.getMaterialBlocks())); - assertTrue(component.getClad().getName().equals(ring1.getName())); - assertTrue(component.getFillGas().getName().equals(material.getName())); - - // Reset values - component = new LWRRod(); - - // Setup composite - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setClad(ring1); - component.setFillGas(material); - component.setMaterialBlocks(blocks); - component.setPressure(pressure); - - newComponent.setClad(ring1); - newComponent.setFillGas(material); - newComponent.setMaterialBlocks(blocks); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup LWRComponent with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup pressure attribute - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, "pressure", - pressure); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5File. - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWReactorTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWReactorTester.java deleted file mode 100644 index 6f98cd725..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/LWReactorTester.java +++ /dev/null @@ -1,558 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRComposite; -import org.eclipse.ice.reactor.LWReactor; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - * @author Scott Forest Hull II - */ -public class LWReactorTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructor and it's default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declarations - LWReactor reactor; - String defaultName = "LWReactor 1"; - String defaultDescription = "LWReactor 1's Description"; - int defaultId = 1; - int defaultSize = 1; - HDF5LWRTagType type = HDF5LWRTagType.LWREACTOR; - - // This test is to show the default value for a reactor when it is - // created with a negative value. - reactor = new LWReactor(-1); - assertEquals(defaultSize, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(type, reactor.getHDF5LWRTag()); - - // This test is to show the default value for a reactor when its created - // with a zero value - reactor = new LWReactor(0); - assertEquals(defaultSize, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(type, reactor.getHDF5LWRTag()); - - // This is a test to show a valid creation of a reactor - reactor = new LWReactor(17); - assertEquals(17, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(type, reactor.getHDF5LWRTag()); - - } - - /** - *

- * This operation demonstrates the behaviors listed with the overridden - * composite implementations from LWRcomposite. - *

- * - */ - @Test - public void checkCompositeImplementations() { - - // Local Declarations - int reactorSize = 17; - LWReactor reactor; - ArrayList compNames = new ArrayList(); - ArrayList components = new ArrayList(); - int numberOfDefaultComponents = 0; - - // Setup the default number of components - numberOfDefaultComponents = components.size(); - - // Check the default Composite size and attributes on PWRAssembly - reactor = new LWReactor(reactorSize); - - // Has a size of numberOfDefaultComponents - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - // Check general getters for the other pieces - assertTrue(compNames.equals(reactor.getComponentNames())); - assertTrue(components.equals(reactor.getComponents())); - - // These operations will show that these will not work for this class - - // Check addComponent - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - reactor.addComponent(new LWRComposite()); - // No size change! - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - - // Check removeComponent - id - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - reactor.removeComponent(1); - // No size change! - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - - // Check remove component - name - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - - // No size change! - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - - } - - /** - *

- * This operation checks equals() and hashCode() operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - LWReactor object, equalObject, unEqualObject, transitiveObject; - int size = 5; - int unEqualSize = 7; - - // Setup root object - object = new LWReactor(size); - - // Setup equalObject equal to object - equalObject = new LWReactor(size); - - // Setup transitiveObject equal to object - transitiveObject = new LWReactor(size); - - // Set its data, not equal to object - unEqualObject = new LWReactor(unEqualSize); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copy and clone routines. - *

- * - */ - @Test - public void checkCopying() { - - // Local declarations - LWReactor object; - LWReactor copyObject = new LWReactor(0), clonedObject; - - int size = 5; - - // Setup root object - object = new LWReactor(size); - - // Run the copy routine - copyObject = new LWReactor(0); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (LWReactor) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - int size = 5; - LWReactor reactor = new LWReactor(size); - String name = "A plain reactor"; - String description = "Its very plain."; - int id = 4; - HDF5LWRTagType tag = reactor.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - String testFileName = "testWrite.h5"; - - // Setup reactor - reactor.setName(name); - reactor.setId(id); - reactor.setDescription(description); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(reactor.getWriteableChildren()); - assertEquals(size, reactor.getSize()); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(reactor.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(5, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - size - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "size"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(size, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(reactor.writeAttributes(null, h5Group)); - assertFalse(reactor.writeAttributes(h5File, null)); - - // Check dataSet. - assertFalse(reactor.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = reactor.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root reactor - assertEquals(reactor.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - int size = 5; - LWReactor component = new LWReactor(size); - LWReactor newComponent = new LWReactor(-1); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - double rodPitch = 4; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check Readable Children - // assertTrue(component.readChild(null)); - - // Setup PWRAssembly with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup size attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "size", - size); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5 file! - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/MaterialBlockTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/MaterialBlockTester.java deleted file mode 100644 index fb4465c7d..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/MaterialBlockTester.java +++ /dev/null @@ -1,688 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.Material; -import org.eclipse.ice.reactor.MaterialBlock; -import org.eclipse.ice.reactor.Ring; -import org.junit.AfterClass; -import org.junit.Test; - -/** - *

- * This class tests the MaterialBlock's operations. - *

- * - * @author Scott Forest Hull II - */ -public class MaterialBlockTester { - /** - *

- * This operation checks the adding, getting and removing of Rings. - *

- * - */ - @Test - public void checkRingMutators() { - - // Local Declarations - MaterialBlock materialBlock = new MaterialBlock(); - - // Check for adding a null ring - boolean result = materialBlock.addRing(null); - assertFalse(result); - - // Check for adding a ring - Ring ring1 = new Ring(); - ring1.setName("Ring 1"); - ring1.setOuterRadius(10); - ring1.setInnerRadius(9); - result = materialBlock.addRing(ring1); - assertTrue(result); - - // Check for adding another ring - Ring ring2 = new Ring(); - ring2.setName("Ring 2"); - ring2.setOuterRadius(4); - ring2.setInnerRadius(3); - result = materialBlock.addRing(ring2); - assertTrue(result); - - // Check for adding an overlapping ring - Ring ring3 = new Ring(); - ring3.setName("Ring 3"); - ring3.setOuterRadius(3.5); - ring3.setInnerRadius(2.5); - result = materialBlock.addRing(ring3); - assertFalse(result); - - // Check for getting a ring by a null name - Ring ring4 = materialBlock.getRing(null); - assertNull(ring4); - - // Check for getting a ring by a name that does not exist - Ring ring5 = materialBlock.getRing("Harold"); - assertNull(ring5); - - // Check for getting a ring by a name that does exist - Ring ring6 = materialBlock.getRing("Ring 2"); - assertNotNull(ring6); - assertEquals(ring6, ring2); - assertEquals(ring6.getName(), "Ring 2"); - assertTrue(ring6.getOuterRadius() == 4); - assertTrue(ring6.getInnerRadius() == 3); - - // Check for getting a ring by a radius not in the set of Rings - Ring ring7 = materialBlock.getRing(2.5); - assertNull(ring7); - - // Check for getting a ring by a radius in the set of Rings - Ring ring8 = materialBlock.getRing(3.5); - assertNotNull(ring8); - assertEquals(ring8, ring2); - assertEquals(ring8.getName(), "Ring 2"); - assertTrue(ring8.getOuterRadius() == 4); - assertTrue(ring8.getInnerRadius() == 3); - - // Check for getting the set of rings - ArrayList list = materialBlock.getRings(); - assertNotNull(list); - assertTrue(list.size() == 2); - assertEquals(list.get(0), ring2); - assertEquals(list.get(1), ring1); - - // Check for removing a ring by a null name - result = materialBlock.removeRing(null); - assertFalse(result); - list = materialBlock.getRings(); - assertTrue(list.size() == 2); - assertEquals(list.get(0), ring2); - assertEquals(list.get(1), ring1); - - // Check for removing a ring that is not in the set - result = materialBlock.removeRing("Harold"); - assertFalse(result); - list = materialBlock.getRings(); - assertTrue(list.size() == 2); - assertEquals(list.get(0), ring2); - assertEquals(list.get(1), ring1); - - // Check for removing a ring that is in the set - result = materialBlock.removeRing("Ring 1"); - assertTrue(result); - list = materialBlock.getRings(); - assertTrue(list.size() == 1); - assertEquals(list.get(0), ring2); - - } - - /** - *

- * This operation checks the constructor and it's default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declaration - MaterialBlock materialBlock; - // Default values - String defaultName = "MaterialBlock 1"; - String defaultDesc = "MaterialBlock 1's Description"; - int defaultId = 1; - HDF5LWRTagType type = HDF5LWRTagType.MATERIALBLOCK; - double defaultPos = 0.0; - - // Instantiate the materialBlock and check default values - materialBlock = new MaterialBlock(); - - // check values - assertEquals(defaultName, materialBlock.getName()); - assertEquals(defaultDesc, materialBlock.getDescription()); - assertEquals(defaultId, materialBlock.getId()); - assertEquals(type, materialBlock.getHDF5LWRTag()); - assertEquals(defaultPos, materialBlock.getPosition(), 0.0); - - } - - /** - *

- * Checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - MaterialBlock object, equalObject, unEqualObject, transitiveObject; - Ring ring1, ring2; - - // Setup Rings - ring1 = new Ring("Bob", new Material("Billy"), 20.0, 5.0, 10.0); - ring2 = new Ring("Bob2", new Material("Billy2"), 22.0, 52.0, 102.0); - - // Setup root object - object = new MaterialBlock(); - object.addRing(ring1); - object.addRing(ring2); - - // Setup equalObject equal to object - equalObject = new MaterialBlock(); - equalObject.addRing(ring1); - equalObject.addRing(ring2); - - // Setup transitiveObject equal to object - transitiveObject = new MaterialBlock(); - transitiveObject.addRing(ring1); - transitiveObject.addRing(ring2); - - // Set its data, not equal to object - unEqualObject = new MaterialBlock(); - unEqualObject.addRing(ring2); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * Checks the copy and clone routines. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - MaterialBlock object, copyObject, clonedObject; - Ring ring1, ring2; - - // Setup Rings - ring1 = new Ring("Bob", new Material("Billy"), 20.0, 5.0, 10.0); - ring2 = new Ring("Bob2", new Material("Billy2"), 22.0, 52.0, 102.0); - - // Setup root object - object = new MaterialBlock(); - object.addRing(ring1); - object.addRing(ring2); - - // Run the copy routine - copyObject = new MaterialBlock(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (MaterialBlock) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - MaterialBlock component = new MaterialBlock(); - String name = "MaterialBlock"; - String description = "Its a collection of rings! MaterialBlock put a ring on it! It has several!"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - Ring ring1 = new Ring("Ring 1"); - ring1.setOuterRadius(6); - ring1.setInnerRadius(4); - Ring ring2 = new Ring("Ring 2"); - ring2.setOuterRadius(3); - ring2.setInnerRadius(1); - String testFileName = "testWrite.h5"; - double position = 2.3; - - Attribute attribute = null; - String attributeValue = null; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.addRing(ring1); - component.addRing(ring2); - component.setPosition(position); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - System.out.println("Going to open file: " - + System.getProperty("user.dir") + separator + testFileName); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(component.getWriteableChildren()); - - // Check children - assertEquals(component.getRings().size(), component - .getWriteableChildren().size()); - assertTrue(ring2.equals(component.getWriteableChildren().get(0))); - assertTrue(ring1.equals(component.getWriteableChildren().get(1))); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(component.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(5, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - rodPitch - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "position"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(position, ((double[]) attribute.getValue())[0], 1.2); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(component.writeAttributes(null, h5Group)); - assertFalse(component.writeAttributes(h5File, null)); - - // Check dataSet. Pass null to show that it always returns true and does - // nothing - assertFalse(component.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = component.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root component - assertEquals(component.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - MaterialBlock component = new MaterialBlock(); - MaterialBlock newComponent = new MaterialBlock(); - String name = "MaterialBlock"; - String description = "Its a collection of rings! MaterialBlock put a ring on it! It has several!"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - Ring ring1 = new Ring("Ring 1"); - ring1.setOuterRadius(6); - ring1.setInnerRadius(4); - Ring ring2 = new Ring("Ring 2"); - ring2.setOuterRadius(3); - ring2.setInnerRadius(1); - H5Group subGroup = null; - double position = 2.3; - - // Test readChild here - assertTrue(component.readChild(ring1)); - assertFalse(component.readChild(null)); - assertTrue(component.readChild(newComponent)); - assertTrue(component.getRings().size() == 1); - assertTrue(component.getRing(ring1.getName()).equals(ring1)); - - // Reset component - component.removeRing(ring1.getName()); - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.addRing(ring1); - component.addRing(ring2); - component.setPosition(position); - - // Add rings to group. Should remove once children are set up correctly - newComponent.addRing(ring1); - newComponent.addRing(ring2); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup LWRComponent with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Write pos - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, "position", - position); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5 file! - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - - /** - *

- * Checks the get/set position operators. - *

- * - */ - public void checkPosition() { - MaterialBlock materialBlock = new MaterialBlock(); - - assertEquals(0, materialBlock.getPosition(), 0.0); - - // Set to bad value - materialBlock.setPosition(-1.0); - // Doesnt change - assertEquals(0, materialBlock.getPosition(), 0.0); - - // Set to good value - materialBlock.setPosition(0.0); - assertEquals(0, materialBlock.getPosition(), 0.0); - - // Set to good value - materialBlock.setPosition(1.0); - assertEquals(1, materialBlock.getPosition(), 0.0); - - } - - /** - *

- * Checks the comparison operator. - *

- * - */ - public void checkCompareTo() { - - // Local Declarations - MaterialBlock mBlock1, mBlock2, mBlock3; - double pos1, pos2; - pos1 = 1.0; - pos2 = 2.0; - - // Create blocks - // Less than - mBlock1 = new MaterialBlock(); - mBlock1.setPosition(pos1); - - // Greater than - mBlock2 = new MaterialBlock(); - mBlock2.setPosition(pos2); - - // Equal to block1 - mBlock3 = new MaterialBlock(); - mBlock3.setPosition(pos1); - - // Show comparisons - assertEquals(-1, mBlock1.compareTo(mBlock2)); - assertEquals(1, mBlock2.compareTo(mBlock1)); - assertEquals(0, mBlock1.compareTo(mBlock3)); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/MaterialTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/MaterialTester.java deleted file mode 100644 index 022d9fd78..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/MaterialTester.java +++ /dev/null @@ -1,636 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.Material; -import org.eclipse.ice.reactor.MaterialType; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * A class that tests the Material's operations. - *

- * - * @author Scott Forest Hull II - */ -public class MaterialTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - - // Local Declarations - Material material = null; - String defaultName = "Material"; - String defaultDesc = "Material's Description"; - String newName = "Special Material"; - MaterialType defaultType = MaterialType.SOLID; - MaterialType newType = MaterialType.GAS; - int defaultId = 1; - HDF5LWRTagType type = HDF5LWRTagType.MATERIAL; - - // Instantiate material and check default values - material = new Material(); - assertEquals(defaultName, material.getName()); - assertEquals(defaultDesc, material.getDescription()); - assertEquals(defaultId, material.getId()); - assertEquals(defaultType, material.getMaterialType()); - assertEquals(type, material.getHDF5LWRTag()); - - // Instantiate material with different name and check default values - material = new Material(newName); - assertEquals(newName, material.getName()); - assertEquals(defaultDesc, material.getDescription()); - assertEquals(defaultId, material.getId()); - assertEquals(defaultType, material.getMaterialType()); - assertEquals(type, material.getHDF5LWRTag()); - - // Instantiate material incorrectly and check default values - material = new Material(null); - assertEquals(defaultName, material.getName()); // Name defaults - assertEquals(defaultDesc, material.getDescription()); - assertEquals(defaultId, material.getId()); - assertEquals(defaultType, material.getMaterialType()); - assertEquals(type, material.getHDF5LWRTag()); - - // Instantiate material with different name and different type. Check - // values - material = new Material(newName, newType); - assertEquals(newName, material.getName()); - assertEquals(defaultDesc, material.getDescription()); - assertEquals(defaultId, material.getId()); - assertEquals(newType, material.getMaterialType()); - assertEquals(type, material.getHDF5LWRTag()); - - // Instantiate material with erroneous name and type - check defaults - material = new Material(null, null); - assertEquals(defaultName, material.getName()); // defaults - assertEquals(defaultDesc, material.getDescription()); - assertEquals(defaultId, material.getId()); - assertEquals(defaultType, material.getMaterialType()); // defaults - assertEquals(type, material.getHDF5LWRTag()); - - // Instantiate material with erroneous type, but not name - check - // defaults - material = new Material(newName, null); - assertEquals(newName, material.getName()); - assertEquals(defaultDesc, material.getDescription()); - assertEquals(defaultId, material.getId()); - assertEquals(defaultType, material.getMaterialType()); // defaults - assertEquals(type, material.getHDF5LWRTag()); - - // Instantiate material with erroneous name, but not type - check - // defaults - material = new Material(null, newType); - assertEquals(defaultName, material.getName()); // defaults - assertEquals(defaultDesc, material.getDescription()); - assertEquals(defaultId, material.getId()); - assertEquals(newType, material.getMaterialType()); - assertEquals(type, material.getHDF5LWRTag()); - - } - - /** - *

- * This operation checks the getter and setter for materialTypes. - *

- * - */ - @Test - public void checkMaterialType() { - - // Local Declarations - Material material = new Material(); - MaterialType defaultType = MaterialType.SOLID; - - // Check default material type value - assertEquals(defaultType, material.getMaterialType()); - - // Set the material type - SOLID - material.setMaterialType(MaterialType.SOLID); - // Check value - assertEquals(MaterialType.SOLID, material.getMaterialType()); - - // Set the material type - LIQUID - material.setMaterialType(MaterialType.LIQUID); - // Check value - assertEquals(MaterialType.LIQUID, material.getMaterialType()); - - // Set the material type - GAS - material.setMaterialType(MaterialType.GAS); - // Check value - assertEquals(MaterialType.GAS, material.getMaterialType()); - - // Check for null - material.setMaterialType(null); - // See that it is the last set made - // Check value - assertEquals(MaterialType.GAS, material.getMaterialType()); - - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - public void checkEquality() { - - // Local Declarations - Material object, equalObject, unEqualObject, transitiveObject; - String name = "Bill"; - MaterialType type = MaterialType.GAS; - MaterialType unEqualType = MaterialType.LIQUID; - String description = "Description !@#!@#!@#!46546484328"; - int id = 68468431; - - // Setup root object - object = new Material(name); - object.setId(id); - object.setDescription(description); - object.setMaterialType(type); - - // Setup equalObject equal to object - equalObject = new Material(name); - equalObject.setId(id); - equalObject.setDescription(description); - equalObject.setMaterialType(type); - - // Setup transitiveObject equal to object - transitiveObject = new Material(name); - transitiveObject.setId(id); - transitiveObject.setDescription(description); - transitiveObject.setMaterialType(type); - - // Set its data, not equal to object - // Does not contain components! - unEqualObject = new Material(name); - unEqualObject.setId(id); - unEqualObject.setDescription(description); - unEqualObject.setMaterialType(unEqualType); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - public void checkCopying() { - - // Local declarations - Material object, copyObject, clonedObject; - String name = "Bill"; - MaterialType type = MaterialType.GAS; - String description = "Description !@#!@#!@#!46546484328"; - int id = 68468431; - - // Setup root object - object = new Material(name); - object.setId(id); - object.setDescription(description); - object.setMaterialType(type); - - // Run the copy routine - copyObject = new Material(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (Material) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - Material component = new Material(); - String name = "Materials"; - String description = "Materials don't say anything"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - MaterialType type = component.getMaterialType(); - String testFileName = "testWrite.h5"; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNull(component.getWriteableChildren()); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(component.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(5, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - - // Check String Attribute - material type - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "materialType"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(type.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(component.writeAttributes(null, h5Group)); - assertFalse(component.writeAttributes(h5File, null)); - - // Check dataSet. - assertFalse(component.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = component.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root component - assertEquals(component.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - Material component = new Material(); - Material newComponent = new Material("NOT A DEFAULT ONE"); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - MaterialType type = MaterialType.GAS; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setMaterialType(type); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check Readable Children - assertTrue(component.readChild(null)); - - // Setup LWRComponent with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup Material attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "materialType", type.toString()); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5 file! - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * Checks the toString and toType operations on MaterialType. - *

- * - */ - @Test - public void checkTyping() { - - // Local Declarations - MaterialType type; - - // Check the toString implementations of the materialType enum - assertEquals("Gas", MaterialType.GAS.toString()); - assertEquals("Solid", MaterialType.SOLID.toString()); - assertEquals("Liquid", MaterialType.LIQUID.toString()); - - // Check the toType implementations of the HDf5 enum - - // Specify the type - type = MaterialType.GAS; - // Check the type - assertEquals(type.toType("Gas"), MaterialType.GAS); - - // Specify the type - type = MaterialType.LIQUID; - // Check the type - assertEquals(type.toType("Liquid"), MaterialType.LIQUID); - - // Specify the type - type = MaterialType.SOLID; - // Check the type - assertEquals(type.toType("Solid"), MaterialType.SOLID); - - // Try to return a type that does not exist - assertEquals(type.toType("asdasd1"), null); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/RingTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/RingTester.java deleted file mode 100644 index a07a225b6..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/RingTester.java +++ /dev/null @@ -1,836 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.Material; -import org.eclipse.ice.reactor.MaterialType; -import org.eclipse.ice.reactor.Ring; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * A class that tests the Ring's operations. - *

- * - * @author Scott Forest Hull II - */ - -public class RingTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declarations - Ring ring; - // Default values. Change here as needed for tests - String defaultName = "Ring"; - String defaultDesc = "Ring's Description"; - int defaultId = 1; - double defaultInnerRadius = 0; - double defaultOuterRadius = 1; - double defaultHeight = 1.0; - HDF5LWRTagType type = HDF5LWRTagType.RING; - - // New values - String newName = "Super Ring!"; - Material newMaterial = new Material(); - newMaterial.setName("SuperMaterial!!@#!@#*!@#!"); - double newHeight = 1.51231541513; - double newOuterRadius = 86.3985656; - double newInnerRadius = 5.83495787819; - - // Check nullary constructor - ring = new Ring(); - // Check default values - assertEquals(defaultName, ring.getName()); - assertEquals(defaultDesc, ring.getDescription()); - assertEquals(defaultId, ring.getId()); - assertEquals(defaultInnerRadius, ring.getInnerRadius(), 0.0); - assertEquals(defaultOuterRadius, ring.getOuterRadius(), 0.0); - assertEquals(defaultHeight, ring.getHeight(), 0.0); - assertNotNull(ring.getMaterial()); - assertEquals(type, ring.getHDF5LWRTag()); - - // Check non-nullary constructor - name - ring = new Ring(newName); - // Check default values - assertEquals(newName, ring.getName()); - assertEquals(defaultDesc, ring.getDescription()); - assertEquals(defaultId, ring.getId()); - assertEquals(defaultInnerRadius, ring.getInnerRadius(), 0.0); - assertEquals(defaultOuterRadius, ring.getOuterRadius(), 0.0); - assertEquals(defaultHeight, ring.getHeight(), 0.0); - assertNotNull(ring.getMaterial()); - assertEquals(type, ring.getHDF5LWRTag()); - - // Check non-nullary constructor - name with null - ring = new Ring(null); - // Check default values - assertEquals(defaultName, ring.getName()); // Defaults name - assertEquals(defaultDesc, ring.getDescription()); - assertEquals(defaultId, ring.getId()); - assertEquals(defaultInnerRadius, ring.getInnerRadius(), 0.0); - assertEquals(defaultOuterRadius, ring.getOuterRadius(), 0.0); - assertEquals(defaultHeight, ring.getHeight(), 0.0); - assertNotNull(ring.getMaterial()); - assertEquals(type, ring.getHDF5LWRTag()); - - // Check non-nullary constructor - name, material, height, outerRadius - ring = new Ring(newName, newMaterial, newHeight, newOuterRadius); - // Check default values - assertEquals(newName, ring.getName()); - assertEquals(defaultDesc, ring.getDescription()); - assertEquals(defaultId, ring.getId()); - assertEquals(defaultInnerRadius, ring.getInnerRadius(), 0.0); - assertEquals(newOuterRadius, ring.getOuterRadius(), 0.0); - assertEquals(newHeight, ring.getHeight(), 0.0); - assertNotNull(ring.getMaterial()); - assertEquals(newMaterial.getName(), ring.getMaterial().getName()); - assertEquals(type, ring.getHDF5LWRTag()); - - // Check non-nullary constructor - name, material, height, innerRadius, - // outerRadius - ring = new Ring(newName, newMaterial, newHeight, newInnerRadius, - newOuterRadius); - // Check default values - assertEquals(newName, ring.getName()); - assertEquals(defaultDesc, ring.getDescription()); - assertEquals(defaultId, ring.getId()); - assertEquals(newInnerRadius, ring.getInnerRadius(), 0.0); - assertEquals(newOuterRadius, ring.getOuterRadius(), 0.0); - assertEquals(newHeight, ring.getHeight(), 0.0); - assertNotNull(ring.getMaterial()); - assertEquals(newMaterial.getName(), ring.getMaterial().getName()); - assertEquals(type, ring.getHDF5LWRTag()); - - // Check nullaries - check name - ring = new Ring(null, newMaterial, newHeight, newOuterRadius); - assertEquals(defaultName, ring.getName()); // Defaults name - - // Check nullaries - check material - ring = new Ring(newName, null, newHeight, newOuterRadius); - assertNotNull(ring.getMaterial()); // Still generates a material - - // Check nullaries - check height - ring = new Ring(null, newMaterial, 0.0, newOuterRadius); - assertEquals(defaultHeight, ring.getHeight(), 0.0); // Defaults height - - // Check bad values - check outer radius - ring = new Ring(newName, newMaterial, 1.0, 0.0); - assertEquals(defaultOuterRadius, ring.getOuterRadius(), 0.0); // Defaults - // radius - - // Check bad values - check inner radius - ring = new Ring(newName, newMaterial, newHeight, -1.0, newOuterRadius); - assertEquals(defaultInnerRadius, ring.getInnerRadius(), 0.0); // Defaults - // radius - assertEquals(type, ring.getHDF5LWRTag()); - - } - - /** - *

- * This operation checks the implementation of the Comparable interface. - *

- * - */ - @Test - public void checkCompareTo() { - - // Local declarations - // Declare comparable constants - final int BEFORE = -1; - final int AFTER = 1; - final int EQUAL = 0; - - // Create a test ring - Ring ring = new Ring(); - ring.setOuterRadius(6); - ring.setInnerRadius(5); - - // Create and test a "after" ring - Ring ring1 = new Ring(); - ring1.setOuterRadius(5); - ring1.setInnerRadius(4); - - // Get the comparison result - int result = ring.compareTo(ring1); - assertEquals(result, AFTER); - - // Create and test an "before" ring - Ring ring2 = new Ring(); - ring2.setOuterRadius(7); - ring2.setInnerRadius(6); - - // Get the comparison result - result = ring.compareTo(ring2); - assertEquals(result, BEFORE); - - // Create and test an "equal" ring with both radii overlapping - Ring ring3 = new Ring(); - ring3.setOuterRadius(7); - ring3.setInnerRadius(4); - - // Get the comparison result - result = ring.compareTo(ring3); - assertEquals(result, EQUAL); - - // Create and test an "equal" ring with an overlapping inner radius - Ring ring4 = new Ring(); - ring4.setOuterRadius(7); - ring4.setInnerRadius(5.5); - - // Get the comparison result - result = ring.compareTo(ring4); - assertEquals(result, EQUAL); - - // Create and test an "equal" ring with an overlapping outer radius - Ring ring5 = new Ring(); - ring5.setOuterRadius(5.5); - ring5.setInnerRadius(4); - - // Get the comparison result - result = ring.compareTo(ring5); - assertEquals(result, EQUAL); - - } - - /** - *

- * This operation checks the getter and setter for the height. - *

- * - */ - @Test - public void checkHeight() { - // Local declarations - Ring ring = new Ring(); - - // Check setter - legal value - ring.setHeight(5.0); - assertEquals(5.0, ring.getHeight(), 0.0); - - // Check for illegal value - 0 - ring.setHeight(0.0); - assertEquals(5.0, ring.getHeight(), 0.0); - - // Check for illegal value - negative - ring.setHeight(-1.0); - assertEquals(5.0, ring.getHeight(), 0.0); - - } - - /** - *

- * This operation checks the getter and setter for the InnerRadius. - *

- * - */ - @Test - public void checkInnerRadius() { - // Local declarations - Ring ring = new Ring(); - - // Check setter - legal value - ring.setOuterRadius(20.0); - ring.setInnerRadius(3.3453453); - assertEquals(3.3453453, ring.getInnerRadius(), 0.0); - - // Check setter - legal value of 0 - ring.setInnerRadius(0.0); - assertEquals(0.0, ring.getInnerRadius(), 0.0); - - // Check illegal value - negative - ring.setInnerRadius(-1.0); - assertEquals(0.0, ring.getInnerRadius(), 0.0); // stays the same as - // before - - // Inner radius can not be greater than or equal to outer radius - ring.setInnerRadius(20.0); - assertEquals(0.0, ring.getInnerRadius(), 0.0); - - } - - /** - *

- * This operation checks the getter and setter for the outer radius. - *

- * - */ - @Test - public void checkOuterRadius() { - // Local declarations - Ring ring = new Ring(); - - // Check setter - legal value - ring.setOuterRadius(20.0); - ring.setInnerRadius(3.3453453); - assertEquals(20.0, ring.getOuterRadius(), 0.0); - - // Check illegal value of 0 - ring.setOuterRadius(0.0); - assertEquals(20.0, ring.getOuterRadius(), 0.0); - - // Check illegal value - negative - ring.setOuterRadius(-1.0); - assertEquals(20.0, ring.getOuterRadius(), 0.0); // stays the same as - // before - - // Outer radius can not be less than or equal to inner radius - ring.setInnerRadius(1.0); - assertEquals(20.0, ring.getOuterRadius(), 0.0); - - } - - /** - *

- * This operation checks the getter and setter for the Material. - *

- * - */ - @Test - public void checkMaterial() { - - // Local declarations - Ring ring = new Ring(); - Material material = new Material(); - String name = "Bobble123123198796**3213.12313123"; - - // Set name on material - material.setName(name); - - // Set material - ring.setMaterial(material); - - // Check to see if set correctly - assertNotNull(ring.getMaterial()); - // Check the name - assertEquals(name, ring.getMaterial().getName()); - - // Check illegal null argument - ring.setMaterial(null); - - // Check to see if set correctly - Values do not change from erroneous - // commit. - assertNotNull(ring.getMaterial()); - // Check the name - assertEquals(name, ring.getMaterial().getName()); - - } - - /** - *

- * Checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - Ring object, equalObject, unEqualObject, transitiveObject; - String name = "Billy!"; - int id = 654654; - String description = "ASDFG Billy464646"; - Material material = new Material(); - Material unEqualMaterial = new Material(); - unEqualMaterial.setMaterialType(MaterialType.LIQUID); - material.setMaterialType(MaterialType.GAS); - double innerRadius = 5.0, outerRadius = 8, height = 20.0; - - // Setup root object - object = new Ring(name, material, height, innerRadius, outerRadius); - object.setId(id); - object.setDescription(description); - - // Setup equalObject equal to object - equalObject = new Ring(name, material, height, innerRadius, outerRadius); - equalObject.setId(id); - equalObject.setDescription(description); - - // Setup transitiveObject equal to object - transitiveObject = new Ring(name, material, height, innerRadius, - outerRadius); - transitiveObject.setId(id); - transitiveObject.setDescription(description); - - // Set its data, not equal to object - // Different Material - unEqualObject = new Ring(name, unEqualMaterial, height, innerRadius, - outerRadius); - unEqualObject.setId(id); - unEqualObject.setDescription(description); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * Checks the copy and clone routines. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - Ring object, copyObject, clonedObject; - String name = "Billy!"; - int id = 654654; - String description = "ASDFG Billy464646"; - Material material = new Material(); - material.setMaterialType(MaterialType.GAS); - double innerRadius = 5.0, outerRadius = 8, height = 20.0; - - // Setup root object - object = new Ring(name, material, height, innerRadius, outerRadius); - object.setId(id); - object.setDescription(description); - - // Run the copy routine - copyObject = new Ring(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (Ring) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - Ring component = new Ring(); - String name = "Ring"; - String description = "Put a ring on it...?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - Material material = new Material("MATERIAL!S"); - double height = 5, inner = 3, outer = 6; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setMaterial(material); - component.setHeight(height); - component.setOuterRadius(outer); - component.setInnerRadius(inner); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(component.getWriteableChildren()); - - // Check children - assertEquals(1, component.getWriteableChildren().size()); - assertTrue(material.equals(component.getWriteableChildren().get(0))); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(component.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(7, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - height - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "height"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(((double[]) attribute.getValue())[0], 1.2, height); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - - // Check Double Attribute - innerRadius - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "innerRadius"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(((double[]) attribute.getValue())[0], 1.2, inner); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(5); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - outerRadius - attribute = (Attribute) h5Group.getMetadata().get(6); - assertEquals(attribute.getName(), "outerRadius"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(((double[]) attribute.getValue())[0], 1.2, outer); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(component.writeAttributes(null, h5Group)); - assertFalse(component.writeAttributes(h5File, null)); - - // Check dataSet. - assertFalse(component.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = component.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root component - assertEquals(component.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - Ring component = new Ring(); - Ring newComponent = new Ring("NOT A DEFAULT ONE"); - String name = "Ring"; - String description = "Put a ring on it...?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - Material material = new Material("MATERIAL!S"); - double height = 5, inner = 3, outer = 6; - H5Group subGroup = null; - String testFileName = "testWrite.h5"; - - // Test readChild here - assertTrue(component.readChild(material)); - assertFalse(component.readChild(null)); - assertTrue(component.readChild(newComponent)); - assertNotNull(component.getMaterial()); - assertTrue(component.getMaterial().getName().equals(material.getName())); - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setMaterial(material); - component.setHeight(height); - component.setOuterRadius(outer); - component.setInnerRadius(inner); - - newComponent.setMaterial(material); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup LWRComponent with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup height attribute - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, "height", - height); - - // Setup height inner radius - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, - "innerRadius", inner); - - // Setup height outer radius - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, - "outerRadius", outer); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5 file! - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/TubeTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/TubeTester.java deleted file mode 100644 index 2c0ebbdf0..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/TubeTester.java +++ /dev/null @@ -1,754 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.Material; -import org.eclipse.ice.reactor.MaterialType; -import org.eclipse.ice.reactor.Tube; -import org.eclipse.ice.reactor.TubeType; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * A class that tests Tube's operations. - *

- * - * @author Scott Forest Hull II - */ -public class TubeTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declarations - Tube tube; - // Default values. Change here as needed for tests - String defaultName = "Tube"; - String defaultDesc = "Tube's Description"; - int defaultId = 1; - double defaultInnerRadius = 0; - double defaultOuterRadius = 1; - double defaultHeight = 1.0; - TubeType defaultType = TubeType.GUIDE; - Material defaultMaterial = new Material(); - HDF5LWRTagType type = HDF5LWRTagType.TUBE; - - // New values - String newName = "Super Tube!"; - Material newMaterial = new Material(); - newMaterial.setName("SuperMaterial!!@#!@#*!@#!"); - double newHeight = 1.51231541513; - double newOuterRadius = 86.3985656; - double newInnerRadius = 5.83495787819; - TubeType newType = TubeType.INSTRUMENT; - - // Check nullary constructor - tube = new Tube(); - // Check default values - assertEquals(defaultName, tube.getName()); - assertEquals(defaultDesc, tube.getDescription()); - assertEquals(defaultId, tube.getId()); - assertEquals(defaultInnerRadius, tube.getInnerRadius(), 0.0); - assertEquals(defaultOuterRadius, tube.getOuterRadius(), 0.0); - assertEquals(defaultHeight, tube.getHeight(), 0.0); - assertNotNull(tube.getMaterial()); - assertEquals(defaultType, tube.getTubeType()); - assertEquals(type, tube.getHDF5LWRTag()); - - // Check non-nullary constructor - name - tube = new Tube(newName); - // Check default values - assertEquals(newName, tube.getName()); - assertEquals(defaultDesc, tube.getDescription()); - assertEquals(defaultId, tube.getId()); - assertEquals(defaultInnerRadius, tube.getInnerRadius(), 0.0); - assertEquals(defaultOuterRadius, tube.getOuterRadius(), 0.0); - assertEquals(defaultHeight, tube.getHeight(), 0.0); - assertNotNull(tube.getMaterial()); - assertEquals(defaultType, tube.getTubeType()); - assertEquals(type, tube.getHDF5LWRTag()); - - // Check non-nullary constructor - name with null - tube = new Tube(null); - // Check default values - assertEquals(defaultName, tube.getName()); // Defaults name - assertEquals(defaultDesc, tube.getDescription()); - assertEquals(defaultId, tube.getId()); - assertEquals(defaultInnerRadius, tube.getInnerRadius(), 0.0); - assertEquals(defaultOuterRadius, tube.getOuterRadius(), 0.0); - assertEquals(defaultHeight, tube.getHeight(), 0.0); - assertNotNull(tube.getMaterial()); - assertEquals(defaultType, tube.getTubeType()); - assertEquals(type, tube.getHDF5LWRTag()); - - // Check non-nullary constructor - name and type - tube = new Tube(newName, newType); - // Check default values - assertEquals(newName, tube.getName()); - assertEquals(defaultDesc, tube.getDescription()); - assertEquals(defaultId, tube.getId()); - assertEquals(defaultInnerRadius, tube.getInnerRadius(), 0.0); - assertEquals(defaultOuterRadius, tube.getOuterRadius(), 0.0); - assertEquals(defaultHeight, tube.getHeight(), 0.0); - assertNotNull(tube.getMaterial()); - assertEquals(newType, tube.getTubeType()); - assertEquals(type, tube.getHDF5LWRTag()); - - // Check nullary type - type is null - tube = new Tube(newName, null); - // Check default values - assertEquals(newName, tube.getName()); - assertEquals(defaultDesc, tube.getDescription()); - assertEquals(defaultId, tube.getId()); - assertEquals(defaultInnerRadius, tube.getInnerRadius(), 0.0); - assertEquals(defaultOuterRadius, tube.getOuterRadius(), 0.0); - assertEquals(defaultHeight, tube.getHeight(), 0.0); - assertNotNull(tube.getMaterial()); - assertEquals(defaultType, tube.getTubeType()); // Defaults - assertEquals(type, tube.getHDF5LWRTag()); - - // Check non-nullary constructor - name, tubetype, material, height, - // outerRadius - tube = new Tube(newName, newType, newMaterial, newHeight, - newOuterRadius); - // Check default values - assertEquals(newName, tube.getName()); - assertEquals(defaultDesc, tube.getDescription()); - assertEquals(defaultId, tube.getId()); - assertEquals(defaultInnerRadius, tube.getInnerRadius(), 0.0); - assertEquals(newOuterRadius, tube.getOuterRadius(), 0.0); - assertEquals(newHeight, tube.getHeight(), 0.0); - assertNotNull(tube.getMaterial()); - assertEquals(newMaterial.getName(), tube.getMaterial().getName()); - assertEquals(newType, tube.getTubeType()); - assertEquals(type, tube.getHDF5LWRTag()); - - // Check non-nullary constructor - null material - tube = new Tube(newName, newType, null, newHeight, newOuterRadius); - // See that it defaults the value - assertNotNull(tube.getMaterial()); // Defaults - - // Check non-nullary constructor - bad height - tube = new Tube(newName, newType, newMaterial, 0.0, newOuterRadius); - // See that it defaults the value - assertEquals(defaultHeight, tube.getHeight(), 0.0); // Defaults - - // Check non-nullary constructor - bad outerRadius - tube = new Tube(newName, newType, newMaterial, newHeight, 0.0); - // See that it defaults the value - assertEquals(defaultOuterRadius, tube.getOuterRadius(), 0.0); // Defaults - - // Check non-nullary constructor - name, tubetype, material, height, - // innerRadius, outerRadius - tube = new Tube(newName, newType, newMaterial, newHeight, - newInnerRadius, newOuterRadius); - // Check default values - assertEquals(newName, tube.getName()); - assertEquals(defaultDesc, tube.getDescription()); - assertEquals(defaultId, tube.getId()); - assertEquals(newInnerRadius, tube.getInnerRadius(), 0.0); - assertEquals(newOuterRadius, tube.getOuterRadius(), 0.0); - assertEquals(newHeight, tube.getHeight(), 0.0); - assertNotNull(tube.getMaterial()); - assertEquals(newMaterial.getName(), tube.getMaterial().getName()); - assertEquals(newType, tube.getTubeType()); - assertEquals(type, tube.getHDF5LWRTag()); - - // Check non-nullary constructor - bad innerRadius - tube = new Tube(newName, newType, newMaterial, newHeight, -1.0, - newOuterRadius); - // See that it defaults the value - assertEquals(defaultInnerRadius, tube.getInnerRadius(), 0.0); // Defaults - - } - - /** - *

- * This operation checks the getter and setter for the tubeTypes. - *

- * - */ - @Test - public void checkTubeType() { - // Local Declarations - Tube tube = new Tube(); - - // Check valid usage of tube type - GUIDE - tube.setTubeType(TubeType.GUIDE); - assertEquals(TubeType.GUIDE, tube.getTubeType()); - - // Check valid usage of tube type -INSTRUMENT - tube.setTubeType(TubeType.INSTRUMENT); - assertEquals(TubeType.INSTRUMENT, tube.getTubeType()); - - // Check invalid usage - null - tube.setTubeType(null); - assertEquals(TubeType.INSTRUMENT, tube.getTubeType()); // Stays the same - // as previous - // value - - } - - /** - *

- * Checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - Tube object, equalObject, unEqualObject, transitiveObject; - String name = "Billy!"; - int id = 654654; - String description = "ASDFG Billy464646"; - Material material = new Material(); - TubeType type = TubeType.INSTRUMENT; - TubeType unEqualTubeType = TubeType.GUIDE; - material.setMaterialType(MaterialType.GAS); - double innerRadius = 5.0, outerRadius = 8, height = 20.0; - - // Setup root object - object = new Tube(name, type, material, height, innerRadius, - outerRadius); - object.setId(id); - object.setDescription(description); - - // Setup equalObject equal to object - equalObject = new Tube(name, type, material, height, innerRadius, - outerRadius); - equalObject.setId(id); - equalObject.setDescription(description); - - // Setup transitiveObject equal to object - transitiveObject = new Tube(name, type, material, height, innerRadius, - outerRadius); - transitiveObject.setId(id); - transitiveObject.setDescription(description); - - // Set its data, not equal to object - // Different Material - unEqualObject = new Tube(name, unEqualTubeType, material, height, - innerRadius, outerRadius); - unEqualObject.setId(id); - unEqualObject.setDescription(description); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - } - - /** - *

- * Checks the copy and clone routines. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - Tube object, copyObject, clonedObject; - String name = "Billy!"; - int id = 654654; - String description = "ASDFG Billy464646"; - Material material = new Material(); - TubeType type = TubeType.INSTRUMENT; - material.setMaterialType(MaterialType.GAS); - double innerRadius = 5.0, outerRadius = 8, height = 20.0; - - // Setup root object - object = new Tube(name, type, material, height, innerRadius, - outerRadius); - object.setId(id); - object.setDescription(description); - - // Run the copy routine - copyObject = new Tube(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (Tube) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - Tube component = new Tube(); - String name = "Tube"; - String description = "Put a ring on it...'tube'? :)"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - Material material = new Material("MATERIAL!S"); - double height = 5, inner = 3, outer = 6; - TubeType type = component.getTubeType(); - String testFileName = "testWrite.h5"; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setMaterial(material); - component.setHeight(height); - component.setOuterRadius(outer); - component.setInnerRadius(inner); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(component.getWriteableChildren()); - - // Check children - assertEquals(1, component.getWriteableChildren().size()); - assertTrue(material.equals(component.getWriteableChildren().get(0))); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(component.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(8, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - height - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "height"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(((double[]) attribute.getValue())[0], 1.2, height); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - - // Check Double Attribute - innerRadius - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "innerRadius"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(((double[]) attribute.getValue())[0], 1.2, inner); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(5); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - outerRadius - attribute = (Attribute) h5Group.getMetadata().get(6); - assertEquals(attribute.getName(), "outerRadius"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(((double[]) attribute.getValue())[0], 1.2, outer); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - tube type - attribute = (Attribute) h5Group.getMetadata().get(7); - assertEquals(attribute.getName(), "tubeType"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(type.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(component.writeAttributes(null, h5Group)); - assertFalse(component.writeAttributes(h5File, null)); - - // Check dataSet. - assertFalse(component.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = component.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root component - assertEquals(component.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - Tube component = new Tube(); - Tube newComponent = new Tube(); - String name = "TUBULAR!?"; - String description = "Put a ring on it...'tube'? :)"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - Material material = new Material("MATERIAL!S"); - double height = 5, inner = 3, outer = 6; - TubeType type = component.getTubeType(); - H5Group subGroup = null; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setMaterial(material); - component.setHeight(height); - component.setOuterRadius(outer); - component.setInnerRadius(inner); - - // Temporary - newComponent.setMaterial(material); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup LWRComponent with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup height attribute - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, "height", - height); - - // Setup height inner radius - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, - "innerRadius", inner); - - // Setup height outer radius - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, - "outerRadius", outer); - - // Setup tube type - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "tubeType", - type.toString()); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5 file! - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * Checks the toString and toType operations on MaterialType. - *

- * - */ - @Test - public void checkTyping() { - - // Local Declarations - TubeType type; - - // Check the toString implementations of the TubeType enum - assertEquals("Guide", TubeType.GUIDE.toString()); - assertEquals("Instrument", TubeType.INSTRUMENT.toString()); - - // Check the toType implementations of the HDf5 enum - - // Specify the type - type = TubeType.GUIDE; - // Check the type - assertEquals(type.toType("Guide"), TubeType.GUIDE); - - // Specify the type - type = TubeType.INSTRUMENT; - // Check the type - assertEquals(type.toType("Instrument"), TubeType.INSTRUMENT); - - // Try to return a type that does not exist - assertEquals(type.toType("asdasd1"), null); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/bwr/BWReactorTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/bwr/BWReactorTester.java deleted file mode 100644 index e024e487d..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/bwr/BWReactorTester.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.bwr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.bwr.BWReactor; -import org.junit.Test; - -/** - *

- * A class that tests the BWReactor. - *

- * - * @author Scott Forest Hull II - */ -public class BWReactorTester { - /** - *

- * This operation checks the constructor and it's default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declarations - BWReactor reactor; - String defaultName = "BWReactor 1"; - String defaultDescription = "BWReactor 1's Description"; - int defaultId = 1; - int defaultSize = 1; - HDF5LWRTagType type = HDF5LWRTagType.BWREACTOR; - - // This test is to show the default value for a reactor when it is - // created with a negative value. - reactor = new BWReactor(-1); - assertEquals(defaultSize, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(type, reactor.getHDF5LWRTag()); - - // This test is to show the default value for a reactor when its created - // with a zero value - reactor = new BWReactor(0); - assertEquals(defaultSize, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(type, reactor.getHDF5LWRTag()); - - // This is a test to show a valid creation of a reactor - reactor = new BWReactor(17); - assertEquals(17, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(type, reactor.getHDF5LWRTag()); - - } - - /** - *

- * This operation checks equals() and hashCode() operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - BWReactor object, equalObject, unEqualObject, transitiveObject; - int size = 5; - int unEqualSize = 7; - - // Setup root object - object = new BWReactor(size); - - // Setup equalObject equal to object - equalObject = new BWReactor(size); - - // Setup transitiveObject equal to object - transitiveObject = new BWReactor(size); - - // Set its data, not equal to object - unEqualObject = new BWReactor(unEqualSize); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copy and clone routines. - *

- * - */ - @Test - public void checkCopying() { - - // Local declarations - BWReactor object; - BWReactor copyObject = new BWReactor(0), clonedObject; - - int size = 5; - - // Setup root object - object = new BWReactor(size); - - // Run the copy routine - copyObject = new BWReactor(0); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (BWReactor) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/ControlBankTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/ControlBankTester.java deleted file mode 100644 index 41667cc3b..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/ControlBankTester.java +++ /dev/null @@ -1,631 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.pwr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.pwr.ControlBank; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class tests the ControlBank class. - *

- * - * @author Scott Forest Hull II - */ -public class ControlBankTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declarations - ControlBank controlBank; - // Default Values - String defaultName = "ControlBank 1"; - String defaultDesc = "Default Control Bank"; - int defaultId = 1; - double defaultStepSize = 0.0; - int defaultMaxNumberOfSteps = 1; - HDF5LWRTagType type = HDF5LWRTagType.CONTROL_BANK; - - // New Values - String newName = "ControlBank 2"; - double newStepSize = 10.0; - int newMaxNumberOfSteps = 100; - - // Check nullary constructor - controlBank = new ControlBank(); - assertEquals(defaultName, controlBank.getName()); - assertEquals(defaultStepSize, controlBank.getStepSize(), 0.0); - assertEquals(defaultMaxNumberOfSteps, controlBank.getMaxNumberOfSteps()); - assertEquals(defaultId, controlBank.getId()); - assertEquals(defaultDesc, controlBank.getDescription()); - assertEquals(type, controlBank.getHDF5LWRTag()); - - // Check non-nullary constructor - controlBank = new ControlBank(newName, newStepSize, newMaxNumberOfSteps); - assertEquals(newName, controlBank.getName()); - assertEquals(newStepSize, controlBank.getStepSize(), 0.0); - assertEquals(newMaxNumberOfSteps, controlBank.getMaxNumberOfSteps()); - assertEquals(type, controlBank.getHDF5LWRTag()); - - // Check non-nullary constructor for illegal values - controlBank = new ControlBank(null, -1.0, -1); - assertEquals(defaultName, controlBank.getName()); - assertEquals(defaultStepSize, controlBank.getStepSize(), 0.0); - assertEquals(defaultMaxNumberOfSteps, controlBank.getMaxNumberOfSteps()); - assertEquals(type, controlBank.getHDF5LWRTag()); - - // Check non-nullary constructor for 0 value of MaxNumberOfSteps - controlBank = new ControlBank(newName, newStepSize, 0); - assertEquals(newName, controlBank.getName()); - assertEquals(newStepSize, controlBank.getStepSize(), 0.0); - assertEquals(defaultMaxNumberOfSteps, controlBank.getMaxNumberOfSteps()); - assertEquals(type, controlBank.getHDF5LWRTag()); - - } - - /** - *

- * This operation checks the getter and setter for the stepSize. - *

- * - */ - @Test - public void checkStepSize() { - // Local Declarations - ControlBank controlBank = new ControlBank(); - - // Set the size to 0 - controlBank.setStepSize(0.0); - - // This checks a valid return after the step size is set - assertEquals(0.0, controlBank.getStepSize(), 0.0); - - // Pass an invalid number: negative - controlBank.setStepSize(-1.0); - - // Should not change the previous value. - assertEquals(0.0, controlBank.getStepSize(), 0.0); - - // Test a valid length - controlBank.setStepSize(10.0); - - // Should set correct value. - assertEquals(10.0, controlBank.getStepSize(), 0.0); - - } - - /** - *

- * This operation checks the getter and setter for the maxNumberOfSteps - *

- * - */ - @Test - public void checkMaxNumberOfSteps() { - // Local Declarations - ControlBank controlBank = new ControlBank(); - - // Set the Max Step Size to default - controlBank.setMaxNumberOfSteps(1); - - // This checks a valid return after the Max step size is set - assertEquals(1, controlBank.getMaxNumberOfSteps()); - - // Pass an invalid number: negative - controlBank.setMaxNumberOfSteps(-1); - - // Should not change the previous value. - assertEquals(1, controlBank.getMaxNumberOfSteps()); - - // Test a valid length - controlBank.setMaxNumberOfSteps(10); - - // Should set correct value. - assertEquals(10, controlBank.getMaxNumberOfSteps()); - - } - - /** - *

- * This operation checks the getStrokeLength method. - *

- * - */ - @Test - public void checkStrokeLength() { - - // Local Declarations - ControlBank controlBank = new ControlBank(); - - // Checking default values. - assertEquals(1, controlBank.getMaxNumberOfSteps()); - assertEquals(0.0, controlBank.getStepSize(), 0.0); - - // Check valid test - assertEquals(0.0, controlBank.getStrokeLength(), 0.0); - - // Check nonzero - controlBank.setStepSize(100.0); - - // Check valid test - assertEquals(100.0, controlBank.getStrokeLength(), 0.0); - - // Check valid test - decimal - controlBank.setMaxNumberOfSteps(2); - controlBank.setStepSize(50.05); - - // Check valid test - assertEquals(100.1, controlBank.getStrokeLength(), 0.0); - - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - public void checkEquality() { - - // Local Declarations - ControlBank object, equalObject, unEqualObject, transitiveObject; - String name = "CONTROL!"; - double stepSize = 5; - int maxNumberOfSteps = 10; - int unEqualMaxNumberOfSteps = 9; - - // Setup root object - object = new ControlBank(name, stepSize, maxNumberOfSteps); - - // Setup equalObject equal to object - equalObject = new ControlBank(name, stepSize, maxNumberOfSteps); - - // Setup transitiveObject equal to object - transitiveObject = new ControlBank(name, stepSize, maxNumberOfSteps); - - // Set its data, not equal to object - // Does not contain components! - unEqualObject = new ControlBank(name, stepSize, unEqualMaxNumberOfSteps); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - public void checkCopying() { - - // Local Declarations - ControlBank object, copyObject, clonedObject; - String name = "CONTROL!"; - double stepSize = 5; - int maxNumberOfSteps = 10; - - // Setup root object - object = new ControlBank(name, stepSize, maxNumberOfSteps); - - // Run the copy routine - copyObject = new ControlBank(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (ControlBank) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - ControlBank bank = new ControlBank(); - String name = "Control"; - String description = "A controlling controller."; - int id = 4; - HDF5LWRTagType tag = bank.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - double stepSize = 10; - int maxNumberOfSteps = 20; - - // Setup bank - bank.setName(name); - bank.setId(id); - bank.setDescription(description); - bank.setMaxNumberOfSteps(maxNumberOfSteps); - bank.setStepSize(stepSize); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - // Fail here - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNull(bank.getWriteableChildren()); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(bank.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(6, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - maxNumberOfSteps - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "maxNumberOfSteps"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(maxNumberOfSteps, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - stepSize - attribute = (Attribute) h5Group.getMetadata().get(5); - assertEquals(attribute.getName(), "stepSize"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(stepSize, ((double[]) attribute.getValue())[0], 1.2); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(bank.writeAttributes(null, h5Group)); - assertFalse(bank.writeAttributes(h5File, null)); - - // Check dataSet. - assertFalse(bank.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = bank.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root bank - assertEquals(bank.getName(), h5Group.getMemberList().get(0).toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - ControlBank component = new ControlBank(); - ControlBank newComponent = new ControlBank(); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - double stepSize = 3.0; - int maxNumberOfSteps = 15; - String testFileName = "testWrite.h5"; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setMaxNumberOfSteps(maxNumberOfSteps); - component.setStepSize(stepSize); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check Readable Children - - // Setup PWRAssembly with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup stepSize attribute - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, "stepSize", - stepSize); - - // Setup maxNumberOfSteps attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, - "maxNumberOfSteps", maxNumberOfSteps); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Close the h5 file! - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/FuelAssemblyTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/FuelAssemblyTester.java deleted file mode 100644 index 8ffce34a4..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/FuelAssemblyTester.java +++ /dev/null @@ -1,1261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.pwr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.GridLabelProvider; -import org.eclipse.ice.reactor.GridLocation; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRComposite; -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.eclipse.ice.reactor.LWRGridManager; -import org.eclipse.ice.reactor.LWRRod; -import org.eclipse.ice.reactor.Tube; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.RodClusterAssembly; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class tests the operations on FuelAssembly. - *

- * - * @author Scott Forest Hull II - */ -public class FuelAssemblyTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declarations - FuelAssembly assembly; - String defaultName = "FuelAssembly"; - String defaultDesc = "FuelAssembly's Description"; - int defaultId = 1; - int defaultSize = 1; - HDF5LWRTagType type = HDF5LWRTagType.FUEL_ASSEMBLY; - - // New names - String newName = "Super FuelAssembly!"; - int newSize = 10; - - // Check the default constructor with a default size. Check default - // values - // Test non-nullary constructor - size - assembly = new FuelAssembly(defaultSize); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with new size - // Test non-nullary constructor - size - assembly = new FuelAssembly(newSize); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(newSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with bad size - negative - // Test non-nullary constructor - size - assembly = new FuelAssembly(-1); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); // Defaults - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with name and size - // Test non-nullary constructor - name, size - assembly = new FuelAssembly(defaultName, defaultSize); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with bad name - // Test non-nullary constructor - name, size - assembly = new FuelAssembly(null, defaultSize); - // Check values - assertEquals(defaultName, assembly.getName()); // Defaults - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with new name and size - // Test non-nullary constructor - name, size - assembly = new FuelAssembly(newName, newSize); - // Check values - assertEquals(newName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(newSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - } - - /** - *

- * This operation checks the operations for the GridLabelProvider. - *

- * - */ - @Test - public void checkLabels() { - // Local Declarations - FuelAssembly assembly = null; - ArrayList rowLabels = new ArrayList(); - ArrayList colLabels = new ArrayList(); - GridLabelProvider provider; - int assemblySize = 5; - - // Set the rowLabels - rowLabels.add("1"); - rowLabels.add("2"); - rowLabels.add("3"); - rowLabels.add("4"); - rowLabels.add("5"); - - // Set the colLabels - colLabels.add("A"); - colLabels.add("B"); - colLabels.add("C"); - colLabels.add("D"); - colLabels.add("E"); - - // Make a new assembly - assembly = new FuelAssembly(assemblySize); - // Check to see the default's gridLabelprovider - assertEquals(-1, assembly.getGridLabelProvider() - .getColumnFromLabel("A")); - assertEquals(assemblySize, assembly.getGridLabelProvider().getSize()); // Size - // the - // same - // as - // assembly. - // Very - // important! - - // Check default values for gridlabelprovider - provider = new GridLabelProvider(assemblySize); - // Adding the column and row labels - provider.setColumnLabels(colLabels); - provider.setRowLabels(rowLabels); - assembly.setGridLabelProvider(provider); - - // Check the row and column labels - assertTrue(this - .doLabelsMatchLabelsInAssembly(true, rowLabels, assembly)); - assertTrue(this.doLabelsMatchLabelsInAssembly(false, colLabels, - assembly)); - - // You can not set it to null or illegal size - assembly.setGridLabelProvider(null); - - // Check the row and column labels - assertTrue(this - .doLabelsMatchLabelsInAssembly(true, rowLabels, assembly)); - assertTrue(this.doLabelsMatchLabelsInAssembly(false, colLabels, - assembly)); - - assembly.setGridLabelProvider(new GridLabelProvider(assemblySize + 22)); - - // Stays the same as before - // Check the row and column labels - assertTrue(this - .doLabelsMatchLabelsInAssembly(true, rowLabels, assembly)); - assertTrue(this.doLabelsMatchLabelsInAssembly(false, colLabels, - assembly)); - - } - - /** - *

- * This operation checks the getters and setters for tube. - *

- * - */ - @Test - public void checkTube() { - // Local Declarations - int assemblySize = 17; - FuelAssembly assembly = new FuelAssembly(assemblySize); - Tube testComponent = new Tube(), testComponent2 = new Tube(), testComponent3 = new Tube(); - String testComponentName = "Bob"; - String testComponentName2 = "Bill!"; - int rowLoc1 = 5, colLoc1 = 5; - int rowLoc2 = 6, colLoc2 = 6; - int testComponentId = 1000001; - - // Check the default values of the Component under test - assembly = new FuelAssembly(assemblySize); - - // No tubes should be added by default. Therefore every - // location is bad - for (int i = 0; i < assemblySize; i++) { - for (int j = 0; j < assemblySize; j++) { - assertNull(assembly.getTubeByLocation(i, j)); - } - } - - // Check the names, should be empty! - assertEquals(0, assembly.getTubeNames().size()); - - // Try to get by name - valid string, empty string, and null - assertNull(assembly - .getTubeByName("validNameThatDoesNotExistInThere152423")); - assertNull(assembly.getTubeByName("")); - assertNull(assembly.getTubeByName(null)); - - // Set the name - testComponent.setName(testComponentName); - - // Add to the assembly - assembly.addTube(testComponent); - - // See that no location is set - assertNull(assembly.getTubeByLocation(rowLoc1, colLoc1)); - // Check locations to be within bounds - assertNull(assembly.getTubeByLocation(-1, assemblySize - 1)); - assertNull(assembly.getTubeByLocation(1, assemblySize - 1)); - assertNull(assembly.getTubeByLocation(assemblySize + 25, - assemblySize - 1)); - assertNull(assembly.getTubeByLocation(assemblySize - 1, - assemblySize + 25)); - - // Set the valid location: - assertTrue(assembly - .setTubeLocation(testComponentName, rowLoc1, colLoc1)); - - // Try to break location setter - assertFalse(assembly.setTubeLocation(null, rowLoc1, colLoc1)); - assertFalse(assembly.setTubeLocation(testComponentName, -1, colLoc1)); - assertFalse(assembly.setTubeLocation(testComponentName, rowLoc1, -1)); - assertFalse(assembly.setTubeLocation(null, -1, colLoc1)); - assertFalse(assembly.setTubeLocation(null, rowLoc1, -1)); - assertFalse(assembly.setTubeLocation(null, -1, -1)); - assertFalse(assembly.setTubeLocation(testComponentName, rowLoc1, - assemblySize + 25)); - assertFalse(assembly.setTubeLocation(testComponentName, - assemblySize + 25, colLoc1)); - - // The above erroneous settings does not change the original location of - // the first, valid set - assertTrue(testComponent.equals(assembly - .getTubeByName(testComponentName))); - - // Check invalid overwrite of location: - testComponent2.setName(testComponentName2); - - // Add assembly, overwrite the previous testComponent's location - assertFalse(assembly.setTubeLocation(testComponent2.getName(), rowLoc1, - colLoc1)); - - // Check that it is the first, but not second - assertTrue(testComponent.equals(assembly - .getTubeByName(testComponentName))); - - // Add it in there - assertTrue(assembly.addTube(testComponent2)); - - // Show that you can have at least 2 components in there - assertTrue(assembly.setTubeLocation(testComponent2.getName(), rowLoc2, - colLoc2)); - - // Check values - see the components are different and they reside in - // the table correctly - assertTrue(testComponent.equals(assembly - .getTubeByName(testComponentName))); - assertTrue(testComponent2.equals(assembly - .getTubeByName(testComponentName2))); - - // Check the locations - assertTrue(testComponent.equals(assembly.getTubeByLocation(rowLoc1, - colLoc1))); - assertTrue(testComponent2.equals(assembly.getTubeByLocation(rowLoc2, - colLoc2))); - - // Check the names, should contain 2! - assertEquals(2, assembly.getTubeNames().size()); - assertEquals(testComponentName, assembly.getTubeNames().get(0)); - assertEquals(testComponentName2, assembly.getTubeNames().get(1)); - - // Check operation for null - assembly.addTube(null); - assertNull(assembly.getTubeByName(null)); // Make sure null does - // not work! - - // Finally, demonstrate what happens when a component of the same name - // is added, it should not overwrite the previous item in the table! - testComponent3.setName(testComponent.getName()); // Same name as the - // other - // component - testComponent3.setId(testComponentId); // Id should differ from - // testComponent! - assertFalse(testComponent.getId() == testComponentId); - - // Overwrite in table - assertFalse(assembly.addTube(testComponent3)); - - // Check that the object has not been overwritten - assertTrue(testComponent.equals(assembly - .getTubeByName(testComponentName))); - assertFalse(testComponent3.equals(assembly - .getTubeByName(testComponentName))); - - // Test to remove components from the assembly - assertFalse(assembly.removeTube(null)); - assertFalse(assembly.removeTube("")); - assertFalse(assembly - .removeTube("!--+ANamETHaTDoESNOTEXIST19674376393<><(@#*)%^")); - - // Remove the first component - assertTrue(assembly.removeTube(testComponent.getName())); - - // Check that it does not exist in the location or getting the name - assertNull(assembly.getTubeByLocation(rowLoc1, colLoc1)); - assertNull(assembly.getTubeByName(testComponent.getName())); - // Check size - assertEquals(1, assembly.getNumberOfTubes()); - - // It can now be overridden! - assertTrue(assembly.setTubeLocation(testComponent2.getName(), rowLoc1, - colLoc1)); - - // Show that the component's names can NOT overwrite each others - // locations - assertTrue(assembly.addTube(testComponent)); - assertFalse(assembly.setTubeLocation(testComponent.getName(), rowLoc1, - colLoc1)); - - // Check the size, the respective locations - assertEquals(testComponent2.getName(), - assembly.getTubeByLocation(rowLoc1, colLoc1).getName()); - assertEquals(testComponent2.getName(), - assembly.getTubeByLocation(rowLoc2, colLoc2).getName()); - assertEquals(2, assembly.getNumberOfTubes()); - - } - - /** - *

- * This operation checks the getter and setter for rodClusterAssembly. - *

- * - */ - @Test - public void checkRodClusterAssembly() { - // Local Declarations - RodClusterAssembly newRod = new RodClusterAssembly(1); - FuelAssembly assembly = new FuelAssembly(2); - String name = "1231231A rod12313123/*/"; - - // Set the newRod's info - newRod.setName(name); - - // Check the getter on fuel assembly. Show that it is null - assertNull(assembly.getRodClusterAssembly()); - - // Set it - assembly.setRodClusterAssembly(newRod); - // Check that it was created and is the newly created rod - assertEquals(name, assembly.getRodClusterAssembly().getName()); - - // Try to set it to null - assembly.setRodClusterAssembly(null); - - // See that it is null - assertNull(assembly.getRodClusterAssembly()); - - } - - /** - *

- * This operation demonstrates the behaviors listed with the overridden - * composite implementations from LWRComposite. - *

- * - */ - @Test - public void checkCompositeImplementations() { - // Local Declarations - int assemblySize = 17; - FuelAssembly assembly; - ArrayList compNames = new ArrayList(); - ArrayList components = new ArrayList(); - int numberOfDefaultComponents = 0; - - // Defaults for tubeComposite - LWRComposite tubeComposite; - String compName = "Tubes"; - String compDescription = "A Composite that contains many Tubes."; - int compId = 2; - - // Setup LWRRodComposite for comparison - tubeComposite = new LWRComposite(); - tubeComposite.setName(compName); - tubeComposite.setId(compId); - tubeComposite.setDescription(compDescription); - - // Add components to arrays - compNames.add(tubeComposite.getName()); - components.add((Component) tubeComposite); - - // Defaults for rodComposite - LWRComposite rodComposite; - compName = "LWRRods"; - compDescription = "A Composite that contains many LWRRods."; - compId = 1; - - // Setup LWRRodComposite for comparison - rodComposite = new LWRComposite(); - rodComposite.setName(compName); - rodComposite.setId(compId); - rodComposite.setDescription(compDescription); - - // Add component to arrays - compNames.add(rodComposite.getName()); - components.add((Component) rodComposite); - - // Setup the default number of components - numberOfDefaultComponents = components.size(); - - // Check the default Composite size and attributes on PWRAssembly - assembly = new FuelAssembly(assemblySize); - - // Has a size of numberOfDefaultComponents - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - // It is equal to the default rodComposite for many of the composite - // getters - assertTrue(rodComposite.equals(assembly.getComponent(1))); - assertTrue(rodComposite.equals(assembly.getComponent(rodComposite - .getName()))); - - // It is equal to the default tubeComposite for many of the composite - // getters - assertTrue(tubeComposite.equals(assembly.getComponent(2))); - assertTrue(tubeComposite.equals(assembly.getComponent(tubeComposite - .getName()))); - - // Check general getters for the other pieces - assertTrue(compNames.equals(assembly.getComponentNames())); - assertTrue(components.equals(assembly.getComponents())); - - // These operations will show that these will not work for this class - - // Check addComponent - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - assembly.addComponent(new LWRComposite()); - // No size change! - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - - // Check removeComponent - id - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - assembly.removeComponent(1); - // No size change! - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - - // Check remove component - name - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - assembly.removeComponent(components.get(0).getName()); // Try to remove - // the first off - // the list - // No size change! - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - - } - - /** - *

- * This is a utility operation that checks the operations for the labels on - * the assembly to see if they are equal to the passed labels. Keep in mind - * that the first parameter, rows, checks to see if its comparing rows - * (true) or columns (false). Returns true if the labels are equal, false - * otherwise. - *

- * - * @param rows - *

- * True if comparing rows. False if comparing columns. - *

- * @param labels - *

- * The labels to be compared to the rows or columns. - *

- * @param assembly - *

- * The assembly to be compared with. - *

- * @return

- * True if they are equal. False otherwise. - *

- */ - private boolean doLabelsMatchLabelsInAssembly(boolean rows, - ArrayList labels, FuelAssembly assembly) { - int colCount = 0, rowCount = 0; - - if (rows == false) { - // Check you can get the column labels - for (int i = 0; i < labels.size(); i++) { - // Assert that the column labels are in order and are set - // correctly to the 0 indexed value of size - assertEquals(labels.get(i), assembly.getGridLabelProvider() - .getLabelFromColumn(i)); - assertEquals(i, assembly.getGridLabelProvider() - .getColumnFromLabel(labels.get(i))); - colCount++; - } - - // Assert that the size of the columns equals the size of the - // reactor - assertEquals(assembly.getSize(), colCount); - } - - else { - - // Check you can get the rowlabels - for (int i = 0; i < labels.size(); i++) { - // Assert that the row labels are in order and are set correctly - // to the 0 indexed value of size - assertEquals(labels.get(i), assembly.getGridLabelProvider() - .getLabelFromRow(i)); - assertEquals(i, assembly.getGridLabelProvider() - .getRowFromLabel(labels.get(i))); - rowCount++; - } - - // Assert that the size of the rows equals the size of the assembly - assertEquals(assembly.getSize(), rowCount); - } - - return true; - - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - FuelAssembly object, equalObject, unEqualObject, transitiveObject; - String name = "Billy"; - int size = 5; - LWRRod rod = new LWRRod("Bob the rod"); - Tube tube = new Tube("Billy the tube"); - - // Setup root object - object = new FuelAssembly(name, size); - object.addLWRRod(rod); - object.addTube(tube); - object.setLWRRodLocation(rod.getName(), 0, 0); - object.setTubeLocation(tube.getName(), 1, 1); - - // Setup equalObject equal to object - equalObject = new FuelAssembly(name, size); - equalObject.addLWRRod(rod); - equalObject.addTube(tube); - equalObject.setLWRRodLocation(rod.getName(), 0, 0); - equalObject.setTubeLocation(tube.getName(), 1, 1); - - // Setup transitiveObject equal to object - transitiveObject = new FuelAssembly(name, size); - transitiveObject.addLWRRod(rod); - transitiveObject.addTube(tube); - transitiveObject.setLWRRodLocation(rod.getName(), 0, 0); - transitiveObject.setTubeLocation(tube.getName(), 1, 1); - - // Set its data, not equal to object - unEqualObject = new FuelAssembly(name, size); - unEqualObject.addLWRRod(rod); - unEqualObject.setLWRRodLocation(rod.getName(), 0, 0); - // No tube - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - FuelAssembly object, copyObject, clonedObject; - String name = "Billy"; - int size = 5; - LWRRod rod = new LWRRod("Bob the rod"); - Tube tube = new Tube("Billy the tube"); - - // Setup root object - object = new FuelAssembly(name, size); - object.addLWRRod(rod); - object.addTube(tube); - object.setLWRRodLocation(rod.getName(), 0, 0); - object.setTubeLocation(tube.getName(), 1, 1); - - // Run the copy routine - copyObject = new FuelAssembly(1); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (FuelAssembly) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - int size = 5; - FuelAssembly assembly = new FuelAssembly(size); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = assembly.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - LWRRod rod1 = new LWRRod("Rod1"); - LWRRod rod2 = new LWRRod("Rod2"); - LWRRod rod3 = new LWRRod("Rod3"); - GridLocation loc1 = new GridLocation(0, 0); - GridLocation loc2 = new GridLocation(2, 0); - GridLocation loc3 = new GridLocation(0, 3); - double rodPitch = 4; - Tube tube = new Tube("IM A TUBE!"); - ArrayList rowLabels = new ArrayList(); - ArrayList columnLabels = new ArrayList(); - LWRGridManager tubeManager = new LWRGridManager(size); - String testFileName = "testWrite.h5"; - - // Setup duplicate manager for comparison testing - LWRGridManager manager = new LWRGridManager(size); - manager.setName("LWRRod Grid"); - manager.addComponent(rod1, loc1); - manager.addComponent(rod2, loc2); - manager.addComponent(rod3, loc3); - - tubeManager.setName("Tube Grid"); - tubeManager.addComponent(tube, loc1); - - // Setup row labels - rowLabels.add("A"); - rowLabels.add("B"); - rowLabels.add("C"); - rowLabels.add("D"); - rowLabels.add("E"); - - // Setup col labels - columnLabels.add("1"); - columnLabels.add("2"); - columnLabels.add("3"); - columnLabels.add("4"); - columnLabels.add("OVER 9000!"); - - GridLabelProvider provider = new GridLabelProvider(size); - provider.setRowLabels(rowLabels); - provider.setColumnLabels(columnLabels); - - // Setup assembly - assembly.setName(name); - assembly.setId(id); - assembly.setDescription(description); - assembly.addLWRRod(rod1); - assembly.addLWRRod(rod2); - assembly.addLWRRod(rod3); - assembly.setRodPitch(rodPitch); - assembly.addTube(tube); - assembly.setGridLabelProvider(provider); - - // Setup duplicate for assembly's grid location - assembly.setLWRRodLocation(rod1.getName(), loc1.getRow(), - loc1.getColumn()); - assembly.setLWRRodLocation(rod2.getName(), loc2.getRow(), - loc2.getColumn()); - assembly.setLWRRodLocation(rod3.getName(), loc3.getRow(), - loc3.getColumn()); - - assembly.setTubeLocation(tube.getName(), loc1.getRow(), - loc1.getColumn()); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - // Fail here - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(assembly.getWriteableChildren()); - // Check Children - assertEquals(5, assembly.getWriteableChildren().size()); - assertTrue(tube.equals(assembly.getWriteableChildren().get(0) - .getWriteableChildren().get(0))); - assertTrue(rod3.equals(assembly.getWriteableChildren().get(1) - .getWriteableChildren().get(0))); - assertTrue(rod2.equals(assembly.getWriteableChildren().get(1) - .getWriteableChildren().get(1))); - assertTrue(rod1.equals(assembly.getWriteableChildren().get(1) - .getWriteableChildren().get(2))); - LWRGridManager otherManager = (LWRGridManager) assembly - .getWriteableChildren().get(2); - assertTrue(manager.equals(otherManager)); - assertTrue(provider.equals(assembly.getWriteableChildren().get(3))); - assertTrue(tubeManager.equals(assembly.getWriteableChildren().get(4))); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(assembly.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(6, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - rodPitch - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "rodPitch"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(rodPitch, ((double[]) attribute.getValue())[0], 1.2); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - size - attribute = (Attribute) h5Group.getMetadata().get(5); - assertEquals(attribute.getName(), "size"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(size, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(assembly.writeAttributes(null, h5Group)); - assertFalse(assembly.writeAttributes(h5File, null)); - assertFalse(assembly.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = assembly.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root assembly - assertEquals(assembly.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - int size = 5; - FuelAssembly component = new FuelAssembly(size); - FuelAssembly newComponent = new FuelAssembly(-1); - RodClusterAssembly rodCluster = new RodClusterAssembly(size); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - LWRRod rod1 = new LWRRod("Rod1"); - LWRRod rod2 = new LWRRod("Rod2"); - LWRRod rod3 = new LWRRod("Rod3"); - GridLocation loc1 = new GridLocation(0, 0); - GridLocation loc2 = new GridLocation(2, 0); - GridLocation loc3 = new GridLocation(0, 3); - GridLocation loc4 = new GridLocation(2, 3); - Tube tube = new Tube("IMMA TUBE!"); - double rodPitch = 4; - ArrayList rowLabels = new ArrayList(); - ArrayList columnLabels = new ArrayList(); - - // Setup row labels - rowLabels.add("A"); - rowLabels.add("B"); - rowLabels.add("C"); - rowLabels.add("D"); - rowLabels.add("E"); - - // Setup col labels - columnLabels.add("1"); - columnLabels.add("2"); - columnLabels.add("3"); - columnLabels.add("4"); - columnLabels.add("OVER 9000!"); - - GridLabelProvider provider = new GridLabelProvider(size); - provider.setName("Grid Labels"); - provider.setRowLabels(rowLabels); - provider.setColumnLabels(columnLabels); - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setRodPitch(rodPitch); - component.setGridLabelProvider(provider); - component.setRodClusterAssembly(rodCluster); - - component.addLWRRod(rod1); - component.addLWRRod(rod2); - component.addLWRRod(rod3); - component.addTube(tube); - - // Setup duplicate for assembly's grid location - component.setLWRRodLocation(rod1.getName(), loc1.getRow(), - loc1.getColumn()); - component.setLWRRodLocation(rod2.getName(), loc2.getRow(), - loc2.getColumn()); - component.setLWRRodLocation(rod3.getName(), loc3.getRow(), - loc3.getColumn()); - component.setTubeLocation(tube.getName(), loc4.getRow(), - loc4.getColumn()); - - // Setup GridManager - LWRRods - LWRGridManager manager1 = new LWRGridManager(size); - manager1.setName("LWRRod Grid"); - manager1.addComponent(rod1, loc1); - manager1.addComponent(rod2, loc2); - manager1.addComponent(rod3, loc3); - - // Setup Composite - LWRRods - LWRComposite composite1 = new LWRComposite(); - composite1.setName("LWRRods"); - composite1.setDescription("A Composite that contains many LWRRods."); - composite1.setId(1); - composite1.addComponent(rod1); - composite1.addComponent(rod2); - composite1.addComponent(rod3); - - // Setup GridManager - Tubes - LWRGridManager manager2 = new LWRGridManager(size); - manager2.setName("Tube Grid"); - manager2.addComponent(tube, loc4); - - // Setup Composite - Tubes - LWRComposite composite2 = new LWRComposite(); - composite2.setName("Tubes"); - composite2.setDescription("A Composite that contains many Tubes."); - composite2.setId(2); - composite2.addComponent(tube); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup PWRAssembly with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup size attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "size", - size); - - // Setup rodPitch attribute - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, "rodPitch", - rodPitch); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - assertTrue(newComponent.readChild(manager1)); - assertTrue(newComponent.readChild(composite1)); - assertTrue(newComponent.readChild(manager2)); - assertTrue(newComponent.readChild(composite2)); - assertTrue(newComponent.readChild(provider)); - assertTrue(newComponent.readChild(rodCluster)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Try to break the readChild operation - assertFalse(newComponent.readChild(null)); - assertTrue(newComponent.readChild(new LWRGridManager(size))); - assertTrue(newComponent.readChild(new LWRComposite())); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - - } - - /** - * - */ - public void checkLWRDataProvider() { - - // Make an assembly and setup some locations - FuelAssembly assembly; - - String name = "Billy"; - int size = 5; - Tube tube = new Tube("Bob the rod"); - - // Setup root object - assembly = new FuelAssembly(name, size); - assembly.addTube(tube); - - // Locations - int row1 = 0, col1 = 0, row2 = 1, col2 = 1, row3 = 2, col3 = 3; - - // Check getters with nothing on the object - assertNull(assembly.getLWRRodDataProviderAtLocation(row1, col1)); - assertNull(assembly.getLWRRodDataProviderAtLocation(row2, col2)); - assertNull(assembly.getLWRRodDataProviderAtLocation(row3, col3)); - - // Add locations - assembly.setLWRRodLocation(tube.getName(), row1, col1); - assembly.setLWRRodLocation(tube.getName(), row2, col2); - assembly.setLWRRodLocation(tube.getName(), row3, col3); - - // Check not null - assertNotNull(assembly.getLWRRodDataProviderAtLocation(row1, col1)); - assertNotNull(assembly.getLWRRodDataProviderAtLocation(row2, col2)); - assertNotNull(assembly.getLWRRodDataProviderAtLocation(row3, col3)); - - // Prepare some data - LWRData data1 = new LWRData("Feature1111"); - LWRData data2 = new LWRData("Feature1111"); - LWRData data3 = new LWRData("Feature1112"); - LWRData data4 = new LWRData("Feature1113"); - - // Setup providers and times - LWRDataProvider provider = new LWRDataProvider(); - - double time1 = 0.0, time2 = 0.1; - - // Setup provider - provider.addData(data1, time1); - provider.addData(data2, time1); - provider.addData(data3, time1); - provider.addData(data4, time2); - - // Add data - assembly.getLWRRodDataProviderAtLocation(row1, col1).addData(data1, - time1); - assembly.getLWRRodDataProviderAtLocation(row1, col1).addData(data2, - time1); - assembly.getLWRRodDataProviderAtLocation(row1, col1).addData(data3, - time1); - assembly.getLWRRodDataProviderAtLocation(row1, col1).addData(data4, - time2); - - // Verify data - assertTrue(provider.equals(assembly.getLWRRodDataProviderAtLocation( - row1, col1))); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/IncoreInstrumentTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/IncoreInstrumentTester.java deleted file mode 100644 index a167ef9a1..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/IncoreInstrumentTester.java +++ /dev/null @@ -1,519 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.pwr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.Ring; -import org.eclipse.ice.reactor.pwr.IncoreInstrument; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This test checks IncoreInstrument Class construction and passing a thimble - * ring - *

- * - * @author Scott Forest Hull II - */ -public class IncoreInstrumentTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - IncoreInstrument instrument; - // Default Values - String defaultName = "Instrument 1"; - String defaultDesc = "Default Instrument"; - // New Values - String newName = "Instrument 2"; - Ring newThimble = new Ring("thimble"); - HDF5LWRTagType type = HDF5LWRTagType.INCORE_INSTRUMENT; - - // Check nullary constructor - instrument = new IncoreInstrument(); - assertEquals(defaultName, instrument.getName()); - assertEquals(defaultDesc, instrument.getDescription()); - assertNotNull(instrument.getThimble()); - assertEquals(type, instrument.getHDF5LWRTag()); - - // Check non-nullary constructor - instrument = new IncoreInstrument(newName, newThimble); - assertEquals(newName, instrument.getName()); - assertEquals(newThimble, instrument.getThimble()); - assertEquals(type, instrument.getHDF5LWRTag()); - - // Check non-nullary constructor illegal values illegal value is set to - // default - instrument = new IncoreInstrument(null, newThimble); - assertEquals(defaultName, instrument.getName()); - assertEquals(newThimble, instrument.getThimble()); - assertEquals(type, instrument.getHDF5LWRTag()); - - instrument = new IncoreInstrument(null, null); - assertEquals(defaultName, instrument.getName()); - assertNotNull(instrument.getThimble()); - assertEquals(type, instrument.getHDF5LWRTag()); - - } - - /** - *

- * This operation tests the getter and setter of the thimble. - *

- * - */ - @Test - public void checkThimble() { - // check a legal value set - IncoreInstrument instrument = new IncoreInstrument(); - Ring newThimble = new Ring("thimble"); - instrument.setThimble(newThimble); - assertEquals(newThimble, instrument.getThimble()); - // check illegal value set - instrument.setThimble(null); - assertNotNull(instrument.getThimble()); - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - IncoreInstrument object, equalObject, unEqualObject, transitiveObject; - String name = "Instruments!"; - Ring thimble = new Ring("THIMBLE!"); - Ring unEqualThimble = new Ring("UNEQUALTHIMBLE!"); - - // Setup root object - object = new IncoreInstrument(name, thimble); - - // Setup equalObject equal to object - equalObject = new IncoreInstrument(name, thimble); - - // Setup transitiveObject equal to object - transitiveObject = new IncoreInstrument(name, thimble); - - // Set its data, not equal to object - // Does not contain components! - unEqualObject = new IncoreInstrument(name, unEqualThimble); - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - IncoreInstrument object, copyObject, clonedObject; - String name = "Instruments!"; - Ring thimble = new Ring("THIMBLE!"); - - // Setup root object - object = new IncoreInstrument(name, thimble); - - // Run the copy routine - copyObject = new IncoreInstrument(); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (IncoreInstrument) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - IncoreInstrument instrument = new IncoreInstrument(); - String name = "Instruments"; - String description = "Music"; - int id = 4; - HDF5LWRTagType tag = instrument.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - Ring thimble = new Ring("I am a thimble!"); - String testFileName = "testWrite.h5"; - - // Setup instrument - instrument.setName(name); - instrument.setId(id); - instrument.setDescription(description); - instrument.setThimble(thimble); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(instrument.getWriteableChildren()); - assertEquals(1, instrument.getWriteableChildren().size()); - assertTrue(thimble.equals(instrument.getThimble())); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(instrument.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(4, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(instrument.writeAttributes(null, h5Group)); - assertFalse(instrument.writeAttributes(h5File, null)); - - // Check dataSet. - assertFalse(instrument.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = instrument.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root instrument - assertEquals(instrument.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - IncoreInstrument component = new IncoreInstrument(); - IncoreInstrument newComponent = new IncoreInstrument(); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - Ring thimble = new Ring("BOBBY!!"); - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setThimble(thimble); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check Readable Children - // assertTrue(component.readChild(null)); - - // Setup PWRAssembly with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - assertTrue(newComponent.readChild(thimble)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - // Nullary check for readChild - assertFalse(component.readChild(null)); - assertTrue(component.readChild(newComponent)); - - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWRAssemblyTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWRAssemblyTester.java deleted file mode 100644 index e9ad723bc..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWRAssemblyTester.java +++ /dev/null @@ -1,1029 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.pwr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.GridLocation; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRComposite; -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.eclipse.ice.reactor.LWRGridManager; -import org.eclipse.ice.reactor.LWRRod; -import org.eclipse.ice.reactor.pwr.PWRAssembly; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class is responsible for testing the PWAssembly class. - *

- * - * @author Scott Forest Hull II - */ -public class PWRAssemblyTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - // Set the path to the library - // System.setProperty("java.library.path", "/usr/lib64"); - // System.setProperty("java.library.path", "/home/Scott Forest Hull II/usr/local/lib64"); - // System.setProperty("java.library.path", - // "/home/ICE/hdf-java/lib/linux"); - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declarations - PWRAssembly assembly; - // Default values. Change here as needed for tests - String defaultName = "PWRAssembly"; - String defaultDesc = "PWRAssembly's Description"; - int defaultId = 1; - int defaultSize = 1; - double defaultRodPitch = 1; - HDF5LWRTagType type = HDF5LWRTagType.PWRASSEMBLY; - - // New values - String newName = "Super Assembly!"; - int newSize = 10; - - // Test non-nullary constructor - size - assembly = new PWRAssembly(defaultSize); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0.0); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Test non-nullary constructor - size - assembly = new PWRAssembly(newSize); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(newSize, assembly.getSize()); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0.0); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Test non-nullary constructor - illegal size value - assembly = new PWRAssembly(0); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); // Defaults - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0.0); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Test non-nullary constructor - illegal size value - negative - assembly = new PWRAssembly(-1); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); // Defaults - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0.0); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Test non-nullary constructor - name and size - assembly = new PWRAssembly(defaultName, defaultSize); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0.0); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Test non-nullary constructor - name and size - assembly = new PWRAssembly(newName, defaultSize); - // Check values - assertEquals(newName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0.0); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Test non-nullary constructor - bad name but good size - assembly = new PWRAssembly(null, defaultSize); - // Check values - assertEquals(defaultName, assembly.getName()); // Defaults - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0.0); - assertEquals(type, assembly.getHDF5LWRTag()); - - } - - /** - *

- * This operation checks the adders, getters, and setters for LWRRods. - *

- * - */ - @Test - public void checkLWRRodOperations() { - // Local Declarations - int assemblySize = 17; - PWRAssembly assembly = new PWRAssembly(assemblySize); - LWRRod testComponent = new LWRRod(), testComponent2 = new LWRRod(), testComponent3 = new LWRRod(); - String testComponentName = "Bob"; - String testComponentName2 = "Bill!"; - int rowLoc1 = 5, colLoc1 = 5; - int rowLoc2 = 6, colLoc2 = 6; - int testComponentId = 1000001; - double defaultRodPitch; - - // Check the default values of the Component under test - assembly = new PWRAssembly(assemblySize); - - // Check rodPitch setting - // Set the defaultRodPitch - defaultRodPitch = assembly.getRodPitch(); - - // Set the rodPitch to 0 - fails - assembly.setRodPitch(0.0); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0.0); - - // Set the rod Pitch to 1 - assembly.setRodPitch(1); - assertEquals(1.0, assembly.getRodPitch(), 0.0); - defaultRodPitch = assembly.getRodPitch(); // Reset default value to - // reflect next test. - - // Set the rod pitch to negative - does not work - assembly.setRodPitch(-1.0); - assertEquals(defaultRodPitch, assembly.getRodPitch(), 0.0); - - // No rods should be added by default. Therefore every - // location is bad - for (int i = 0; i < assemblySize; i++) { - for (int j = 0; j < assemblySize; j++) { - assertNull(assembly.getLWRRodByLocation(i, j)); - } - } - - // Check the names, should be empty! - assertEquals(0, assembly.getLWRRodNames().size()); - - // Try to get by name - valid string, empty string, and null - assertNull(assembly - .getLWRRodByName("validNameThatDoesNotExistInThere152423")); - assertNull(assembly.getLWRRodByName("")); - assertNull(assembly.getLWRRodByName(null)); - - // Set the name - testComponent.setName(testComponentName); - - // Add to the assembly - assembly.addLWRRod(testComponent); - - // See that no location is set - assertNull(assembly.getLWRRodByLocation(rowLoc1, colLoc1)); - // Check locations to be within bounds - assertNull(assembly.getLWRRodByLocation(-1, assemblySize - 1)); - assertNull(assembly.getLWRRodByLocation(1, assemblySize - 1)); - assertNull(assembly.getLWRRodByLocation(assemblySize + 25, - assemblySize - 1)); - assertNull(assembly.getLWRRodByLocation(assemblySize - 1, - assemblySize + 25)); - - // Set the valid location: - assertTrue(assembly.setLWRRodLocation(testComponentName, rowLoc1, - colLoc1)); - - // Try to break location setter - assertFalse(assembly.setLWRRodLocation(null, rowLoc1, colLoc1)); - assertFalse(assembly.setLWRRodLocation(testComponentName, -1, colLoc1)); - assertFalse(assembly.setLWRRodLocation(testComponentName, rowLoc1, -1)); - assertFalse(assembly.setLWRRodLocation(null, -1, colLoc1)); - assertFalse(assembly.setLWRRodLocation(null, rowLoc1, -1)); - assertFalse(assembly.setLWRRodLocation(null, -1, -1)); - assertFalse(assembly.setLWRRodLocation(testComponentName, rowLoc1, - assemblySize + 25)); - assertFalse(assembly.setLWRRodLocation(testComponentName, - assemblySize + 25, colLoc1)); - - // The above erroneous settings does not change the original location of - // the first, valid set - assertTrue(testComponent.equals(assembly - .getLWRRodByName(testComponentName))); - - // Check invalid overwrite of location: - testComponent2.setName(testComponentName2); - - // Add assembly, overwrite the previous testComponent's location - assertFalse(assembly.setLWRRodLocation(testComponent2.getName(), - rowLoc1, colLoc1)); - - // Check that it is the first, but not second - assertTrue(testComponent.equals(assembly - .getLWRRodByName(testComponentName))); - - // Add it in there - assertTrue(assembly.addLWRRod(testComponent2)); - - // Show that you can have at least 2 components in there - assertTrue(assembly.setLWRRodLocation(testComponent2.getName(), - rowLoc2, colLoc2)); - - // Check values - see the components are different and they reside in - // the table correctly - assertTrue(testComponent.equals(assembly - .getLWRRodByName(testComponentName))); - assertTrue(testComponent2.equals(assembly - .getLWRRodByName(testComponentName2))); - - // Check the locations - assertTrue(testComponent.equals(assembly.getLWRRodByLocation(rowLoc1, - colLoc1))); - assertTrue(testComponent2.equals(assembly.getLWRRodByLocation(rowLoc2, - colLoc2))); - - // Check the names, should contain 2! - assertEquals(2, assembly.getLWRRodNames().size()); - assertEquals(testComponentName, assembly.getLWRRodNames().get(0)); - assertEquals(testComponentName2, assembly.getLWRRodNames().get(1)); - - // Check operation for null - assembly.addLWRRod(null); - assertNull(assembly.getLWRRodByName(null)); // Make sure null does - // not work! - - // Finally, demonstrate what happens when a component of the same name - // is added, it should not overwrite the previous item in the table! - testComponent3.setName(testComponent.getName()); // Same name as the - // other - // component - testComponent3.setId(testComponentId); // Id should differ from - // testComponent! - assertFalse(testComponent.getId() == testComponentId); - - // Overwrite in table - assertFalse(assembly.addLWRRod(testComponent3)); - - // Check that the object has not been overwritten - assertTrue(testComponent.equals(assembly - .getLWRRodByName(testComponentName))); - assertFalse(testComponent3.equals(assembly - .getLWRRodByName(testComponentName))); - - // Test to remove components from the assembly - assertFalse(assembly.removeLWRRod(null)); - assertFalse(assembly.removeLWRRod("")); - assertFalse(assembly - .removeLWRRod("!--+ANamETHaTDoESNOTEXIST19674376393<><(@#*)%^")); - - // Remove the first component - assertTrue(assembly.removeLWRRod(testComponent.getName())); - - // Check that it does not exist in the location or getting the name - assertNull(assembly.getLWRRodByLocation(rowLoc1, colLoc1)); - assertNull(assembly.getLWRRodByName(testComponent.getName())); - // Check size - assertEquals(1, assembly.getNumberOfLWRRods()); - - // It can now be overridden! - assertTrue(assembly.setLWRRodLocation(testComponent2.getName(), - rowLoc1, colLoc1)); - - // Show that the component's names can NOT overwrite each others - // locations - assertTrue(assembly.addLWRRod(testComponent)); - assertFalse(assembly.setLWRRodLocation(testComponent.getName(), - rowLoc1, colLoc1)); - - // Check the size, the respective locations - assertEquals(testComponent2.getName(), - assembly.getLWRRodByLocation(rowLoc1, colLoc1).getName()); - assertEquals(testComponent2.getName(), - assembly.getLWRRodByLocation(rowLoc2, colLoc2).getName()); - assertEquals(2, assembly.getNumberOfLWRRods()); - - } - - /** - *

- * This operation demonstrates the behaviors listed with the overridden - * composite implementations from LWRComposite. - *

- * - */ - @Test - public void checkCompositeImplementations() { - // Local Declarations - int assemblySize = 17; - PWRAssembly assembly; - ArrayList compNames = new ArrayList(); - ArrayList components = new ArrayList(); - int numberOfDefaultComponents = 0; - - // Defaults for rodComposite - LWRComposite rodComposite; - String compName = "LWRRods"; - String compDescription = "A Composite that contains many LWRRods."; - int compId = 1; - - // Setup LWRRodComposite for comparison - rodComposite = new LWRComposite(); - rodComposite.setName(compName); - rodComposite.setId(compId); - rodComposite.setDescription(compDescription); - - // Add components to arrays - compNames.add(rodComposite.getName()); - components.add((Component) rodComposite); - // Setup the default number of components - numberOfDefaultComponents = components.size(); - - // Check the default Composite size and attributes on PWRAssembly - assembly = new PWRAssembly(assemblySize); - - // Has a size of numberOfDefaultComponents - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - // It is equal to the default rodComposite for many of the composite - // getters - assertTrue(rodComposite.equals(assembly.getComponent(1))); - assertTrue(rodComposite.equals(assembly.getComponent(rodComposite - .getName()))); - assertTrue(compNames.equals(assembly.getComponentNames())); - assertTrue(components.equals(assembly.getComponents())); - - // These operations will show that these will not work for this class - - // Check addComponent - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - assembly.addComponent(new LWRComposite()); - // No size change! - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - - // Check removeComponent - id - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - assembly.removeComponent(1); - // No size change! - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - - // Check remove component - name - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - assembly.removeComponent(components.get(0).getName()); // Try to remove - // the first off - // the list - // No size change! - assertEquals(numberOfDefaultComponents, - assembly.getNumberOfComponents()); - - } - - /** - *

- * This operation checks the getter and setter for rodPitch. - *

- * - */ - @Test - public void checkRodPitch() { - PWRAssembly assembly = new PWRAssembly(2); - double defaultPitch = 1; - - // Check default value on assembly - assertEquals(defaultPitch, assembly.getRodPitch(), 0.0); - - // Set it to 1 - assembly.setRodPitch(1.0); - assertEquals(1.0, assembly.getRodPitch(), 0.0); - - // Set it to 0 - fails - assembly.setRodPitch(0.0); - assertEquals(1.0, assembly.getRodPitch(), 0.0); - - // Set it to negative - illegal value - assembly.setRodPitch(-1.0); - assertEquals(1.0, assembly.getRodPitch(), 0.0); - - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - PWRAssembly object, equalObject, unEqualObject, transitiveObject; - String name = "Billy"; - int size = 5; - LWRRod rod = new LWRRod("Bob the rod"); - - // Setup root object - object = new PWRAssembly(name, size); - object.addLWRRod(rod); - object.setLWRRodLocation(rod.getName(), 0, 0); - - // Setup equalObject equal to object - equalObject = new PWRAssembly(name, size); - equalObject.addLWRRod(rod); - equalObject.setLWRRodLocation(rod.getName(), 0, 0); - - // Setup transitiveObject equal to object - transitiveObject = new PWRAssembly(name, size); - transitiveObject.addLWRRod(rod); - transitiveObject.setLWRRodLocation(rod.getName(), 0, 0); - - // Set its data, not equal to object - unEqualObject = new PWRAssembly(name, size); - // Uses the default rod - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - PWRAssembly object, copyObject, clonedObject; - String name = "Billy"; - int size = 5; - LWRRod rod = new LWRRod("Bob the rod"); - - // Setup root object - object = new PWRAssembly(name, size); - object.addLWRRod(rod); - object.setLWRRodLocation(rod.getName(), 0, 0); - - // Run the copy routine - copyObject = new PWRAssembly(1); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (PWRAssembly) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - int size = 5; - PWRAssembly assembly = new PWRAssembly(size); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = assembly.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - LWRRod rod1 = new LWRRod("Rod1"); - LWRRod rod2 = new LWRRod("Rod2"); - LWRRod rod3 = new LWRRod("Rod3"); - GridLocation loc1 = new GridLocation(0, 0); - GridLocation loc2 = new GridLocation(2, 0); - GridLocation loc3 = new GridLocation(0, 3); - double rodPitch = 4; - String testFileName = "testWrite.h5"; - - // Setup duplicate manager for comparison testing - LWRGridManager manager = new LWRGridManager(size); - manager.setName("LWRRod Grid"); - manager.addComponent(rod1, loc1); - manager.addComponent(rod2, loc2); - manager.addComponent(rod3, loc3); - - // Setup assembly - assembly.setName(name); - assembly.setId(id); - assembly.setDescription(description); - assembly.addLWRRod(rod1); - assembly.addLWRRod(rod2); - assembly.addLWRRod(rod3); - assembly.setRodPitch(rodPitch); - // Setup duplicate for assembly's grid location - assembly.setLWRRodLocation(rod1.getName(), loc1.getRow(), - loc1.getColumn()); - assembly.setLWRRodLocation(rod2.getName(), loc2.getRow(), - loc2.getColumn()); - assembly.setLWRRodLocation(rod3.getName(), loc3.getRow(), - loc3.getColumn()); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - // Fail here - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(assembly.getWriteableChildren()); - // Check Children - assertEquals(2, assembly.getWriteableChildren().size()); - assertTrue(rod3.equals(assembly.getWriteableChildren().get(0) - .getWriteableChildren().get(0))); - assertTrue(rod2.equals(assembly.getWriteableChildren().get(0) - .getWriteableChildren().get(1))); - assertTrue(rod1.equals(assembly.getWriteableChildren().get(0) - .getWriteableChildren().get(2))); - LWRGridManager otherManager = (LWRGridManager) assembly - .getWriteableChildren().get(1); - assertTrue(manager.equals(otherManager)); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(assembly.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(6, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - rodPitch - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "rodPitch"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(rodPitch, ((double[]) attribute.getValue())[0], 1.2); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - size - attribute = (Attribute) h5Group.getMetadata().get(5); - assertEquals(attribute.getName(), "size"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(size, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(assembly.writeAttributes(null, h5Group)); - assertFalse(assembly.writeAttributes(h5File, null)); - - // Check dataSet. - assertFalse(assembly.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = assembly.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root assembly - assertEquals(assembly.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - int size = 5; - PWRAssembly component = new PWRAssembly(size); - PWRAssembly newComponent = new PWRAssembly(-1); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - LWRRod rod1 = new LWRRod("Rod1"); - LWRRod rod2 = new LWRRod("Rod2"); - LWRRod rod3 = new LWRRod("Rod3"); - GridLocation loc1 = new GridLocation(0, 0); - GridLocation loc2 = new GridLocation(2, 0); - GridLocation loc3 = new GridLocation(0, 3); - double rodPitch = 4; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setRodPitch(rodPitch); - - component.addLWRRod(rod1); - component.addLWRRod(rod2); - component.addLWRRod(rod3); - - // Setup duplicate for assembly's grid location - component.setLWRRodLocation(rod1.getName(), loc1.getRow(), - loc1.getColumn()); - component.setLWRRodLocation(rod2.getName(), loc2.getRow(), - loc2.getColumn()); - component.setLWRRodLocation(rod3.getName(), loc3.getRow(), - loc3.getColumn()); - - // Setup GridManager - LWRGridManager manager = new LWRGridManager(size); - manager.setName("LWRRod Grid"); - manager.addComponent(rod1, loc1); - manager.addComponent(rod2, loc2); - manager.addComponent(rod3, loc3); - - // Setup Composite - LWRComposite composite = new LWRComposite(); - composite.setName("LWRRods"); - composite.setDescription("A Composite that contains many LWRRods."); - composite.setId(1); - composite.addComponent(rod1); - composite.addComponent(rod2); - composite.addComponent(rod3); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Check Readable Children - // assertTrue(component.readChild(null)); - - // Setup PWRAssembly with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup size attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "size", - size); - - // Setup rodPitch attribute - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, "rodPitch", - rodPitch); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - assertTrue(newComponent.readChild(manager)); - assertTrue(newComponent.readChild(composite)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Try to break the PWRAssembly.readChild operation - assertFalse(newComponent.readChild(null)); - assertTrue(newComponent.readChild(new LWRGridManager(size))); - assertTrue(newComponent.readChild(new LWRComposite())); - - // Show data is not changed - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - - /** - * - */ - @Test - public void checkLWRDataProvider() { - - // Make an assembly and setup some locations - PWRAssembly assembly; - - String name = "Billy"; - int size = 5; - LWRRod rod = new LWRRod("Bob the rod"); - - // Setup root object - assembly = new PWRAssembly(name, size); - assembly.addLWRRod(rod); - - // Locations - int row1 = 0, col1 = 0, row2 = 1, col2 = 1, row3 = 2, col3 = 3; - - // Check getters with nothing on the object - assertNull(assembly.getLWRRodDataProviderAtLocation(row1, col1)); - assertNull(assembly.getLWRRodDataProviderAtLocation(row2, col2)); - assertNull(assembly.getLWRRodDataProviderAtLocation(row3, col3)); - - // Add locations - assembly.setLWRRodLocation(rod.getName(), row1, col1); - assembly.setLWRRodLocation(rod.getName(), row2, col2); - assembly.setLWRRodLocation(rod.getName(), row3, col3); - - // Check not null - assertNotNull(assembly.getLWRRodDataProviderAtLocation(row1, col1)); - assertNotNull(assembly.getLWRRodDataProviderAtLocation(row2, col2)); - assertNotNull(assembly.getLWRRodDataProviderAtLocation(row3, col3)); - - // Prepare some data - LWRData data1 = new LWRData("Feature1111"); - LWRData data2 = new LWRData("Feature1111"); - LWRData data3 = new LWRData("Feature1112"); - LWRData data4 = new LWRData("Feature1113"); - - // Setup providers and times - LWRDataProvider provider = new LWRDataProvider(); - - double time1 = 0.0, time2 = 0.1; - - // Setup provider - provider.addData(data1, time1); - provider.addData(data2, time1); - provider.addData(data3, time1); - provider.addData(data4, time2); - - // Add data - assembly.getLWRRodDataProviderAtLocation(row1, col1).addData(data1, - time1); - assembly.getLWRRodDataProviderAtLocation(row1, col1).addData(data2, - time1); - assembly.getLWRRodDataProviderAtLocation(row1, col1).addData(data3, - time1); - assembly.getLWRRodDataProviderAtLocation(row1, col1).addData(data4, - time2); - - // Verify data - assertTrue(provider.equals(assembly.getLWRRodDataProviderAtLocation( - row1, col1))); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWReactorFactory.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWReactorFactory.java deleted file mode 100644 index 5fbe9cc9f..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWReactorFactory.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.pwr; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.ArrayList; - -import org.eclipse.ice.reactor.AssemblyType; -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRRod; -import org.eclipse.ice.reactor.Material; -import org.eclipse.ice.reactor.MaterialType; -import org.eclipse.ice.reactor.Ring; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; - -public class PWReactorFactory { - - /** - *

- * Creates and returns a sample PWReactor populated with state point data at - * one time step. - *

- * - * @return A sample PWReactor populated with state point data at one time - * step. - */ - public PressurizedWaterReactor createPopulatedPWReactor() { - - PressurizedWaterReactor reactor = new PressurizedWaterReactor(1); - reactor.setName("Test PWR"); - reactor.setFuelAssemblyPitch(21.5); - - FuelAssembly assembly = new FuelAssembly(17); - assembly.setName("Test Assembly"); - - reactor.addAssembly(AssemblyType.Fuel, assembly); - reactor.setAssemblyLocation(AssemblyType.Fuel, assembly.getName(), 0, 0); - - ArrayList materialList = new ArrayList(); - materialList.add(new Material("uo2", MaterialType.SOLID)); - materialList.add(new Material("instrument", MaterialType.SOLID)); - materialList.add(new Material("poison", MaterialType.SOLID)); - materialList.add(new Material("guide", MaterialType.SOLID)); - - String separator = System.getProperty("file.separator"); - File pinDataFile = new File(System.getProperty("user.dir") + separator - + "data" + separator + "pin_data.txt"); - File powerDataFile = new File(System.getProperty("user.dir") - + separator + "data" + separator + "power_data.txt"); - - try { - - String pinDataFileContents = new String(this.readFile(pinDataFile)); - String powerDataFileContents = new String( - this.readFile(powerDataFile)); - - String[] pinDataLines = pinDataFileContents.split("\n"); - String[] powerDataLines = powerDataFileContents.split("\n"); - ArrayList rodList = new ArrayList(); - - int column = 0; - int row = 0; - - for (String line : pinDataLines) { - - String[] elements = line.split(","); - int pinNumber = Integer.valueOf(elements[0]); - int materialNumber = Integer.valueOf(elements[1]); - double radius = Double.valueOf(elements[2]); - - Ring clad = new Ring( - "Clad " + pinNumber, - (Material) materialList.get(materialNumber - 1).clone(), - 1.0, radius); - LWRRod rod = new LWRRod("Pin " + pinNumber); - rod.setClad(clad); - rodList.add(rod); - - assembly.addLWRRod(rod); - - if (column == 9) { - column = 0; - row++; - } - - assembly.setLWRRodLocation(rod.getName(), row, column); - - column++; - } - - for (String line : powerDataLines) { - - String[] elements = line.split(","); - int pinNumber = Integer.valueOf(elements[0]); - double pinPower = Double.valueOf(elements[1]); - double uncertainty = Double.valueOf(elements[2]); - - LWRRod rod = rodList.get(pinNumber - 1); - LWRData data = new LWRData("Pin Powers"); - data.setValue(pinPower); - data.setUncertainty(uncertainty); - rod.addData(data, 0.0); - - } - - return reactor; - - } catch (IOException e) { - - e.printStackTrace(); - return null; - - } - } - - /** - * Reads a file into a byte array. - * - * @param file - * the file - * @return the byte[] - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public byte[] readFile(File file) throws IOException { - int i = (int) file.length(); - byte[] buffer = new byte[i]; - FileInputStream fis = new FileInputStream(file); - fis.read(buffer); - fis.close(); - return buffer; - } - -} diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWReactorHDF5IntegrationTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWReactorHDF5IntegrationTester.java deleted file mode 100644 index af5fb547d..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWReactorHDF5IntegrationTester.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Eric J. Lingerfelt, Alexander J. McCaskey, - * Taylor Patterson, Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.pwr; - -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; - -import org.eclipse.ice.reactor.AssemblyType; -import org.eclipse.ice.reactor.LWRComponentReader; -import org.eclipse.ice.reactor.LWRComponentWriter; -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRRod; -import org.eclipse.ice.reactor.Material; -import org.eclipse.ice.reactor.MaterialType; -import org.eclipse.ice.reactor.Ring; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * - * @author Eric J. Lingerfelt - */ -public class PWReactorHDF5IntegrationTester { - - /** - * - */ - @BeforeClass - public static void beforeClass() { - - } - - /** - * - */ - @Test - public void checkHDF5Integration() { - - PressurizedWaterReactor reactor = createPopulatedPWReactor(); - - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + "reactorData"; - File dataFile = new File(userDir + separator + "integration_test.h5"); - URI uri = dataFile.toURI(); - - LWRComponentWriter writer = new LWRComponentWriter(); - writer.write(reactor, uri); - LWRComponentReader reader = new LWRComponentReader(); - PressurizedWaterReactor readReactor = (PressurizedWaterReactor) reader - .read(uri); - - assertTrue(reactor.equals(readReactor)); - - } - - /** - * - * @return - */ - private PressurizedWaterReactor createPopulatedPWReactor() { - - PressurizedWaterReactor reactor = new PressurizedWaterReactor(1); - reactor.setName("Test PWR"); - reactor.setFuelAssemblyPitch(21.5); - - FuelAssembly assembly = new FuelAssembly(17); - assembly.setName("Test Assembly"); - - reactor.addAssembly(AssemblyType.Fuel, assembly); - reactor.setAssemblyLocation(AssemblyType.Fuel, assembly.getName(), 0, - 0); - - ArrayList materialList = new ArrayList(); - materialList.add(new Material("uo2", MaterialType.SOLID)); - materialList.add(new Material("instrument", MaterialType.SOLID)); - materialList.add(new Material("poison", MaterialType.SOLID)); - materialList.add(new Material("guide", MaterialType.SOLID)); - - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + "reactorData"; - File pinDataFile = new File(userDir + separator + "pin_data.txt"); - File powerDataFile = new File(userDir + separator + "power_data.txt"); - - try { - - String pinDataFileContents = new String(this.readFile(pinDataFile)); - String powerDataFileContents = new String( - this.readFile(powerDataFile)); - - String[] pinDataLines = pinDataFileContents.split("\n"); - String[] powerDataLines = powerDataFileContents.split("\n"); - ArrayList rodList = new ArrayList(); - - int column = 0; - int row = 0; - - for (String line : pinDataLines) { - - String[] elements = line.split(","); - int pinNumber = Integer.valueOf(elements[0]); - int materialNumber = Integer.valueOf(elements[1]); - double radius = Double.valueOf(elements[2]); - - Ring clad = new Ring("Clad " + pinNumber, - (Material) materialList.get(materialNumber - 1).clone(), - 1.0, radius); - LWRRod rod = new LWRRod("Pin " + pinNumber); - rod.setClad(clad); - rodList.add(rod); - - assembly.addLWRRod(rod); - - if (column == 9) { - column = 0; - row++; - } - - assembly.setLWRRodLocation(rod.getName(), row, column); - - column++; - } - - for (String line : powerDataLines) { - - String[] elements = line.split(","); - int pinNumber = Integer.valueOf(elements[0]); - double pinPower = Double.valueOf(elements[1]); - double uncertainty = Double.valueOf(elements[2]); - - LWRRod rod = rodList.get(pinNumber - 1); - LWRData data = new LWRData("Pin Powers"); - data.setValue(pinPower); - data.setUncertainty(uncertainty); - rod.addData(data, 0.0); - - } - - return reactor; - - } catch (IOException e) { - - e.printStackTrace(); - return null; - - } - - } - - /** - * Read file. - * - * @param file - * the file - * @return the byte[] - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public byte[] readFile(File file) throws IOException { - int i = (int) file.length(); - byte[] buffer = new byte[i]; - FileInputStream fis = new FileInputStream(file); - fis.read(buffer); - fis.close(); - return buffer; - } - - /** - * - */ - @AfterClass - public static void afterClass() { - - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + "reactorData"; - File dataFile = new File(userDir + separator + "integration_test.h5"); - - if (dataFile.exists()) { - dataFile.delete(); - } - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWReactorTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWReactorTester.java deleted file mode 100644 index a5e0b7cdf..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PWReactorTester.java +++ /dev/null @@ -1,2211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.pwr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.AssemblyType; -import org.eclipse.ice.reactor.GridLabelProvider; -import org.eclipse.ice.reactor.GridLocation; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRComposite; -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.eclipse.ice.reactor.LWRGridManager; -import org.eclipse.ice.reactor.Ring; -import org.eclipse.ice.reactor.pwr.ControlBank; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.IncoreInstrument; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.eclipse.ice.reactor.pwr.RodClusterAssembly; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class is responsible for testing the PWReactor class. - *

- * - * @author Scott Forest Hull II - */ - -public class PWReactorTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - } - - /** - *

- * This operation checks the constructor and it's default values. - *

- * - */ - @Test - public void checkConstruction() { - - // Local Declarations - PressurizedWaterReactor reactor; - PressurizedWaterReactor defaultReactor; - int defaultSize = 17; // Default size when an erroneous value is set on - // the reactor - String defaultName = "PWReactor 1"; - String defaultDescription = "PWReactor 1's Description"; - int defaultId = 1; - HDF5LWRTagType type = HDF5LWRTagType.PWREACTOR; - - // This test is to show the default value for a reactor when it is - // created with a negative value. - defaultReactor = new PressurizedWaterReactor(-1); - assertEquals(defaultSize, defaultReactor.getSize()); - assertEquals(defaultName, defaultReactor.getName()); - assertEquals(defaultDescription, defaultReactor.getDescription()); - assertEquals(defaultId, defaultReactor.getId()); - assertEquals(type, defaultReactor.getHDF5LWRTag()); - - // This test is to show the default value for a reactor when its created - // with a zero value - defaultReactor = new PressurizedWaterReactor(0); - assertEquals(defaultSize, defaultReactor.getSize()); - assertEquals(defaultName, defaultReactor.getName()); - assertEquals(defaultDescription, defaultReactor.getDescription()); - assertEquals(defaultId, defaultReactor.getId()); - assertEquals(type, defaultReactor.getHDF5LWRTag()); - - // This is a test to show a valid creation of a reactor - reactor = new PressurizedWaterReactor(17); - assertEquals(17, reactor.getSize()); - assertEquals(defaultName, reactor.getName()); - assertEquals(defaultDescription, reactor.getDescription()); - assertEquals(defaultId, reactor.getId()); - assertEquals(type, reactor.getHDF5LWRTag()); - - } - - /** - *

- * This operation checks the operations for the GridLabelProvider. - *

- * - */ - @Test - public void checkLabels() { - // Local Declarations - PressurizedWaterReactor reactor = null; - ArrayList rowLabels = new ArrayList(); - ArrayList colLabels = new ArrayList(); - GridLabelProvider provider; - int reactorSize = 5; - - // Set the rowLabels - rowLabels.add("1"); - rowLabels.add("2"); - rowLabels.add("3"); - rowLabels.add("4"); - rowLabels.add("5"); - - // Set the colLabels - colLabels.add("A"); - colLabels.add("B"); - colLabels.add("C"); - colLabels.add("D"); - colLabels.add("E"); - - // Make a new reactor - reactor = new PressurizedWaterReactor(reactorSize); - // Check to see the default's gridLabelprovider - assertEquals(-1, reactor.getGridLabelProvider().getColumnFromLabel("A")); - assertEquals(reactorSize, reactor.getGridLabelProvider().getSize()); // Size - // the - // same - // as - // reactor. - // Very - // important! - - // Check default values for gridlabelprovider - provider = new GridLabelProvider(reactorSize); - // Adding the column and row labels - provider.setColumnLabels(colLabels); - provider.setRowLabels(rowLabels); - reactor.setGridLabelProvider(provider); - - // Check the row and column labels - assertTrue(this.doLabelsMatchLabelsInReactor(true, rowLabels, reactor)); - assertTrue(this.doLabelsMatchLabelsInReactor(false, colLabels, reactor)); - - // You can not set it to null or illegal size - reactor.setGridLabelProvider(null); - - // Check the row and column labels - assertTrue(this.doLabelsMatchLabelsInReactor(true, rowLabels, reactor)); - assertTrue(this.doLabelsMatchLabelsInReactor(false, colLabels, reactor)); - - reactor.setGridLabelProvider(new GridLabelProvider(reactorSize + 22)); - - // Stays the same as before - // Check the row and column labels - assertTrue(this.doLabelsMatchLabelsInReactor(true, rowLabels, reactor)); - assertTrue(this.doLabelsMatchLabelsInReactor(false, colLabels, reactor)); - - } - - /** - *

- * This operation checks the getter, setter, and adding of FuelAssemblies to - * the PWReactor. - *

- * - */ - @Test - public void checkFuelAssembly() { - - // Local Declarations - int reactorSize = 17; - PressurizedWaterReactor reactor = new PressurizedWaterReactor( - reactorSize); - FuelAssembly testComponent = new FuelAssembly(5), testComponent2 = new FuelAssembly( - 5), testComponent3 = new FuelAssembly(5); - String testComponentName = "Bob"; - String testComponentName2 = "Bill!"; - int rowLoc1 = 5, colLoc1 = 5; - int rowLoc2 = 6, colLoc2 = 6; - int testComponentId = 1000001; - - // Check the getter and setter for the pitch - - // Check default value of Pitch - assertEquals(0.0, reactor.getFuelAssemblyPitch(), 0.0); - - // Set the pitch to 0 and check setting - VALID - reactor.setFuelAssemblyPitch(0.0); - - assertEquals(0.0, reactor.getFuelAssemblyPitch(), 0.0); - - // Try to set to positive double - VALID - reactor.setFuelAssemblyPitch(100.01); - assertEquals(100.01, reactor.getFuelAssemblyPitch(), 0.0); - - // Try to set to negative double - NOT VALID - reactor.setFuelAssemblyPitch(-1.0); - assertEquals(100.01, reactor.getFuelAssemblyPitch(), 0.0); // Stays the - // same as - // the - // previous - // value - - // Check the default values of the Component under test - reactor = new PressurizedWaterReactor(reactorSize); - - // No assemblies should be added by default. Therefore every - // location is bad - for (int i = 0; i < reactorSize; i++) { - for (int j = 0; j < reactorSize; j++) { - assertNull(reactor.getAssemblyByLocation(AssemblyType.Fuel, i, - j)); - } - } - - // Check the names, should be empty! - assertEquals(0, reactor.getAssemblyNames(AssemblyType.Fuel).size()); - - // Try to get by name - valid string, empty string, and null - assertNull(reactor.getAssemblyByName(AssemblyType.Fuel, - "validNameThatDoesNotExistInThere152423")); - assertNull(reactor.getAssemblyByName(AssemblyType.Fuel, "")); - assertNull(reactor.getAssemblyByName(AssemblyType.Fuel, null)); - - // Set the name - testComponent.setName(testComponentName); - - // Add to the reactor - reactor.addAssembly(AssemblyType.Fuel, testComponent); - - // See that no location is set - assertNull(reactor.getAssemblyByLocation(AssemblyType.Fuel, rowLoc1, - colLoc1)); - // Check locations to be within bounds - assertNull(reactor.getAssemblyByLocation(AssemblyType.Fuel, -1, - reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.Fuel, 1, - reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.Fuel, - reactorSize + 25, reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.Fuel, - reactorSize - 1, reactorSize + 25)); - - // Set the valid location: - assertTrue(reactor.setAssemblyLocation(AssemblyType.Fuel, - testComponentName, rowLoc1, colLoc1)); - - // Try to break location setter - assertFalse(reactor.setAssemblyLocation(AssemblyType.Fuel, null, - rowLoc1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.Fuel, - testComponentName, -1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.Fuel, - testComponentName, rowLoc1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.Fuel, null, -1, - colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.Fuel, null, - rowLoc1, -1)); - assertFalse(reactor - .setAssemblyLocation(AssemblyType.Fuel, null, -1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.Fuel, - testComponentName, rowLoc1, reactorSize + 25)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.Fuel, - testComponentName, reactorSize + 25, colLoc1)); - - // The above erroneous settings does not change the original location of - // the first, valid set - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.Fuel, testComponentName))); - - // Check invalid overwrite of location: - testComponent2.setName(testComponentName2); - - // Add reactor, overwrite the previous testComponent's location - assertFalse(reactor.setAssemblyLocation(AssemblyType.Fuel, - testComponent2.getName(), rowLoc1, colLoc1)); - - // Check that it is the first, but not second - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.Fuel, testComponentName))); - - // Add it in there - assertTrue(reactor.addAssembly(AssemblyType.Fuel, testComponent2)); - - // Show that you can have at least 2 components in there - assertTrue(reactor.setAssemblyLocation(AssemblyType.Fuel, - testComponent2.getName(), rowLoc2, colLoc2)); - - // Check values - see the components are different and they reside in - // the table correctly - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.Fuel, testComponentName))); - assertTrue(testComponent2.equals(reactor.getAssemblyByName( - AssemblyType.Fuel, testComponentName2))); - - // Check the locations - assertTrue(testComponent.equals(reactor.getAssemblyByLocation( - AssemblyType.Fuel, rowLoc1, colLoc1))); - assertTrue(testComponent2.equals(reactor.getAssemblyByLocation( - AssemblyType.Fuel, rowLoc2, colLoc2))); - - // Check the names, should contain 2! - assertEquals(2, reactor.getAssemblyNames(AssemblyType.Fuel).size()); - assertEquals(testComponentName, - reactor.getAssemblyNames(AssemblyType.Fuel).get(0)); - assertEquals(testComponentName2, - reactor.getAssemblyNames(AssemblyType.Fuel).get(1)); - - // Check operation for null - reactor.addAssembly(AssemblyType.Fuel, null); - assertNull(reactor.getAssemblyByName(AssemblyType.Fuel, null)); // Make - // sure - // null - // does - // not work! - - // Finally, demonstrate what happens when a component of the same name - // is added, it should not overwrite the previous item in the table! - testComponent3.setName(testComponent.getName()); // Same name as the - // other - // component - testComponent3.setId(testComponentId); // Id should differ from - // testComponent! - assertFalse(testComponent.getId() == testComponentId); - - // Overwrite in table - assertFalse(reactor.addAssembly(AssemblyType.Fuel, testComponent3)); - - // Check that the object has not been overwritten - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.Fuel, testComponentName))); - assertFalse(testComponent3.equals(reactor.getAssemblyByName( - AssemblyType.Fuel, testComponentName))); - - // Test to remove components from the reactor - assertFalse(reactor.removeAssembly(AssemblyType.Fuel, null)); - assertFalse(reactor.removeAssembly(AssemblyType.Fuel, "")); - assertFalse(reactor.removeAssembly(AssemblyType.Fuel, - "!--+ANamETHaTDoESNOTEXIST19674376393<><(@#*)%^")); - - // Remove the first component - assertTrue(reactor.removeAssembly(AssemblyType.Fuel, - testComponent.getName())); - - // Check that it does not exist in the location or getting the name - assertNull(reactor.getAssemblyByLocation(AssemblyType.Fuel, rowLoc1, - colLoc1)); - assertNull(reactor.getAssemblyByName(AssemblyType.Fuel, - testComponent.getName())); - // Check size - assertEquals(1, reactor.getNumberOfAssemblies(AssemblyType.Fuel)); - - // It can now be overridden! - assertTrue(reactor.setAssemblyLocation(AssemblyType.Fuel, - testComponent2.getName(), rowLoc1, colLoc1)); - - // Show that the component's names can NOT overwrite each others - // locations - assertTrue(reactor.addAssembly(AssemblyType.Fuel, testComponent)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.Fuel, - testComponent.getName(), rowLoc1, colLoc1)); - - // Check the size, the respective locations - assertEquals( - testComponent2.getName(), - reactor.getAssemblyByLocation(AssemblyType.Fuel, rowLoc1, - colLoc1).getName()); - assertEquals( - testComponent2.getName(), - reactor.getAssemblyByLocation(AssemblyType.Fuel, rowLoc2, - colLoc2).getName()); - assertEquals(2, reactor.getNumberOfAssemblies(AssemblyType.Fuel)); - } - - /** - *

- * This operation checks the getter, setter, and adding of ControlBanks to - * the PWReactor. - *

- * - */ - @Test - public void checkControlBank() { - // Local Declarations - int reactorSize = 17; - PressurizedWaterReactor reactor = new PressurizedWaterReactor( - reactorSize); - ControlBank testComponent = new ControlBank(), testComponent2 = new ControlBank(), testComponent3 = new ControlBank(); - String testComponentName = "Bob"; - String testComponentName2 = "Bill!"; - int rowLoc1 = 5, colLoc1 = 5; - int rowLoc2 = 6, colLoc2 = 6; - int testComponentId = 1000001; - - // Check the default values of the Component under test - reactor = new PressurizedWaterReactor(reactorSize); - - // No assemblies should be added by default. Therefore every - // location is bad - for (int i = 0; i < reactorSize; i++) { - for (int j = 0; j < reactorSize; j++) { - assertNull(reactor.getAssemblyByLocation( - AssemblyType.ControlBank, i, j)); - } - } - - // Check the names, should be empty! - assertEquals(0, reactor.getAssemblyNames(AssemblyType.ControlBank) - .size()); - - // Try to get by name - valid string, empty string, and null - assertNull(reactor.getAssemblyByName(AssemblyType.ControlBank, - "validNameThatDoesNotExistInThere152423")); - assertNull(reactor.getAssemblyByName(AssemblyType.ControlBank, "")); - assertNull(reactor.getAssemblyByName(AssemblyType.ControlBank, null)); - - // Set the name - testComponent.setName(testComponentName); - - // Add to the reactor - reactor.addAssembly(AssemblyType.ControlBank, testComponent); - - // See that no location is set - assertNull(reactor.getAssemblyByLocation(AssemblyType.ControlBank, - rowLoc1, colLoc1)); - // Check locations to be within bounds - assertNull(reactor.getAssemblyByLocation(AssemblyType.ControlBank, -1, - reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.ControlBank, 1, - reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.ControlBank, - reactorSize + 25, reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.ControlBank, - reactorSize - 1, reactorSize + 25)); - - // Set the valid location: - assertTrue(reactor.setAssemblyLocation(AssemblyType.ControlBank, - testComponentName, rowLoc1, colLoc1)); - - // Try to break location setter - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, null, - rowLoc1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, - testComponentName, -1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, - testComponentName, rowLoc1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, null, - -1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, null, - rowLoc1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, null, - -1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, - testComponentName, rowLoc1, reactorSize + 25)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, - testComponentName, reactorSize + 25, colLoc1)); - - // The above erroneous settings does not change the original location of - // the first, valid set - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.ControlBank, testComponentName))); - - // Check invalid overwrite of location: - testComponent2.setName(testComponentName2); - - // Add reactor, overwrite the previous testComponent's location - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, - testComponent2.getName(), rowLoc1, colLoc1)); - - // Check that it is the first, but not second - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.ControlBank, testComponentName))); - - // Add it in there - assertTrue(reactor - .addAssembly(AssemblyType.ControlBank, testComponent2)); - - // Show that you can have at least 2 components in there - assertTrue(reactor.setAssemblyLocation(AssemblyType.ControlBank, - testComponent2.getName(), rowLoc2, colLoc2)); - - // Check values - see the components are different and they reside in - // the table correctly - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.ControlBank, testComponentName))); - assertTrue(testComponent2.equals(reactor.getAssemblyByName( - AssemblyType.ControlBank, testComponentName2))); - - // Check the locations - assertTrue(testComponent.equals(reactor.getAssemblyByLocation( - AssemblyType.ControlBank, rowLoc1, colLoc1))); - assertTrue(testComponent2.equals(reactor.getAssemblyByLocation( - AssemblyType.ControlBank, rowLoc2, colLoc2))); - - // Check the names, should contain 2! - assertEquals(2, reactor.getAssemblyNames(AssemblyType.ControlBank) - .size()); - assertEquals(testComponentName, - reactor.getAssemblyNames(AssemblyType.ControlBank).get(0)); - assertEquals(testComponentName2, - reactor.getAssemblyNames(AssemblyType.ControlBank).get(1)); - - // Check operation for null - reactor.addAssembly(AssemblyType.ControlBank, null); - assertNull(reactor.getAssemblyByName(AssemblyType.ControlBank, null)); // Make - // sure - // null - // does - // not work! - - // Finally, demonstrate what happens when a component of the same name - // is added, it should not overwrite the previous item in the table! - testComponent3.setName(testComponent.getName()); // Same name as the - // other - // component - testComponent3.setId(testComponentId); // Id should differ from - // testComponent! - assertFalse(testComponent.getId() == testComponentId); - - // Overwrite in table - assertFalse(reactor.addAssembly(AssemblyType.ControlBank, - testComponent3)); - - // Check that the object has not been overwritten - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.ControlBank, testComponentName))); - assertFalse(testComponent3.equals(reactor.getAssemblyByName( - AssemblyType.ControlBank, testComponentName))); - - // Test to remove components from the reactor - assertFalse(reactor.removeAssembly(AssemblyType.ControlBank, null)); - assertFalse(reactor.removeAssembly(AssemblyType.ControlBank, "")); - assertFalse(reactor.removeAssembly(AssemblyType.ControlBank, - "!--+ANamETHaTDoESNOTEXIST19674376393<><(@#*)%^")); - - // Remove the first component - assertTrue(reactor.removeAssembly(AssemblyType.ControlBank, - testComponent.getName())); - - // Check that it does not exist in the location or getting the name - assertNull(reactor.getAssemblyByLocation(AssemblyType.ControlBank, - rowLoc1, colLoc1)); - assertNull(reactor.getAssemblyByName(AssemblyType.ControlBank, - testComponent.getName())); - // Check size - assertEquals(1, reactor.getNumberOfAssemblies(AssemblyType.ControlBank)); - - // It can now be overridden! - assertTrue(reactor.setAssemblyLocation(AssemblyType.ControlBank, - testComponent2.getName(), rowLoc1, colLoc1)); - - // Show that the component's names can NOT overwrite each others - // locations - assertTrue(reactor.addAssembly(AssemblyType.ControlBank, testComponent)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.ControlBank, - testComponent.getName(), rowLoc1, colLoc1)); - - // Check the size, the respective locations - assertEquals( - testComponent2.getName(), - reactor.getAssemblyByLocation(AssemblyType.ControlBank, - rowLoc1, colLoc1).getName()); - assertEquals( - testComponent2.getName(), - reactor.getAssemblyByLocation(AssemblyType.ControlBank, - rowLoc2, colLoc2).getName()); - assertEquals(2, reactor.getNumberOfAssemblies(AssemblyType.ControlBank)); - - } - - /** - *

- * This operation checks the getter, setter, and adding ofInCoreInstruments - * to the PWReactor. - *

- * - */ - @Test - public void checkInCoreInstrument() { - // Local Declarations - int reactorSize = 17; - PressurizedWaterReactor reactor = new PressurizedWaterReactor( - reactorSize); - IncoreInstrument testComponent = new IncoreInstrument(), testComponent2 = new IncoreInstrument(), testComponent3 = new IncoreInstrument(); - String testComponentName = "Bob"; - String testComponentName2 = "Bill!"; - int rowLoc1 = 5, colLoc1 = 5; - int rowLoc2 = 6, colLoc2 = 6; - int testComponentId = 1000001; - - // Check the default values of the Component under test - reactor = new PressurizedWaterReactor(reactorSize); - - // No assemblies should be added by default. Therefore every - // location is bad - for (int i = 0; i < reactorSize; i++) { - for (int j = 0; j < reactorSize; j++) { - assertNull(reactor.getAssemblyByLocation( - AssemblyType.IncoreInstrument, i, j)); - } - } - - // Check the names, should be empty! - assertEquals(0, reactor.getAssemblyNames(AssemblyType.IncoreInstrument) - .size()); - - // Try to get by name - valid string, empty string, and null - assertNull(reactor.getAssemblyByName(AssemblyType.IncoreInstrument, - "validNameThatDoesNotExistInThere152423")); - assertNull(reactor.getAssemblyByName(AssemblyType.IncoreInstrument, "")); - assertNull(reactor.getAssemblyByName(AssemblyType.IncoreInstrument, - null)); - - // Set the name - testComponent.setName(testComponentName); - - // Add to the reactor - reactor.addAssembly(AssemblyType.IncoreInstrument, testComponent); - - // See that no location is set - assertNull(reactor.getAssemblyByLocation(AssemblyType.IncoreInstrument, - rowLoc1, colLoc1)); - // Check locations to be within bounds - assertNull(reactor.getAssemblyByLocation(AssemblyType.IncoreInstrument, - -1, reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.IncoreInstrument, - 1, reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.IncoreInstrument, - reactorSize + 25, reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.IncoreInstrument, - reactorSize - 1, reactorSize + 25)); - - // Set the valid location: - assertTrue(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - testComponentName, rowLoc1, colLoc1)); - - // Try to break location setter - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - null, rowLoc1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - testComponentName, -1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - testComponentName, rowLoc1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - null, -1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - null, rowLoc1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - null, -1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - testComponentName, rowLoc1, reactorSize + 25)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - testComponentName, reactorSize + 25, colLoc1)); - - // The above erroneous settings does not change the original location of - // the first, valid set - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.IncoreInstrument, testComponentName))); - - // Check invalid overwrite of location: - testComponent2.setName(testComponentName2); - - // Add reactor, overwrite the previous testComponent's location - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - testComponent2.getName(), rowLoc1, colLoc1)); - - // Check that it is the first, but not second - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.IncoreInstrument, testComponentName))); - - // Add it in there - assertTrue(reactor.addAssembly(AssemblyType.IncoreInstrument, - testComponent2)); - - // Show that you can have at least 2 components in there - assertTrue(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - testComponent2.getName(), rowLoc2, colLoc2)); - - // Check values - see the components are different and they reside in - // the table correctly - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.IncoreInstrument, testComponentName))); - assertTrue(testComponent2.equals(reactor.getAssemblyByName( - AssemblyType.IncoreInstrument, testComponentName2))); - - // Check the locations - assertTrue(testComponent.equals(reactor.getAssemblyByLocation( - AssemblyType.IncoreInstrument, rowLoc1, colLoc1))); - assertTrue(testComponent2.equals(reactor.getAssemblyByLocation( - AssemblyType.IncoreInstrument, rowLoc2, colLoc2))); - - // Check the names, should contain 2! - assertEquals(2, reactor.getAssemblyNames(AssemblyType.IncoreInstrument) - .size()); - assertEquals(testComponentName, - reactor.getAssemblyNames(AssemblyType.IncoreInstrument).get(0)); - assertEquals(testComponentName2, - reactor.getAssemblyNames(AssemblyType.IncoreInstrument).get(1)); - - // Check operation for null - reactor.addAssembly(AssemblyType.IncoreInstrument, null); - assertNull(reactor.getAssemblyByName(AssemblyType.IncoreInstrument, - null)); // Make sure null does - // not work! - - // Finally, demonstrate what happens when a component of the same name - // is added, it should not overwrite the previous item in the table! - testComponent3.setName(testComponent.getName()); // Same name as the - // other - // component - testComponent3.setId(testComponentId); // Id should differ from - // testComponent! - assertFalse(testComponent.getId() == testComponentId); - - // Overwrite in table - assertFalse(reactor.addAssembly(AssemblyType.IncoreInstrument, - testComponent3)); - - // Check that the object has not been overwritten - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.IncoreInstrument, testComponentName))); - assertFalse(testComponent3.equals(reactor.getAssemblyByName( - AssemblyType.IncoreInstrument, testComponentName))); - - // Test to remove components from the reactor - assertFalse(reactor.removeAssembly(AssemblyType.IncoreInstrument, null)); - assertFalse(reactor.removeAssembly(AssemblyType.IncoreInstrument, "")); - assertFalse(reactor.removeAssembly(AssemblyType.IncoreInstrument, - "!--+ANamETHaTDoESNOTEXIST19674376393<><(@#*)%^")); - - // Remove the first component - assertTrue(reactor.removeAssembly(AssemblyType.IncoreInstrument, - testComponent.getName())); - - // Check that it does not exist in the location or getting the name - assertNull(reactor.getAssemblyByLocation(AssemblyType.IncoreInstrument, - rowLoc1, colLoc1)); - assertNull(reactor.getAssemblyByName(AssemblyType.IncoreInstrument, - testComponent.getName())); - // Check size - assertEquals(1, - reactor.getNumberOfAssemblies(AssemblyType.IncoreInstrument)); - - // It can now be overridden! - assertTrue(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - testComponent2.getName(), rowLoc1, colLoc1)); - - // Show that the component's names can NOT overwrite each others - // locations - assertTrue(reactor.addAssembly(AssemblyType.IncoreInstrument, - testComponent)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - testComponent.getName(), rowLoc1, colLoc1)); - - // Check the size, the respective locations - assertEquals( - testComponent2.getName(), - reactor.getAssemblyByLocation(AssemblyType.IncoreInstrument, - rowLoc1, colLoc1).getName()); - assertEquals( - testComponent2.getName(), - reactor.getAssemblyByLocation(AssemblyType.IncoreInstrument, - rowLoc2, colLoc2).getName()); - assertEquals(2, - reactor.getNumberOfAssemblies(AssemblyType.IncoreInstrument)); - - } - - /** - *

- * This operation checks the getter, setter, and adding of - * RodClusterAssemblies to the PWReactor. - *

- * - */ - @Test - public void checkRodClusterAssembly() { - // Local Declarations - int reactorSize = 17; - PressurizedWaterReactor reactor = new PressurizedWaterReactor( - reactorSize); - RodClusterAssembly testComponent = new RodClusterAssembly(10), testComponent2 = new RodClusterAssembly( - 10), testComponent3 = new RodClusterAssembly(10); - String testComponentName = "Bob"; - String testComponentName2 = "Bill!"; - int rowLoc1 = 5, colLoc1 = 5; - int rowLoc2 = 6, colLoc2 = 6; - int testComponentId = 1000001; - - // Check the default values of the Component under test - reactor = new PressurizedWaterReactor(reactorSize); - - // No assemblies should be accessible or added to the list because every - // location is bad - for (int i = 0; i < reactorSize; i++) { - for (int j = 0; j < reactorSize; j++) { - assertNull(reactor.getAssemblyByLocation( - AssemblyType.RodCluster, i, j)); - } - } - - // Check the names, should be empty! - assertEquals(0, reactor.getAssemblyNames(AssemblyType.RodCluster) - .size()); - - // Try to get by name - valid string, empty string, and null - assertNull(reactor.getAssemblyByName(AssemblyType.RodCluster, - "validNameThatDoesNotExistInThere152423")); - assertNull(reactor.getAssemblyByName(AssemblyType.RodCluster, "")); - assertNull(reactor.getAssemblyByName(AssemblyType.RodCluster, null)); - - // Set the name - testComponent.setName(testComponentName); - - // Add to the reactor - reactor.addAssembly(AssemblyType.RodCluster, testComponent); - - // See that no location is set - assertNull(reactor.getAssemblyByLocation(AssemblyType.RodCluster, - rowLoc1, colLoc1)); - // Check locations to be within bounds - assertNull(reactor.getAssemblyByLocation(AssemblyType.RodCluster, -1, - reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.RodCluster, 1, - reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.RodCluster, - reactorSize + 25, reactorSize - 1)); - assertNull(reactor.getAssemblyByLocation(AssemblyType.RodCluster, - reactorSize - 1, reactorSize + 25)); - - // Set the valid location: - assertTrue(reactor.setAssemblyLocation(AssemblyType.RodCluster, - testComponentName, rowLoc1, colLoc1)); - - // Try to break location setter - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, null, - rowLoc1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, - testComponentName, -1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, - testComponentName, rowLoc1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, null, - -1, colLoc1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, null, - rowLoc1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, null, - -1, -1)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, - testComponentName, rowLoc1, reactorSize + 25)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, - testComponentName, reactorSize + 25, colLoc1)); - - // The above erroneous settings does not change the original location of - // the first, valid set - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.RodCluster, testComponentName))); - - // Check invalid overwrite of location: - testComponent2.setName(testComponentName2); - - // Add reactor, overwrite the previous testComponent's location - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, - testComponent2.getName(), rowLoc1, colLoc1)); - - // Check that it is the first, but not second - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.RodCluster, testComponentName))); - - // Add it in there - assertTrue(reactor.addAssembly(AssemblyType.RodCluster, testComponent2)); - - // Show that you can have at least 2 components in there - assertTrue(reactor.setAssemblyLocation(AssemblyType.RodCluster, - testComponent2.getName(), rowLoc2, colLoc2)); - - // Check values - see the components are different and they reside in - // the table correctly - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.RodCluster, testComponentName))); - assertTrue(testComponent2.equals(reactor.getAssemblyByName( - AssemblyType.RodCluster, testComponentName2))); - - // Check the locations - assertTrue(testComponent.equals(reactor.getAssemblyByLocation( - AssemblyType.RodCluster, rowLoc1, colLoc1))); - assertTrue(testComponent2.equals(reactor.getAssemblyByLocation( - AssemblyType.RodCluster, rowLoc2, colLoc2))); - - // Check the names, should contain 2! - assertEquals(2, reactor.getAssemblyNames(AssemblyType.RodCluster) - .size()); - assertEquals(testComponentName, - reactor.getAssemblyNames(AssemblyType.RodCluster).get(0)); - assertEquals(testComponentName2, - reactor.getAssemblyNames(AssemblyType.RodCluster).get(1)); - - // Check operation for null - reactor.addAssembly(AssemblyType.RodCluster, null); - assertNull(reactor.getAssemblyByName(AssemblyType.RodCluster, null)); // Make - // sure - // null - // does - // not work! - - // Finally, demonstrate what happens when a component of the same name - // is added, it should not overwrite the previous item in the table! - testComponent3.setName(testComponent.getName()); // Same name as the - // other - // component - testComponent3.setId(testComponentId); // Id should differ from - // testComponent! - assertFalse(testComponent.getId() == testComponentId); - - // Overwrite in table - assertFalse(reactor - .addAssembly(AssemblyType.RodCluster, testComponent3)); - - // Check that the object has not been overwritten - assertTrue(testComponent.equals(reactor.getAssemblyByName( - AssemblyType.RodCluster, testComponentName))); - assertFalse(testComponent3.equals(reactor.getAssemblyByName( - AssemblyType.RodCluster, testComponentName))); - - // Test to remove components from the reactor - assertFalse(reactor.removeAssembly(AssemblyType.RodCluster, null)); - assertFalse(reactor.removeAssembly(AssemblyType.RodCluster, "")); - assertFalse(reactor.removeAssembly(AssemblyType.RodCluster, - "!--+ANamETHaTDoESNOTEXIST19674376393<><(@#*)%^")); - - // Remove the first component - assertTrue(reactor.removeAssembly(AssemblyType.RodCluster, - testComponent.getName())); - - // Check that it does not exist in the location or getting the name - assertNull(reactor.getAssemblyByLocation(AssemblyType.RodCluster, - rowLoc1, colLoc1)); - assertNull(reactor.getAssemblyByName(AssemblyType.RodCluster, - testComponent.getName())); - // Check size - assertEquals(1, reactor.getNumberOfAssemblies(AssemblyType.RodCluster)); - - // It can now be overridden! - assertTrue(reactor.setAssemblyLocation(AssemblyType.RodCluster, - testComponent2.getName(), rowLoc1, colLoc1)); - - // Show that the component's names can NOT overwrite each others - // locations - assertTrue(reactor.addAssembly(AssemblyType.RodCluster, testComponent)); - assertFalse(reactor.setAssemblyLocation(AssemblyType.RodCluster, - testComponent.getName(), rowLoc1, colLoc1)); - - // Check the size, the respective locations - assertEquals( - testComponent2.getName(), - reactor.getAssemblyByLocation(AssemblyType.RodCluster, rowLoc1, - colLoc1).getName()); - assertEquals( - testComponent2.getName(), - reactor.getAssemblyByLocation(AssemblyType.RodCluster, rowLoc2, - colLoc2).getName()); - assertEquals(2, reactor.getNumberOfAssemblies(AssemblyType.RodCluster)); - - } - - /** - *

- * This operation demonstrates the behaviors listed with the overridden - * composite implementations from LWRComposite. - *

- * - */ - @Test - public void checkCompositeImplementations() { - // Local Declarations - int reactorSize = 17; - PressurizedWaterReactor reactor; - ArrayList compNames = new ArrayList(); - ArrayList components = new ArrayList(); - int numberOfDefaultComponents = 0; - - // Defaults for FuelAssembly - LWRComposite fuelComposite; - String compName = "Fuel Assemblies"; - String compDescription = "A Composite that contains many FuelAssembly Components."; - int compId = 2; - - // Setup component for comparison - fuelComposite = new LWRComposite(); - fuelComposite.setName(compName); - fuelComposite.setId(compId); - fuelComposite.setDescription(compDescription); - // Add to arraylist - compNames.add(fuelComposite.getName()); - components.add((Component) fuelComposite); - - // Defaults for ControlBank - LWRComposite controlComposite; - compName = "Control Banks"; - compDescription = "A Composite that contains many ControlBank Components."; - compId = 1; - - // Setup component for comparison - controlComposite = new LWRComposite(); - controlComposite.setName(compName); - controlComposite.setId(compId); - controlComposite.setDescription(compDescription); - // Add to arraylist - compNames.add(controlComposite.getName()); - components.add((Component) controlComposite); - - // Defaults for RCA - LWRComposite rodComposite; - compName = "Rod Cluster Assemblies"; - compDescription = "A Composite that contains many RodClusterAssembly Components."; - compId = 4; - - // Setup component for comparison - rodComposite = new LWRComposite(); - rodComposite.setName(compName); - rodComposite.setId(compId); - rodComposite.setDescription(compDescription); - // Add to arraylist - compNames.add(rodComposite.getName()); - components.add((Component) rodComposite); - - // Defaults for IncoreInstruments - LWRComposite coreComposite; - compName = "Incore Instruments"; - compDescription = "A Composite that contains many IncoreInstrument Components."; - compId = 3; - - // Setup component for comparison - coreComposite = new LWRComposite(); - coreComposite.setName(compName); - coreComposite.setId(compId); - coreComposite.setDescription(compDescription); - // Add to arraylist - compNames.add(coreComposite.getName()); - components.add((Component) coreComposite); - - // Setup the default number of components - numberOfDefaultComponents = components.size(); - - // Check the default Composite size and attributes on PWRAssembly - reactor = new PressurizedWaterReactor(reactorSize); - - // Has a size of numberOfDefaultComponents - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - - // It is equal to the default rodComposite for many of the composite - // getters - assertTrue(rodComposite.equals(reactor.getComponent(4))); - assertTrue(rodComposite.equals(reactor.getComponent(rodComposite - .getName()))); - - // It is equal to the default coreComposite for many of the composite - // getters - assertTrue(coreComposite.equals(reactor.getComponent(3))); - assertTrue(coreComposite.equals(reactor.getComponent(coreComposite - .getName()))); - - // It is equal to the default fuelComposite for many of the composite - // getters - assertTrue(fuelComposite.equals(reactor.getComponent(2))); - assertTrue(fuelComposite.equals(reactor.getComponent(fuelComposite - .getName()))); - - // It is equal to the default controlComposite for many of the composite - // getters - assertTrue(controlComposite.equals(reactor.getComponent(1))); - assertTrue(controlComposite.equals(reactor - .getComponent(controlComposite.getName()))); - - // Check general getters for the other pieces - assertTrue(compNames.size() == reactor.getComponentNames().size()); - assertTrue(compNames.containsAll(reactor.getComponentNames())); - - // These operations will show that these will not work for this class - - // Check addComponent - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - reactor.addComponent(new LWRComposite()); - // No size change! - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - - // Check removeComponent - id - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - reactor.removeComponent(1); - // No size change! - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - - // Check remove component - name - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - - // No size change! - assertEquals(numberOfDefaultComponents, reactor.getNumberOfComponents()); - - } - - /** - *

- * This is a utility operation that checks the operations for the labels on - * the reactor to see if they are equal to the passed labels. Keep in mind - * that the first parameter, rows, checks to see if its comparing rows - * (true) or columns (false). Returns true if the labels are equal, false - * otherwise. - *

- * - * @param rows - *

- * True if comparing rows. False if comparing columns. - *

- * @param labels - *

- * The labels to be compared to the rows or columns. - *

- * @param reactor - *

- * The reactor to be compared with. - *

- * @return

- * True if they are equal. False otherwise. - *

- */ - private boolean doLabelsMatchLabelsInReactor(boolean rows, - ArrayList labels, PressurizedWaterReactor reactor) { - int colCount = 0, rowCount = 0; - - if (rows == false) { - // Check you can get the column labels - for (int i = 0; i < labels.size(); i++) { - // Assert that the column labels are in order and are set - // correctly to the 0 indexed value of size - assertEquals(labels.get(i), reactor.getGridLabelProvider() - .getLabelFromColumn(i)); - assertEquals(i, reactor.getGridLabelProvider() - .getColumnFromLabel(labels.get(i))); - colCount++; - } - - // Assert that the size of the columns equals the size of the - // reactor - assertEquals(reactor.getSize(), colCount); - } - - else { - - // Check you can get the rowlabels - for (int i = 0; i < labels.size(); i++) { - // Assert that the row labels are in order and are set correctly - // to the 0 indexed value of size - assertEquals(labels.get(i), reactor.getGridLabelProvider() - .getLabelFromRow(i)); - assertEquals( - i, - reactor.getGridLabelProvider().getRowFromLabel( - labels.get(i))); - rowCount++; - } - - // Assert that the size of the rows equals the size of the reactor - assertEquals(reactor.getSize(), rowCount); - } - - return true; - - } - - /** - *

- * This operation checks equals() and hashCode() operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - PressurizedWaterReactor object, equalObject, unEqualObject, transitiveObject; - int size = 5; - - // Setup Values - FuelAssembly assembly = new FuelAssembly("FUELS!", size); - ControlBank bank = new ControlBank("BANKS!", 2, 5); - RodClusterAssembly rca = new RodClusterAssembly("RODS!", size); - IncoreInstrument instrument = new IncoreInstrument("Instruments!", - new Ring()); - - // Setup root object - object = new PressurizedWaterReactor(size); - object.addAssembly(AssemblyType.ControlBank, bank); - object.addAssembly(AssemblyType.Fuel, assembly); - object.addAssembly(AssemblyType.IncoreInstrument, instrument); - object.addAssembly(AssemblyType.RodCluster, rca); - object.setAssemblyLocation(AssemblyType.ControlBank, bank.getName(), 0, - 0); - object.setAssemblyLocation(AssemblyType.Fuel, assembly.getName(), 0, 0); - object.setAssemblyLocation(AssemblyType.RodCluster, rca.getName(), 0, 0); - object.setAssemblyLocation(AssemblyType.IncoreInstrument, - instrument.getName(), 0, 0); - - // Setup equalObject equal to object - equalObject = new PressurizedWaterReactor(size); - equalObject.addAssembly(AssemblyType.ControlBank, bank); - equalObject.addAssembly(AssemblyType.Fuel, assembly); - equalObject.addAssembly(AssemblyType.IncoreInstrument, instrument); - equalObject.addAssembly(AssemblyType.RodCluster, rca); - equalObject.setAssemblyLocation(AssemblyType.ControlBank, - bank.getName(), 0, 0); - equalObject.setAssemblyLocation(AssemblyType.Fuel, assembly.getName(), - 0, 0); - equalObject.setAssemblyLocation(AssemblyType.RodCluster, rca.getName(), - 0, 0); - equalObject.setAssemblyLocation(AssemblyType.IncoreInstrument, - instrument.getName(), 0, 0); - - // Setup transitiveObject equal to object - transitiveObject = new PressurizedWaterReactor(size); - transitiveObject.addAssembly(AssemblyType.ControlBank, bank); - transitiveObject.addAssembly(AssemblyType.Fuel, assembly); - transitiveObject.addAssembly(AssemblyType.IncoreInstrument, instrument); - transitiveObject.addAssembly(AssemblyType.RodCluster, rca); - transitiveObject.setAssemblyLocation(AssemblyType.ControlBank, - bank.getName(), 0, 0); - transitiveObject.setAssemblyLocation(AssemblyType.Fuel, - assembly.getName(), 0, 0); - transitiveObject.setAssemblyLocation(AssemblyType.RodCluster, - rca.getName(), 0, 0); - transitiveObject.setAssemblyLocation(AssemblyType.IncoreInstrument, - instrument.getName(), 0, 0); - - // Set its data, not equal to object - unEqualObject = new PressurizedWaterReactor(size); - unEqualObject.addAssembly(AssemblyType.ControlBank, bank); - unEqualObject.addAssembly(AssemblyType.Fuel, assembly); - unEqualObject.addAssembly(AssemblyType.IncoreInstrument, instrument); - unEqualObject.addAssembly(AssemblyType.RodCluster, rca); - unEqualObject.setAssemblyLocation(AssemblyType.ControlBank, - bank.getName(), 0, 0); - unEqualObject.setAssemblyLocation(AssemblyType.Fuel, - assembly.getName(), 0, 0); - unEqualObject.setAssemblyLocation(AssemblyType.RodCluster, - rca.getName(), 0, 0); - unEqualObject.setAssemblyLocation(AssemblyType.IncoreInstrument, - instrument.getName(), 0, 1); // Only difference here - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copy and clone routines. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - PressurizedWaterReactor object; - PressurizedWaterReactor copyObject = new PressurizedWaterReactor(0), clonedObject; - int size = 5; - - // Setup Values - FuelAssembly assembly = new FuelAssembly("FUELS!", size); - ControlBank bank = new ControlBank("BANKS!", 2, 5); - RodClusterAssembly rca = new RodClusterAssembly("RODS!", size); - IncoreInstrument instrument = new IncoreInstrument("Instruments!", - new Ring()); - - // Setup root object - object = new PressurizedWaterReactor(size); - object.addAssembly(AssemblyType.ControlBank, bank); - object.addAssembly(AssemblyType.Fuel, assembly); - object.addAssembly(AssemblyType.IncoreInstrument, instrument); - object.addAssembly(AssemblyType.RodCluster, rca); - object.setAssemblyLocation(AssemblyType.ControlBank, bank.getName(), 0, - 0); - object.setAssemblyLocation(AssemblyType.Fuel, assembly.getName(), 0, 0); - object.setAssemblyLocation(AssemblyType.RodCluster, rca.getName(), 0, 0); - object.setAssemblyLocation(AssemblyType.IncoreInstrument, - instrument.getName(), 0, 0); - - // Run the copy routine - copyObject = new PressurizedWaterReactor(0); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (PressurizedWaterReactor) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - int size = 5; - PressurizedWaterReactor reactor = new PressurizedWaterReactor(size); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = reactor.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - double fuelAssemblyPitch = 4; - - // Setup Assemblies, instruments, and controlBank locations - - // Size of the assemblies - int assemblySize = 3; - - // Locations - GridLocation loc1 = new GridLocation(0, 0); - GridLocation loc2 = new GridLocation(2, 0); - GridLocation loc3 = new GridLocation(0, 3); - GridLocation loc4 = new GridLocation(1, 1); - GridLocation loc5 = new GridLocation(3, 1); - GridLocation loc6 = new GridLocation(1, 3); - GridLocation loc7 = new GridLocation(3, 0); - GridLocation loc8 = new GridLocation(2, 3); - GridLocation loc9 = new GridLocation(3, 3); - - // Control Banks - ControlBank bank1 = new ControlBank("ControlBank1", 2, 4); - ControlBank bank2 = new ControlBank("ControlBank2", 3, 6); - - // IncoreInstruments - IncoreInstrument instruments1 = new IncoreInstrument("Instrument1", - new Ring("I am a thimble!")); - IncoreInstrument instruments2 = new IncoreInstrument("Instrument2", - new Ring("I am a thimble, too!")); - - // Fuel Assembly - FuelAssembly fuel1 = new FuelAssembly("Fuel Assembly 1", assemblySize); - FuelAssembly fuel2 = new FuelAssembly("Fuel Assembly 2", assemblySize); - - // RodClusterAssembly - RodClusterAssembly rod1 = new RodClusterAssembly("RCA 1", assemblySize); - RodClusterAssembly rod2 = new RodClusterAssembly("RCA 2", assemblySize); - - // Setup Duplicate Grids - LWRGridManager bankGridManager = new LWRGridManager(size); - LWRGridManager coreGridManager = new LWRGridManager(size); - LWRGridManager fuelGridManager = new LWRGridManager(size); - LWRGridManager rodGridManager = new LWRGridManager(size); - - // Setup names - bankGridManager.setName("Control Bank Grid"); - coreGridManager.setName("Incore Instrument Grid"); - fuelGridManager.setName("Fuel Assembly Grid"); - rodGridManager.setName("Rod Cluster Assembly Grid"); - - // Add objects to the grid for later comparison - // ControlBank - bankGridManager.addComponent(bank1, loc1); - bankGridManager.addComponent(bank2, loc2); - // Incore Instruments - coreGridManager.addComponent(instruments1, loc3); - coreGridManager.addComponent(instruments2, loc4); - // Fuel Assemblies - fuelGridManager.addComponent(fuel1, loc5); - fuelGridManager.addComponent(fuel2, loc6); - // RodClusterAssemblies - rodGridManager.addComponent(rod1, loc7); - rodGridManager.addComponent(rod2, loc8); - - // Setup LWRComposite clones - LWRComposite bankComposite = new LWRComposite(); - LWRComposite coreComposite = new LWRComposite(); - LWRComposite fuelComposite = new LWRComposite(); - LWRComposite rodComposite = new LWRComposite(); - - // Setup names, descriptions, ids and add pieces - // Control Bank - bankComposite.setName("Control Banks"); - bankComposite - .setDescription("A Composite that contains many ControlBank Components."); - bankComposite.setId(1); - bankComposite.addComponent(bank1); - bankComposite.addComponent(bank2); - // Incore Instrument - coreComposite.setName("Incore Instruments"); - coreComposite - .setDescription("A Composite that contains many IncoreInstrument Components."); - coreComposite.setId(3); - coreComposite.addComponent(instruments1); - coreComposite.addComponent(instruments2); - // Fuel Composite - fuelComposite.setName("Fuel Assemblies"); - fuelComposite - .setDescription("A Composite that contains many FuelAssembly Components."); - fuelComposite.setId(2); - fuelComposite.addComponent(fuel1); - fuelComposite.addComponent(fuel2); - // Rod Cluster Assemblies - rodComposite.setName("Rod Cluster Assemblies"); - rodComposite - .setDescription("A Composite that contains many RodClusterAssembly Components."); - rodComposite.setId(4); - rodComposite.addComponent(rod1); - rodComposite.addComponent(rod2); - - // Setup Rows and Columns - ArrayList rowLabels = new ArrayList(); - ArrayList columnLabels = new ArrayList(); - - // Setup row labels - rowLabels.add("A"); - rowLabels.add("B"); - rowLabels.add("C"); - rowLabels.add("D"); - rowLabels.add("E"); - - // Setup col labels - rowLabels.add("1"); - rowLabels.add("2"); - rowLabels.add("3"); - rowLabels.add("4"); - rowLabels.add("OVER 9000!"); - - GridLabelProvider provider = new GridLabelProvider(size); - provider.setRowLabels(rowLabels); - provider.setColumnLabels(columnLabels); - provider.setName("Grid Labels"); - - // Setup reactor - reactor.setName(name); - reactor.setId(id); - reactor.setDescription(description); - reactor.setGridLabelProvider(provider); - reactor.setFuelAssemblyPitch(fuelAssemblyPitch); - - // Add pieces to reactor - // Control Bank - reactor.addAssembly(AssemblyType.ControlBank, bank1); - reactor.addAssembly(AssemblyType.ControlBank, bank2); - // IncoreInstrument - reactor.addAssembly(AssemblyType.IncoreInstrument, instruments1); - reactor.addAssembly(AssemblyType.IncoreInstrument, instruments2); - // Fuel Assemblies - reactor.addAssembly(AssemblyType.Fuel, fuel1); - reactor.addAssembly(AssemblyType.Fuel, fuel2); - // RodClusterAssemblies - reactor.addAssembly(AssemblyType.RodCluster, rod1); - reactor.addAssembly(AssemblyType.RodCluster, rod2); - - // Setup Positions - // Control Bank - reactor.setAssemblyLocation(AssemblyType.ControlBank, bank1.getName(), - loc1.getRow(), loc1.getColumn()); - reactor.setAssemblyLocation(AssemblyType.ControlBank, bank2.getName(), - loc2.getRow(), loc2.getColumn()); - // IncoreInstrument - reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - instruments1.getName(), loc3.getRow(), loc3.getColumn()); - reactor.setAssemblyLocation(AssemblyType.IncoreInstrument, - instruments2.getName(), loc4.getRow(), loc4.getColumn()); - // Fuel Assemblies - reactor.setAssemblyLocation(AssemblyType.Fuel, fuel1.getName(), - loc5.getRow(), loc5.getColumn()); - reactor.setAssemblyLocation(AssemblyType.Fuel, fuel2.getName(), - loc6.getRow(), loc6.getColumn()); - // RodClusterAssemblies - reactor.setAssemblyLocation(AssemblyType.RodCluster, rod1.getName(), - loc7.getRow(), loc7.getColumn()); - reactor.setAssemblyLocation(AssemblyType.RodCluster, rod2.getName(), - loc8.getRow(), loc8.getColumn()); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - // Fail here - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(reactor.getWriteableChildren()); - // Check Children - use equals comparison - // Check size - assertEquals(9, reactor.getWriteableChildren().size()); - // Check contents - assertTrue(rodComposite.equals(reactor.getWriteableChildren().get(0))); - assertTrue(coreComposite.equals(reactor.getWriteableChildren().get(1))); - assertTrue(fuelComposite.equals(reactor.getWriteableChildren().get(2))); - assertTrue(bankComposite.equals(reactor.getWriteableChildren().get(3))); - assertTrue(provider.equals(reactor.getWriteableChildren().get(4))); - - assertTrue(reactor.getWriteableChildren().contains(bankGridManager)); - assertTrue(reactor.getWriteableChildren().contains(fuelGridManager)); - assertTrue(reactor.getWriteableChildren().contains(coreGridManager)); - assertTrue(reactor.getWriteableChildren().contains(rodGridManager)); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(reactor.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(6, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - fuelAssemblyPitch - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "fuelAssemblyPitch"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(fuelAssemblyPitch, - ((double[]) attribute.getValue())[0], 1.2); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - size - attribute = (Attribute) h5Group.getMetadata().get(5); - assertEquals(attribute.getName(), "size"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(size, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(reactor.writeAttributes(null, h5Group)); - assertFalse(reactor.writeAttributes(h5File, null)); - - // Check dataSet. - assertFalse(reactor.writeDatasets(null, null)); - - // Check Group Creation - H5Group group = reactor.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root reactor - assertEquals(reactor.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - int size = 5; - PressurizedWaterReactor component = new PressurizedWaterReactor(size); - PressurizedWaterReactor newComponent = new PressurizedWaterReactor(-1); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - double fuelAssemblyPitch = 4; - H5Group subGroup = null; - String testFileName = "testWrite.h5"; - - // Setup Assemblies, instruments, and controlBank locations - - // Size of the assemblies - int assemblySize = 3; - - // Locations - GridLocation loc1 = new GridLocation(0, 0); - GridLocation loc2 = new GridLocation(2, 0); - GridLocation loc3 = new GridLocation(0, 3); - GridLocation loc4 = new GridLocation(1, 1); - GridLocation loc5 = new GridLocation(3, 1); - GridLocation loc6 = new GridLocation(1, 3); - GridLocation loc7 = new GridLocation(3, 0); - GridLocation loc8 = new GridLocation(2, 3); - GridLocation loc9 = new GridLocation(3, 3); - - // Control Banks - ControlBank bank1 = new ControlBank("ControlBank1", 2, 4); - ControlBank bank2 = new ControlBank("ControlBank2", 3, 6); - - // IncoreInstruments - IncoreInstrument instruments1 = new IncoreInstrument("Instrument1", - new Ring("I am a thimble!")); - IncoreInstrument instruments2 = new IncoreInstrument("Instrument2", - new Ring("I am a thimble, too!")); - - // Fuel Assembly - FuelAssembly fuel1 = new FuelAssembly("Fuel Assembly 1", assemblySize); - FuelAssembly fuel2 = new FuelAssembly("Fuel Assembly 2", assemblySize); - - // RodClusterAssembly - RodClusterAssembly rod1 = new RodClusterAssembly("RCA 1", assemblySize); - RodClusterAssembly rod2 = new RodClusterAssembly("RCA 2", assemblySize); - - // Setup Duplicate Grids - LWRGridManager bankGridManager = new LWRGridManager(size); - LWRGridManager coreGridManager = new LWRGridManager(size); - LWRGridManager fuelGridManager = new LWRGridManager(size); - LWRGridManager rodGridManager = new LWRGridManager(size); - - // Setup names - bankGridManager.setName("Control Bank Grid"); - coreGridManager.setName("Incore Instrument Grid"); - fuelGridManager.setName("Fuel Assembly Grid"); - rodGridManager.setName("Rod Cluster Assembly Grid"); - - // Add objects to the grid for later comparison - // ControlBank - bankGridManager.addComponent(bank1, loc1); - bankGridManager.addComponent(bank2, loc2); - // Incore Instruments - coreGridManager.addComponent(instruments1, loc3); - coreGridManager.addComponent(instruments2, loc4); - // Fuel Assemblies - fuelGridManager.addComponent(fuel1, loc5); - fuelGridManager.addComponent(fuel2, loc6); - // RodClusterAssemblies - rodGridManager.addComponent(rod1, loc7); - rodGridManager.addComponent(rod2, loc8); - - // Setup LWRComposite clones - LWRComposite bankComposite = new LWRComposite(); - LWRComposite coreComposite = new LWRComposite(); - LWRComposite fuelComposite = new LWRComposite(); - LWRComposite rodComposite = new LWRComposite(); - - // Setup names, descriptions, ids and add pieces - // Control Bank - bankComposite.setName("Control Banks"); - bankComposite - .setDescription("A Composite that contains many ControlBank Components."); - bankComposite.setId(1); - bankComposite.addComponent(bank1); - bankComposite.addComponent(bank2); - // Incore Instrument - coreComposite.setName("Incore Instruments"); - coreComposite - .setDescription("A Composite that contains many IncoreInstrument Components."); - coreComposite.setId(3); - coreComposite.addComponent(instruments1); - coreComposite.addComponent(instruments2); - // Fuel Composite - fuelComposite.setName("Fuel Assemblies"); - fuelComposite - .setDescription("A Composite that contains many FuelAssembly Components."); - fuelComposite.setId(2); - fuelComposite.addComponent(fuel1); - fuelComposite.addComponent(fuel2); - // Rod Cluster Assemblies - rodComposite.setName("Rod Cluster Assemblies"); - rodComposite - .setDescription("A Composite that contains many RodClusterAssembly Components."); - rodComposite.setId(4); - rodComposite.addComponent(rod1); - rodComposite.addComponent(rod2); - - // Setup Rows and Columns - ArrayList rowLabels = new ArrayList(); - ArrayList columnLabels = new ArrayList(); - - // Setup row labels - rowLabels.add("A"); - rowLabels.add("B"); - rowLabels.add("C"); - rowLabels.add("D"); - rowLabels.add("E"); - - // Setup col labels - rowLabels.add("1"); - rowLabels.add("2"); - rowLabels.add("3"); - rowLabels.add("4"); - rowLabels.add("OVER 9000!"); - - GridLabelProvider provider = new GridLabelProvider(size); - provider.setRowLabels(rowLabels); - provider.setColumnLabels(columnLabels); - provider.setName("Grid Labels"); - - // Setup reactor - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setGridLabelProvider(provider); - component.setFuelAssemblyPitch(fuelAssemblyPitch); - - // Add pieces to component - // Control Bank - component.addAssembly(AssemblyType.ControlBank, bank1); - component.addAssembly(AssemblyType.ControlBank, bank2); - // IncoreInstrument - component.addAssembly(AssemblyType.IncoreInstrument, instruments1); - component.addAssembly(AssemblyType.IncoreInstrument, instruments2); - // Fuel Assemblies - component.addAssembly(AssemblyType.Fuel, fuel1); - component.addAssembly(AssemblyType.Fuel, fuel2); - // RodClusterAssemblies - component.addAssembly(AssemblyType.RodCluster, rod1); - component.addAssembly(AssemblyType.RodCluster, rod2); - - // Setup Positions - // Control Bank - component.setAssemblyLocation(AssemblyType.ControlBank, - bank1.getName(), loc1.getRow(), loc1.getColumn()); - component.setAssemblyLocation(AssemblyType.ControlBank, - bank2.getName(), loc2.getRow(), loc2.getColumn()); - // IncoreInstrument - component.setAssemblyLocation(AssemblyType.IncoreInstrument, - instruments1.getName(), loc3.getRow(), loc3.getColumn()); - component.setAssemblyLocation(AssemblyType.IncoreInstrument, - instruments2.getName(), loc4.getRow(), loc4.getColumn()); - // Fuel Assemblies - component.setAssemblyLocation(AssemblyType.Fuel, fuel1.getName(), - loc5.getRow(), loc5.getColumn()); - component.setAssemblyLocation(AssemblyType.Fuel, fuel2.getName(), - loc6.getRow(), loc6.getColumn()); - // RodClusterAssemblies - component.setAssemblyLocation(AssemblyType.RodCluster, rod1.getName(), - loc7.getRow(), loc7.getColumn()); - component.setAssemblyLocation(AssemblyType.RodCluster, rod2.getName(), - loc8.getRow(), loc8.getColumn()); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup PWRAssembly with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup size attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "size", - size); - - // Setup fuelAssemblyPitch attribute - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, - "fuelAssemblyPitch", fuelAssemblyPitch); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertFalse(newComponent.readDatasets(null)); - assertTrue(newComponent.readChild(bankComposite)); - assertTrue(newComponent.readChild(fuelComposite)); - assertTrue(newComponent.readChild(rodComposite)); - assertTrue(newComponent.readChild(coreComposite)); - assertTrue(newComponent.readChild(provider)); - assertTrue(newComponent.readChild(bankGridManager)); - assertTrue(newComponent.readChild(coreGridManager)); - assertTrue(newComponent.readChild(fuelGridManager)); - assertTrue(newComponent.readChild(rodGridManager)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Try to break the readChild operation - assertFalse(newComponent.readChild(null)); - assertTrue(newComponent.readChild(new LWRGridManager(size))); - assertTrue(newComponent.readChild(new LWRComposite())); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } - - /** - *

- * An operation that checks the data providers by location. - *

- * - */ - @Test - public void checkDataProviderLocations() { - - // Local Declarations - - // Create a PWReactor, add a few pieces and setup their locations. - int size = 5; - PressurizedWaterReactor object = new PressurizedWaterReactor(size); - - int row1 = 0, col1 = 0, row2 = 2, col2 = 2, row3 = 4, col3 = 3; - - // Setup Values - FuelAssembly assembly = new FuelAssembly("FUELS!", size); - ControlBank bank = new ControlBank("BANKS!", 2, 5); - RodClusterAssembly rca = new RodClusterAssembly("RODS!", size); - IncoreInstrument instrument = new IncoreInstrument("Instruments!", - new Ring()); - - // Setup object - object = new PressurizedWaterReactor(size); - object.addAssembly(AssemblyType.ControlBank, bank); - object.addAssembly(AssemblyType.Fuel, assembly); - object.addAssembly(AssemblyType.IncoreInstrument, instrument); - object.addAssembly(AssemblyType.RodCluster, rca); - - // Try to get at locations that do not exist yet for empty - assertNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row1, col1)); - assertNull(object.getAssemblyDataProviderAtLocation(AssemblyType.Fuel, - row1, col1)); - assertNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.RodCluster, row1, col1)); - assertNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.IncoreInstrument, row1, col1)); - - // Setup locations - object.setAssemblyLocation(AssemblyType.ControlBank, bank.getName(), - row1, col1); - object.setAssemblyLocation(AssemblyType.Fuel, assembly.getName(), row1, - col1); - object.setAssemblyLocation(AssemblyType.RodCluster, rca.getName(), - row1, col1); - object.setAssemblyLocation(AssemblyType.IncoreInstrument, - instrument.getName(), row1, col1); - - object.setAssemblyLocation(AssemblyType.ControlBank, bank.getName(), - row2, col2); - object.setAssemblyLocation(AssemblyType.Fuel, assembly.getName(), row2, - col2); - object.setAssemblyLocation(AssemblyType.RodCluster, rca.getName(), - row2, col2); - object.setAssemblyLocation(AssemblyType.IncoreInstrument, - instrument.getName(), row2, col2); - - object.setAssemblyLocation(AssemblyType.ControlBank, bank.getName(), - row3, col3); - object.setAssemblyLocation(AssemblyType.Fuel, assembly.getName(), row3, - col3); - object.setAssemblyLocation(AssemblyType.RodCluster, rca.getName(), - row3, col3); - object.setAssemblyLocation(AssemblyType.IncoreInstrument, - instrument.getName(), row3, col3); - - // Setup some data - LWRData data1 = new LWRData("Feature1111"); - LWRData data2 = new LWRData("Feature1111"); - LWRData data3 = new LWRData("Feature1113"); - LWRData data4 = new LWRData("Feature1114"); - - // Setup some times - double time1 = 0.0; - double time2 = 0.1; - - // Setup duplicate LWRDataProvider - LWRDataProvider provider = new LWRDataProvider(); - provider.addData(data1, time1); - provider.addData(data2, time1); - provider.addData(data3, time1); - provider.addData(data3, time2); - provider.addData(data4, time2); - - // Try to get data by location - // Try to get at locations that do not exist yet for empty - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row1, col1)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.Fuel, row1, col1)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.RodCluster, row1, col1)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.IncoreInstrument, row1, col1)); - - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row2, col2)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.Fuel, row2, col2)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.RodCluster, row2, col2)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.IncoreInstrument, row2, col2)); - - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row3, col3)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.Fuel, row3, col3)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.RodCluster, row3, col3)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.IncoreInstrument, row3, col3)); - - // Add some data - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row1, col1)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row1, col1)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row1, col1)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row1, col1)); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row1, col1)); - object.getAssemblyDataProviderAtLocation(AssemblyType.ControlBank, - row1, col1).addData(data1, time1); - assertNotNull(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row1, col1)); - object.getAssemblyDataProviderAtLocation(AssemblyType.ControlBank, - row1, col1).addData(data2, time1); - - object.getAssemblyDataProviderAtLocation(AssemblyType.ControlBank, - row1, col1).addData(data3, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.ControlBank, - row1, col1).addData(data3, time2); - object.getAssemblyDataProviderAtLocation(AssemblyType.ControlBank, - row1, col1).addData(data4, time2); - - // Add some data - object.getAssemblyDataProviderAtLocation(AssemblyType.Fuel, row1, col1) - .addData(data1, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.Fuel, row1, col1) - .addData(data2, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.Fuel, row1, col1) - .addData(data3, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.Fuel, row1, col1) - .addData(data3, time2); - object.getAssemblyDataProviderAtLocation(AssemblyType.Fuel, row1, col1) - .addData(data4, time2); - - // Add some data - object.getAssemblyDataProviderAtLocation(AssemblyType.RodCluster, row1, - col1).addData(data1, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.RodCluster, row1, - col1).addData(data2, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.RodCluster, row1, - col1).addData(data3, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.RodCluster, row1, - col1).addData(data3, time2); - object.getAssemblyDataProviderAtLocation(AssemblyType.RodCluster, row1, - col1).addData(data4, time2); - - // Add some data - object.getAssemblyDataProviderAtLocation(AssemblyType.IncoreInstrument, - row1, col1).addData(data1, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.IncoreInstrument, - row1, col1).addData(data2, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.IncoreInstrument, - row1, col1).addData(data3, time1); - object.getAssemblyDataProviderAtLocation(AssemblyType.IncoreInstrument, - row1, col1).addData(data3, time2); - object.getAssemblyDataProviderAtLocation(AssemblyType.IncoreInstrument, - row1, col1).addData(data4, time2); - - // Do comparisons - assertTrue(object.getAssemblyDataProviderAtLocation( - AssemblyType.ControlBank, row1, col1).equals(provider)); - assertTrue(object.getAssemblyDataProviderAtLocation(AssemblyType.Fuel, - row1, col1).equals(provider)); - assertTrue(object.getAssemblyDataProviderAtLocation( - AssemblyType.RodCluster, row1, col1).equals(provider)); - assertTrue(object.getAssemblyDataProviderAtLocation( - AssemblyType.IncoreInstrument, row1, col1).equals(provider)); - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PressurizedWaterReactorXMLAdapterTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PressurizedWaterReactorXMLAdapterTester.java deleted file mode 100644 index 1f2011a07..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/PressurizedWaterReactorXMLAdapterTester.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.pwr; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactorXMLAdapter; -import org.junit.Test; - -/** - * This class tests the custom XML adapter for PressurizedWaterReactors. - * - * @author Jay Jay Billings - * - */ -public class PressurizedWaterReactorXMLAdapterTester { - - /** - * This operation tests the PWR XML adapter used by the persistence - * provider. - */ - @Test - public void checkPWRAdapter() { - - PressurizedWaterReactorXMLAdapter adapter = new PressurizedWaterReactorXMLAdapter(); - PressurizedWaterReactor reactor = new PressurizedWaterReactor(15); - - try { - assertNotNull(adapter.marshal(reactor)); - assertNotNull(adapter.unmarshal("Test string")); - } catch (Exception e) { - // Complain - e.printStackTrace(); - // And fail - fail(); - } - - return; - } - -} diff --git a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/RodClusterAssemblyTester.java b/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/RodClusterAssemblyTester.java deleted file mode 100644 index 1e50e6bcb..000000000 --- a/org.eclipse.ice.reactor.test/src/org/eclipse/ice/reactor/test/pwr/RodClusterAssemblyTester.java +++ /dev/null @@ -1,641 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.test.pwr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import ncsa.hdf.object.Attribute; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.Group; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.GridLocation; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRComposite; -import org.eclipse.ice.reactor.LWRGridManager; -import org.eclipse.ice.reactor.LWRRod; -import org.eclipse.ice.reactor.pwr.RodClusterAssembly; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class tests the RodClusterAssembly operations. - *

- * - * @author Scott Forest Hull II - */ -public class RodClusterAssemblyTester { - // An @BeforeClass that sets up the library path. This should be added to - // the model or removed if it can be fixed for local machine - @BeforeClass - public static void beforeClass() { - - } - - /** - *

- * This operation checks the constructors and their default values. - *

- * - */ - @Test - public void checkConstruction() { - // Local Declarations - RodClusterAssembly assembly; - String defaultName = "RodClusterAssembly"; - String defaultDesc = "RodClusterAssembly's Description"; - int defaultId = 1; - int defaultSize = 1; - HDF5LWRTagType type = HDF5LWRTagType.ROD_CLUSTER_ASSEMBLY; - - // New names - String newName = "Super RodClusterAssembly!"; - int newSize = 10; - - // Check the default constructor with a default size. Check default - // values - // Test non-nullary constructor - size - assembly = new RodClusterAssembly(defaultSize); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with new size - // Test non-nullary constructor - size - assembly = new RodClusterAssembly(newSize); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(newSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with bad size - negative - // Test non-nullary constructor - size - assembly = new RodClusterAssembly(-1); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); // Defaults - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with name and size - // Test non-nullary constructor - name, size - assembly = new RodClusterAssembly(defaultName, defaultSize); - // Check values - assertEquals(defaultName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with bad name - // Test non-nullary constructor - name, size - assembly = new RodClusterAssembly(null, defaultSize); - // Check values - assertEquals(defaultName, assembly.getName()); // Defaults - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(defaultSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - // Check with new name and size - // Test non-nullary constructor - name, size - assembly = new RodClusterAssembly(newName, newSize); - // Check values - assertEquals(newName, assembly.getName()); - assertEquals(defaultDesc, assembly.getDescription()); - assertEquals(defaultId, assembly.getId()); - assertEquals(newSize, assembly.getSize()); - assertEquals(type, assembly.getHDF5LWRTag()); - - } - - /** - *

- * This operation checks the equals and hashCode operations. - *

- * - */ - @Test - public void checkEquality() { - - // Local Declarations - RodClusterAssembly object, equalObject, unEqualObject, transitiveObject; - String name = "Billy"; - int size = 5; - LWRRod rod = new LWRRod("Bob the rod"); - - // Setup root object - object = new RodClusterAssembly(name, size); - object.addLWRRod(rod); - object.setLWRRodLocation(rod.getName(), 0, 0); - - // Setup equalObject equal to object - equalObject = new RodClusterAssembly(name, size); - equalObject.addLWRRod(rod); - equalObject.setLWRRodLocation(rod.getName(), 0, 0); - - // Setup transitiveObject equal to object - transitiveObject = new RodClusterAssembly(name, size); - transitiveObject.addLWRRod(rod); - transitiveObject.setLWRRodLocation(rod.getName(), 0, 0); - - // Set its data, not equal to object - unEqualObject = new RodClusterAssembly(name, size); - // Uses the default rod - - // Assert that these two objects are equal - assertTrue(object.equals(equalObject)); - - // Assert that two unequal objects returns false - assertFalse(object.equals(unEqualObject)); - - // Check that equals() is Reflexive - // x.equals(x) = true - assertTrue(object.equals(object)); - - // Check that equals() is Symmetric - // x.equals(y) = true iff y.equals(x) = true - assertTrue(object.equals(equalObject) && equalObject.equals(object)); - - // Check that equals() is Transitive - // x.equals(y) = true, y.equals(z) = true => x.equals(z) = true - if (object.equals(equalObject) && equalObject.equals(transitiveObject)) { - assertTrue(object.equals(transitiveObject)); - } else { - fail(); - } - - // Check the Consistent nature of equals() - assertTrue(object.equals(equalObject) && object.equals(equalObject) - && object.equals(equalObject)); - assertTrue(!object.equals(unEqualObject) - && !object.equals(unEqualObject) - && !object.equals(unEqualObject)); - - // Assert checking equality with null value returns false - assertFalse(object==null); - - // Assert that two equal objects have the same hashcode - assertTrue(object.equals(equalObject) - && object.hashCode() == equalObject.hashCode()); - - // Assert that hashcode is consistent - assertTrue(object.hashCode() == object.hashCode()); - - // Assert that hashcodes are different for unequal objects - assertFalse(object.hashCode() == unEqualObject.hashCode()); - - } - - /** - *

- * This operation checks the copying and clone operations. - *

- * - */ - @Test - public void checkCopying() { - - // Local Declarations - RodClusterAssembly object, copyObject, clonedObject; - String name = "Billy"; - int size = 5; - LWRRod rod = new LWRRod("Bob the rod"); - - // Setup root object - object = new RodClusterAssembly(name, size); - object.addLWRRod(rod); - object.setLWRRodLocation(rod.getName(), 0, 0); - - // Run the copy routine - copyObject = new RodClusterAssembly(1); - copyObject.copy(object); - - // Check contents - assertTrue(object.equals(copyObject)); - - // Run the clone routine - clonedObject = (RodClusterAssembly) object.clone(); - - // Check contents - assertTrue(object.equals(clonedObject)); - - // Pass null for the copy routine - copyObject.copy(null); - - // Show that nothing as changed - assertTrue(object.equals(copyObject)); - - } - - /** - *

- * This operation checks the HDF5 writing operations. - *

- * - */ - @Test - public void checkHDF5Writeables() { - - // Local Declarations - int size = 5; - RodClusterAssembly assembly = new RodClusterAssembly(size); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = assembly.getHDF5LWRTag(); - Attribute attribute = null; - String attributeValue = null; - LWRRod rod1 = new LWRRod("Rod1"); - LWRRod rod2 = new LWRRod("Rod2"); - LWRRod rod3 = new LWRRod("Rod3"); - GridLocation loc1 = new GridLocation(0, 0); - GridLocation loc2 = new GridLocation(2, 0); - GridLocation loc3 = new GridLocation(0, 3); - double rodPitch = 4; - String testFileName = "testWrite.h5"; - - // Setup duplicate manager for comparison testing - LWRGridManager manager = new LWRGridManager(size); - manager.setName("LWRRod Grid"); - manager.addComponent(rod1, loc1); - manager.addComponent(rod2, loc2); - manager.addComponent(rod3, loc3); - - // Setup assembly - assembly.setName(name); - assembly.setId(id); - assembly.setDescription(description); - assembly.addLWRRod(rod1); - assembly.addLWRRod(rod2); - assembly.addLWRRod(rod3); - assembly.setRodPitch(rodPitch); - - // Setup duplicate for assembly's grid location - assembly.setLWRRodLocation(rod1.getName(), loc1.getRow(), - loc1.getColumn()); - assembly.setLWRRodLocation(rod2.getName(), loc2.getRow(), - loc2.getColumn()); - assembly.setLWRRodLocation(rod3.getName(), loc3.getRow(), - loc3.getColumn()); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + testFileName); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - // Fail here - e1.printStackTrace(); - fail(); - } - - // Check to see if it has any children - assertNotNull(assembly.getWriteableChildren()); - // Check Children - assertEquals(2, assembly.getWriteableChildren().size()); - assertTrue(rod3.equals(assembly.getWriteableChildren().get(0) - .getWriteableChildren().get(0))); - assertTrue(rod2.equals(assembly.getWriteableChildren().get(0) - .getWriteableChildren().get(1))); - assertTrue(rod1.equals(assembly.getWriteableChildren().get(0) - .getWriteableChildren().get(2))); - LWRGridManager otherManager = (LWRGridManager) assembly - .getWriteableChildren().get(1); - assertTrue(manager.equals(otherManager)); - - // Check writing attributes - H5Group h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - // Pass the group and file to the writer for attributes - // See that it passes - assertTrue(assembly.writeAttributes(h5File, h5Group)); - - // Close group and then reopen - try { - h5File.close(); - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Get the group again - h5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Check attributes - assertEquals("/", h5Group.getName()); - - try { - // Show that there are no other groups made at this time - assertEquals(0, h5Group.getMemberList().size()); - - // Check the meta data - assertEquals(6, h5Group.getMetadata().size()); - - // Check String attribute - HDF5LWRTag - attribute = (Attribute) h5Group.getMetadata().get(0); - assertEquals(attribute.getName(), "HDF5LWRTag"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(tag.toString(), attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - description - attribute = (Attribute) h5Group.getMetadata().get(1); - assertEquals(attribute.getName(), "description"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(description, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check String Attribute - name - attribute = (Attribute) h5Group.getMetadata().get(3); - assertEquals(attribute.getName(), "name"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_STRING); - attributeValue = ((String[]) attribute.getValue())[0]; - assertEquals(name, attributeValue); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - id - attribute = (Attribute) h5Group.getMetadata().get(2); - assertEquals(attribute.getName(), "id"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(id, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Double Attribute - rodPitch - attribute = (Attribute) h5Group.getMetadata().get(4); - assertEquals(attribute.getName(), "rodPitch"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_FLOAT); - assertEquals(rodPitch, ((double[]) attribute.getValue())[0], 1.2); - // Reset Values - attribute = null; - attributeValue = null; - - // Check Integer Attribute - size - attribute = (Attribute) h5Group.getMetadata().get(5); - assertEquals(attribute.getName(), "size"); - assertEquals(attribute.getType().getDatatypeClass(), - Datatype.CLASS_INTEGER); - assertEquals(size, ((int[]) attribute.getValue())[0]); - // Reset Values - attribute = null; - attributeValue = null; - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - // Make sure the writeAttributes fail for invalid stuff - assertFalse(assembly.writeAttributes(null, h5Group)); - assertFalse(assembly.writeAttributes(h5File, null)); - - // Check Group Creation - H5Group group = assembly.createGroup(h5File, h5Group); - // See that the previous group has a group - assertEquals(1, h5Group.getMemberList().size()); - // Check that it has the same name as the root assembly - assertEquals(assembly.getName(), h5Group.getMemberList().get(0) - .toString()); - // Check that the returned group is a Group but no members - assertEquals(0, group.getMemberList().size()); - assertEquals(0, ((Group) h5Group.getMemberList().get(0)) - .getMemberList().size()); - - // Close that h5 file! - try { - h5File.close(); - } catch (Exception e1) { - e1.printStackTrace(); - dataFile.delete(); - fail(); - } - - // Delete the file once you are done - dataFile.delete(); - - } - - /** - *

- * Removes the test.h5 file after the tests fails (to keep the workspace - * clean). - *

- * - */ - @AfterClass - public static void afterClass() { - - // Cleans up the datafile if it exists due to a failed test - File dataFile = new File(System.getProperty("user.dir") - + System.getProperty("file.separator") + "test.h5"); - - // If it exists, remove it - if (dataFile.exists()) { - dataFile.delete(); - } - - } - - /** - *

- * This operation checks the HDF5 readable operations. - *

- * - */ - @Test - public void checkHDF5Readables() { - - // Local Declarations - int size = 5; - RodClusterAssembly component = new RodClusterAssembly(size); - RodClusterAssembly newComponent = new RodClusterAssembly(-1); - String name = "Bob the Builder"; - String description = "Can he fix it?"; - int id = 4; - HDF5LWRTagType tag = component.getHDF5LWRTag(); - H5Group subGroup = null; - LWRRod rod1 = new LWRRod("Rod1"); - LWRRod rod2 = new LWRRod("Rod2"); - LWRRod rod3 = new LWRRod("Rod3"); - GridLocation loc1 = new GridLocation(0, 0); - GridLocation loc2 = new GridLocation(2, 0); - GridLocation loc3 = new GridLocation(0, 3); - double rodPitch = 4; - - // Setup Component - component.setName(name); - component.setId(id); - component.setDescription(description); - component.setRodPitch(rodPitch); - - component.addLWRRod(rod1); - component.addLWRRod(rod2); - component.addLWRRod(rod3); - - // Setup duplicate for assembly's grid location - component.setLWRRodLocation(rod1.getName(), loc1.getRow(), - loc1.getColumn()); - component.setLWRRodLocation(rod2.getName(), loc2.getRow(), - loc2.getColumn()); - component.setLWRRodLocation(rod3.getName(), loc3.getRow(), - loc3.getColumn()); - - // Setup GridManager - LWRGridManager manager = new LWRGridManager(size); - manager.setName("LWRRod Grid"); - manager.addComponent(rod1, loc1); - manager.addComponent(rod2, loc2); - manager.addComponent(rod3, loc3); - - // Setup Composite - LWRComposite composite = new LWRComposite(); - composite.setName("LWRRods"); - composite.setDescription("A Composite that contains many LWRRods."); - composite.setId(1); - composite.addComponent(rod1); - composite.addComponent(rod2); - composite.addComponent(rod3); - - // Setup the HDF5 File - String separator = System.getProperty("file.separator"); - File dataFile = new File(System.getProperty("user.dir") + separator - + "test.h5"); - URI uri = dataFile.toURI(); - H5File h5File = HdfFileFactory.createH5File(uri); - try { - h5File.open(); - } catch (Exception e1) { - e1.printStackTrace(); - fail(); - } - - // Setup PWRAssembly with Data in the Group - - H5Group parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - try { - // Setup the subGroup - subGroup = (H5Group) h5File.createGroup(name, parentH5Group); - - // Setup the subGroup's attributes - - // Setup Tag Attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "HDF5LWRTag", tag.toString()); - - // Setup name attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, "name", - name); - - // Setup id attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "id", id); - - // Setup description attribute - HdfWriterFactory.writeStringAttribute(h5File, subGroup, - "description", description); - - // Setup size attribute - HdfWriterFactory.writeIntegerAttribute(h5File, subGroup, "size", - size); - - // Setup rodPitch attribute - HdfWriterFactory.writeDoubleAttribute(h5File, subGroup, "rodPitch", - rodPitch); - - // Close group and then reopen - h5File.close(); - h5File.open(); - parentH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // Get the subGroup - subGroup = (H5Group) parentH5Group.getMemberList().get(0); - - // Read information - assertTrue(newComponent.readAttributes(subGroup)); - assertTrue(newComponent.readChild(manager)); - assertTrue(newComponent.readChild(composite)); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Try to break the readChild operation - assertFalse(newComponent.readChild(null)); - assertTrue(newComponent.readChild(new LWRGridManager(size))); - assertTrue(newComponent.readChild(new LWRComposite())); - - // Check with setup component - assertTrue(component.equals(newComponent)); - - // Now, lets try to set an erroneous H5Group with missing data - subGroup.getMetadata().remove(1); - - // Run it through - assertFalse(newComponent.readAttributes(subGroup)); - // Check it does not change - assertTrue(component.equals(newComponent)); - - // Check for nullaries - assertFalse(newComponent.readAttributes(null)); - // Doesn't change anything - assertTrue(component.equals(newComponent)); - - h5File.close(); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - - dataFile.delete(); - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/.classpath b/org.eclipse.ice.reactor/.classpath deleted file mode 100644 index ad32c83a7..000000000 --- a/org.eclipse.ice.reactor/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.reactor/.gitignore b/org.eclipse.ice.reactor/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.reactor/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.reactor/.project b/org.eclipse.ice.reactor/.project deleted file mode 100644 index 662e7d920..000000000 --- a/org.eclipse.ice.reactor/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.ice.reactor - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.reactor/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.reactor/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c90853614..000000000 --- a/org.eclipse.ice.reactor/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Mon Nov 19 10:16:15 EST 2012 -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/org.eclipse.ice.reactor/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.reactor/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index f03c7129c..000000000 --- a/org.eclipse.ice.reactor/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Nov 19 10:16:15 EST 2012 -eclipse.preferences.version=1 -resolve.requirebundle=false -pluginProject.extensions=false diff --git a/org.eclipse.ice.reactor/META-INF/MANIFEST.MF b/org.eclipse.ice.reactor/META-INF/MANIFEST.MF deleted file mode 100644 index 085967a81..000000000 --- a/org.eclipse.ice.reactor/META-INF/MANIFEST.MF +++ /dev/null @@ -1,17 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Reactor -Bundle-SymbolicName: org.eclipse.ice.reactor -Bundle-Version: 2.1.8 -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Export-Package: org.eclipse.ice.reactor, - org.eclipse.ice.reactor.bwr, - org.eclipse.ice.reactor.pwr -Import-Package: org.eclipse.ice.datastructures.ICEObject, - org.eclipse.ice.reactor.pwr, - org.slf4j;version="1.7.2" -Require-Bundle: org.eclipse.ice.datastructures, - org.eclipse.ice.io;visibility:=reexport, - org.eclipse.ice.analysistool;bundle-version="2.0.0" -Bundle-ActivationPolicy: lazy -Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.reactor/about.html b/org.eclipse.ice.reactor/about.html deleted file mode 100644 index b47b18406..000000000 --- a/org.eclipse.ice.reactor/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

July 1, 2014

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/org.eclipse.ice.reactor/build.properties b/org.eclipse.ice.reactor/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/org.eclipse.ice.reactor/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/org.eclipse.ice.reactor/pom.xml b/org.eclipse.ice.reactor/pom.xml deleted file mode 100644 index 865287e7f..000000000 --- a/org.eclipse.ice.reactor/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.reactor - 2.1.8 - eclipse-plugin - \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/AssemblyType.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/AssemblyType.java deleted file mode 100644 index 2c86b123b..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/AssemblyType.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -/** - *

- * An enumeration of all of the nuclear reactor assembly types supported by this - * package. - *

- * - * @author Jay Jay Billings - */ -public enum AssemblyType { - /** - *

- * Nuclear fuel components, purchased from fuel vendors and shuffled around - * each fuel cycle. A typical fuel assembly is loaded fresh with either - * integral or discrete burnable absorbers, is operated for three fuel - * cycles in a different core location each cycle, and is discharged to the - * spent fuel pool one a substantial amount of its initial fissile material - * is depleted. - *

- * - */ - Fuel, - /** - *

- * A control bank used to regulate the power within the reactor. - *

- * - */ - ControlBank, - /** - *

- * Used for power distribution monitoring inside of the reactor core. - * Typically there are movable fission chambers that create electronic - * signals from neutron flux fields. Incore detectors have to be replaced as - * needed, when their sensitivity decreases substantially due to depletion - * of the fissile material. - *

- * - */ - IncoreInstrument, - /** - *

- * Clusters of (typically neutron absorbing) rods when are placed in and - * moved between fuel assemblies during refueling outages. - *

- * - */ - RodCluster -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/FeatureSet.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/FeatureSet.java deleted file mode 100644 index 648f06efe..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/FeatureSet.java +++ /dev/null @@ -1,247 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; - -import org.eclipse.ice.analysistool.IData; - -/** - *

- * A convience class that holds a IData for the java collection on the - * LWRComponent. This is an intermediary class designed to hold the list of - * LWRData for the same types of features. The getFeature() operation on LWRData - * should return the same value as the getName() operation on this class. - *

- * - * @author Scott Forest Hull II - */ -public class FeatureSet { - /** - *

- * List of IData associated with this feature set. - *

- * - */ - private ArrayList iData; - /** - *

- * The name of the feature. - *

- * - */ - private String name; - - /** - *

- * The constructor. The passed value must be a valid feature set, otherwise - * it will set the feature name to null and not allow the addition of any - * IData. - *

- * - * @param feature - */ - public FeatureSet(String feature) { - - // If the feature is not null and is not empty, set as the name - if (feature != null && !feature.trim().isEmpty()) { - this.name = feature; - } - - // Setup the IData arrayList - this.iData = new ArrayList(); - - } - - /** - *

- * Returns the name of the feature whose data is contained by this set. - *

- * - * @return The name of the feature. - */ - public String getName() { - - return name; - - } - - /** - *

- * Returns the IDatas associated with the FeatureSet. - *

- * - * @return

- * The returned IData list. - *

- */ - public ArrayList getIData() { - - // If the name is null, then return a cloned copy of the array so that - // data can not be externally added/deleted. - if (this.name == null) { - return new ArrayList(iData); - } - - // Otherwise, return iData. - return this.iData; - - } - - /** - *

- * Adds IData to the list within the feature set. The name of the feature - * must match the name set on the FeatureSet, otherwise this operation will - * fail. Returns true if operation was successful, false otherwise. - *

- * - * @param iData - *

- * The data associated with the feature set. - *

- * @return True if the data was added, false otherwise. - */ - public boolean addIData(IData iData) { - - // If the iData is not null and the feature name is equal to the iData's - // feature, add the piece to the IData. - if (iData != null && iData.getFeature().equals(this.name)) { - this.iData.add(iData); - - // Operation was successful - return true; - } - - // Failed - return false; - - } - - /** - *

- * Overrides the equals operation to check the attributes on this object - * with another object of the same type. Returns true if the objects are - * equal. False otherwise. - *

- * - * @param otherObject - *

- * The object to be compared. - *

- * @return

- * True if otherObject is equal. False otherwise. - *

- */ - @Override - public boolean equals(Object otherObject) { - - // Local declarations - FeatureSet featureSet; - boolean retVal = false; - - // If they are equal to the same object, return true - if (this == otherObject) { - return true; - } - - // If this object is an instance of the FeatureSet, cast it. - // Make sure it is also not null - if (otherObject != null && otherObject instanceof FeatureSet) { - featureSet = (FeatureSet) otherObject; - - // Check values - retVal = (this.name.equals(featureSet.name) && this.iData - .equals(featureSet.iData)); - - } - - // Return retVal - return retVal; - - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return

- * The hash of the object. - *

- */ - @Override - public int hashCode() { - - // Local Declarations - int hash = 31; - - // Calculate hash - hash += 31 * this.name.hashCode(); - hash += 31 * this.iData.hashCode(); - - // return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(FeatureSet otherObject) { - - // If null, return - if (otherObject == null) { - return; - } - - // Setup the name and iData - this.name = otherObject.name; - this.iData.clear(); - - // Deep copy iData - for (int i = 0; i < otherObject.iData.size(); i++) { - this.iData.add(otherObject.iData.get(i)); - } - - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return

- * The newly instantiated copied object. - *

- */ - @Override - public Object clone() { - - // Local Declarations - FeatureSet set = new FeatureSet(null); - - // Copy contents - set.copy(this); - - // Return newly instantiated object - return set; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/GridLabelProvider.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/GridLabelProvider.java deleted file mode 100644 index fa2333428..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/GridLabelProvider.java +++ /dev/null @@ -1,612 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; - -import javax.xml.bind.annotation.XmlTransient; - -import ncsa.hdf.object.Dataset; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.h5.H5Datatype; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; - -/** - *

- * This is a utility class that provides labels on a 2D grid for rows and - * columns. This class should be considered as a piece designed specifically for - * interactions with the GUI and should not be considered as a means to override - * the ability to set rows and column indicie types. - *

- *

- * The constructor takes a size that is N squared, and defaults to a positive - * number if the size is non-positive or zero. - *

- * - * @author Scott Forest Hull II - */ -public class GridLabelProvider extends LWRComponent { - /** - *

- * An ArrayList of Strings of length size containing the label for each - * column position from left to right. - *

- * - */ - @XmlTransient - private ArrayList columnLabels; - /** - *

- * An ArrayList of Strings of length size containing the label for each row - * position from top to bottom. - *

- * - */ - @XmlTransient - private ArrayList rowLabels; - /** - *

- * The size for the row and column label ArrayLists. - *

- * - */ - @XmlTransient - private int size; - - // Private Attributes for specifying row and column types - @XmlTransient - private static final String ROW_LABELS_NAME = "Row Labels"; - @XmlTransient - private static final String COLUMN_LABELS_NAME = "Column Labels"; - @XmlTransient - private static final String LABELS_GROUP_NAME = "Labels"; - - /** - * A default constructor that should ONLY be used for persistence and - * testing. It is equivalent to GridLabelProvider(15). - */ - public GridLabelProvider() { - this(15); - } - - /** - *

- * A parameterized constructor. - *

- * - * @param size - *

- * The size for the row and column label ArrayLists. - *

- */ - public GridLabelProvider(int size) { - - // Setup LWRComponent info - this.name = "GridLabelProvider 1"; - this.description = "GridLabelProvider 1's Description"; - this.id = 1; - this.HDF5LWRTag = HDF5LWRTagType.GRID_LABEL_PROVIDER; - - // Default values - this.size = 1; - this.columnLabels = new ArrayList(); - this.rowLabels = new ArrayList(); - - // Check size - can't be less than or equal to 0. - if (size > 0) { - this.size = size; - } - - // Setup the HDF5LWRTagType to correct type - this.HDF5LWRTag = HDF5LWRTagType.GRID_LABEL_PROVIDER; - - } - - /** - *

- * Returns the column position from a label. Returns -1 if the label is not - * found or if the label is null. - *

- * - * @param columnLabel - *

- * The column label. - *

- * @return

- * The column position. - *

- */ - public int getColumnFromLabel(String columnLabel) { - // If the column label is in there, or -1 if it does not exist - if (columnLabel != null) { - return this.columnLabels.indexOf(columnLabel); - } - - return -1; - } - - /** - *

- * Returns the row position from a label. Returns -1 if the label is not - * found or if the label is null. - *

- * - * @param rowLabel - *

- * The row label. - *

- * @return

- * The row position. - *

- */ - public int getRowFromLabel(String rowLabel) { - - // If the row label is in there, or -1 if it does not exist - if (rowLabel != null) { - return this.rowLabels.indexOf(rowLabel); - } - - return -1; - - } - - /** - *

- * Returns the label at position column. - *

- * - * @param column - *

- * The column position. - *

- * @return

- * The label at the provided column position. - *

- */ - public String getLabelFromColumn(int column) { - // Return the column label or null if it does not exist - // Make sure its within the size - // Make sure the column labels also have stuff in the arraylist - if (column >= 0 && column < this.size && !this.columnLabels.isEmpty()) { - return this.columnLabels.get(column); - } - - // Return null if not bound correctly - return null; - } - - /** - *

- * Returns the label at position row. - *

- * - * @param row - *

- * The row position. - *

- * @return

- * The label at the provided row position. - *

- */ - public String getLabelFromRow(int row) { - - // Return the row label or null if it does not exist - // Make sure its within the size - // Make sure the row labels also have stuff in the arraylist - if (row >= 0 && row < this.size && !this.rowLabels.isEmpty()) { - return this.rowLabels.get(row); - } - - // Return null if not bound correctly - return null; - - } - - /** - *

- * Sets the array of row labels ordered from top to bottom. - *

- * - * @param rowLabels - *

- * The array of row labels ordered from top to bottom. - *

- */ - public void setRowLabels(ArrayList rowLabels) { - - // If the rowLabels passed are not null and equal in size, then add them - if (rowLabels != null && rowLabels.size() == this.size) { - this.rowLabels.clear(); // Clear out the current list - for (int i = 0; i < rowLabels.size(); i++) { - this.rowLabels.add(rowLabels.get(i)); - } - } - - } - - /** - *

- * Sets the array of column labels ordered from left to right. - *

- * - * @param columnLabels - *

- * The array of column labels ordered from left to right. - *

- */ - public void setColumnLabels(ArrayList columnLabels) { - - // If the columnLabels passed are not null and equal in size, then add - // them - if (columnLabels != null && columnLabels.size() == this.size) { - this.columnLabels.clear(); // Clear out the current list - for (int i = 0; i < columnLabels.size(); i++) { - this.columnLabels.add(columnLabels.get(i)); - } - } - - } - - /** - *

- * Returns the size for the row and column label ArrayLists. - *

- * - * @return

- * The size for the row and column label ArrayLists. - *

- */ - public int getSize() { - return this.size; - - - } - - /** - *

- * Overrides the equals operation to check the attributes on this object - * with another object of the same type. Returns true if the objects are - * equal. False otherwise. - *

- * - * @param otherObject - *

- * The object to be compared. - *

- * @return

- * True if otherObject is equal. False otherwise. - *

- */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - GridLabelProvider provider; - boolean retVal = false; - - // If they are equal to the same object, return true - if (this == otherObject) { - return true; - } - - // If the object is null or not an instance of this object, return false - if (otherObject != null || otherObject instanceof GridLabelProvider) { - - // Cast to local object - provider = (GridLabelProvider) otherObject; - - // Get the equality of the values - retVal = (super.equals(otherObject) && this.size == provider.size - && this.rowLabels.equals(provider.rowLabels) && this.columnLabels - .equals(provider.columnLabels)); - } - - // Return the equality - return retVal; - - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return

- * The hash of the object. - *

- */ - @Override - public int hashCode() { - - // Local Declarations - int hash = super.hashCode(); - - // Hash the values on the object - hash += 31 * this.size; - hash += 31 * this.rowLabels.hashCode(); - hash += 31 * this.columnLabels.hashCode(); - - // Return the hashCode - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(GridLabelProvider otherObject) { - - // If object is null, return - if (otherObject == null) { - return; - } - - // Copy contents - super - super.copy(otherObject); - - // Copy contents - - // Deep copy columnLabels - this.columnLabels.clear(); - for (int i = 0; i < otherObject.columnLabels.size(); i++) { - this.columnLabels.add(new String(otherObject.columnLabels.get(i))); - } - - // Deep copy rowLabels - this.rowLabels.clear(); - for (int i = 0; i < otherObject.rowLabels.size(); i++) { - this.rowLabels.add(new String(otherObject.rowLabels.get(i))); - } - - this.size = otherObject.size; - - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return

- * The newly instantiated copied object. - *

- */ - @Override - public Object clone() { - - // Local Declarations - GridLabelProvider provider = new GridLabelProvider(0); - - // Copy contents - provider.copy(this); - - // Return the newly instantiated object - return provider; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeIntegerAttribute(h5File, h5Group, "size", - size); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeDatasets(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeDatasets(H5File h5File, H5Group h5Group) { - boolean flag = true; - - // Return if the file or group is null - if (h5File == null || h5Group == null) { - return false; - } - - flag &= super.writeDatasets(h5File, h5Group); - - H5Group labelsGroup = HdfWriterFactory.createH5Group(h5File, - GridLabelProvider.LABELS_GROUP_NAME, h5Group); - - // If there are no columns or rows set, then return true - if (this.columnLabels.isEmpty() && this.rowLabels.isEmpty()) { - return true; - } - - try { - - // Initialize row and column String arrays - String[] rowValues = new String[this.size]; - String[] columnValues = new String[this.size]; - - // Declare biggest size variables - int biggestRowSize = 0; - int biggestColumnSize = 0; - - // Check to see if we have any labels and - // that they are of the right size - if (this.rowLabels.size() != this.size - || this.columnLabels.size() != this.size) { - - // If not return false - return false; - } - - // Loop over the labels - for (int i = 0; i < size; i++) { - - // Assign the current label - String rowLabel = this.rowLabels.get(i); - String columnLabel = this.columnLabels.get(i); - - // Get the biggest size label - biggestRowSize = Math.max(biggestRowSize, rowLabel.length()); - biggestColumnSize = Math.max(biggestColumnSize, - columnLabel.length()); - - // Assign the label to the String array - rowValues[i] = rowLabel; - columnValues[i] = columnLabel; - - } - - // Create datatypes for the row and column labels - H5Datatype rowH5Datatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, biggestRowSize, Datatype.NATIVE, - Datatype.NATIVE); - - H5Datatype columnH5Datatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, biggestColumnSize, Datatype.NATIVE, - Datatype.NATIVE); - - // Set the dimensions of the String array - long[] dims = { size }; - - // Create the row and column datasets - Dataset h5RowDataset = h5File.createScalarDS(ROW_LABELS_NAME, - labelsGroup, rowH5Datatype, dims, null, null, 0, null); - Dataset h5ColumnDataset = h5File.createScalarDS(COLUMN_LABELS_NAME, - labelsGroup, columnH5Datatype, dims, null, null, 0, null); - - // Write the String arrays to the right dataset - h5RowDataset.write(rowValues); - h5ColumnDataset.write(columnValues); - - } catch (Exception e) { - - // Print stack trace - logger.error(getClass().getName() + " Exception!",e); - - // Return false - return false; - } - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readDatasets(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readDatasets(H5Group h5Group) { - - // Call super - boolean flag = super.readDatasets(h5Group); - Object rowData = null; - Object colData = null; - - if (h5Group == null) { - return false; - } - - H5Group labelGroup = HdfReaderFactory.getChildH5Group(h5Group, - LABELS_GROUP_NAME); - - // No GridLabelProviders were written, return true - if (labelGroup == null) { - return true; - } - // Grab datasets - Dataset rowSet = HdfReaderFactory.getDataset(labelGroup, - ROW_LABELS_NAME); - Dataset colSet = HdfReaderFactory.getDataset(labelGroup, - COLUMN_LABELS_NAME); - - // If the group is null, return false - // Verify that the two pieces - // are datasets and the contents are in there correctly - if (labelGroup == null || rowSet == null || colSet == null - || !flag) { - return false; - } - - // Iterate over the list and set up the rows and columns into their - // arraylist - - try { - rowData = rowSet.getData(); - colData = colSet.getData(); - } catch (Exception e) { - logger.error(getClass().getName() + " Exception!",e); - return false; - } - - // If the data is null, return false - if (rowData == null || colData == null) { - return false; - } - - // Iterate over the list and check the arrayLists - for (int i = 0; i < this.size; i++) { - // Check contents of rowData and columnData at X - // Add the data when necessary - this.rowLabels.add(((String[]) rowData)[i]); - this.columnLabels.add(((String[]) colData)[i]); - } - - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - Integer size = HdfReaderFactory.readIntegerAttribute(h5Group, "size"); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (size == null || !flag || h5Group == null) { - return false; - } - // If everything is valid, then set data - this.size = size.intValue(); - - // Reset labels - this.columnLabels.clear(); - this.rowLabels.clear(); - - return true; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/GridLocation.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/GridLocation.java deleted file mode 100644 index 656259ee3..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/GridLocation.java +++ /dev/null @@ -1,307 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - - -/** - *

- * The GridLocation class represents a location on a Cartesian grid. This class - * also stores an implementation of the IDataProvider, called LWRDataProvider. - * This class was designed with two specific roles in mind. - *

- *

- * 1.) To provide a wrapper for Rows and Columns (i, j or x, y) on a cartesean - * grid. - *

- *

- * 2.) To provide state point data at particular positions within a grid. - *

- *

- * As 1.) is easy to understand, 2.) is a bit complex. To optimize memory - * efficiency, the LWRDataProvider should be used to represent changes in - * statepointdata at a particular position for a specific type of delegated sub - * component. - *

- *

- * For example, in most reactors there are only about 3-5 different types of - * "Rods" used within a reaction. On an assembly, these rods are used multiple - * times for different positions. These rods also contain materials that - * decompose over a reaction's lifetime. For a 17x17 assembly, it is a waste of - * memory to store 17x17 amount of rods for each location along with unique - * state point data (LWRDataProvider) for each rod (especially if most of them - * are the same type of rod). It is preferred to store 5 rods and to set their - * positions based on name within that assembly and to change the statepoint - * data on the assembly through this class over the life cycle of the reaction. - * This improves memory efficiency and separates the model from the - * "experimental data". - *

- *

- * Keep in mind, you can do both. However, the second method improves IO times - * in magnitudes and is more optimal. - *

- * - * @author Scott Forest Hull II - */ -public class GridLocation implements Comparable { - /** - *

- * The row position. - *

- * - */ - private int row; - /** - *

- * The column position. - *

- * - */ - private int col; - - /** - *

- * The LWRDataProvider. - *

- * - */ - private LWRDataProvider lWRDataProvider; - - /** - *

- * The Constructor. - *

- * - * @param row - *

- * The row position. - *

- * @param col - *

- * The column position. - *

- */ - public GridLocation(int row, int col) { - - // Set default values - this.row = 1; - this.col = 1; - - // Check row and column - if (row >= 0) { - this.row = row; - } - if (col >= 0) { - this.col = col; - } - - // Setup LWRDataProvider - this.lWRDataProvider = new LWRDataProvider(); - - } - - /** - *

- * Returns the row position. - *

- * - * @return

- * The row position. - *

- */ - public int getRow() { - - return this.row; - } - - /** - *

- * Returns the column position. - *

- * - * @return

- * The column position. - *

- */ - public int getColumn() { - - return this.col; - } - - /** - *

- * Overrides the equals operation to check the attributes on this object - * with another object of the same type. Returns true if the objects are - * equal. False otherwise. - *

- * - * @param otherObject - *

- * The object to be compared. - *

- * @return

- * True if otherObject is equal. False otherwise. - *

- */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - GridLocation location; - boolean retVal = false; - - // If they are equal to the same object, return true - if (this == otherObject) { - return true; - } - - // Check that the object is not null and an instance of this object - if (otherObject != null && otherObject instanceof GridLocation) { - location = (GridLocation) otherObject; - // Check values - retVal = this.row == location.row && this.col == location.col - && this.lWRDataProvider.equals(location.lWRDataProvider); - - } - - // Return the retVal - return retVal; - - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return

- * The hash of the object. - *

- */ - @Override - public int hashCode() { - - // Local Declarations - int hash = 31; - - // Compute hash across attributes - - // Added +1 to these pieces just in case row or col is 0 - hash += 31 * (this.col + 1); - hash += 31 * (this.row + 1); - hash += 31 * this.lWRDataProvider.hashCode(); - - // Return the hashCode - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(GridLocation otherObject) { - - // If the otherObject is null, return - if (otherObject == null) { - return; - } - - // Copy contents of the object - this.row = otherObject.row; - this.col = otherObject.col; - this.lWRDataProvider = (LWRDataProvider) otherObject.lWRDataProvider - .clone(); - - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return

- * The newly instantiated copied object. - *

- */ - @Override - public Object clone() { - - // Local Declarations - GridLocation location = new GridLocation(0, 0); - - // Copy contents - location.copy(this); - - // Return the newly instantiated object - return location; - - } - - /** - *

- * Sets the LWRDataProvider. - *

- * - * @param dataProvider - *

- * The IDataProvider implementation. - *

- */ - public void setLWRDataProvider(LWRDataProvider dataProvider) { - - if (dataProvider != null) { - this.lWRDataProvider = dataProvider; - } - - } - - /** - *

- * Returns the LWRDataProvider. - *

- * - * @return

- * The IDataProvider implementation. - *

- */ - public LWRDataProvider getLWRDataProvider() { - - return this.lWRDataProvider; - } - - /** - * (non-Javadoc) - * - * @see Comparable#compareTo(Object arg0) - */ - @Override - public int compareTo(GridLocation location) { - // Local Declarations - - // Return the difference of the row - if (this.row != location.row) { - return this.row - location.row; - } - // Return the difference of col. If the rows are equal, then if the cols - // are equal, this should return 0. - return this.col - location.col; - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/HDF5LWRTagType.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/HDF5LWRTagType.java deleted file mode 100644 index 9cd3c1219..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/HDF5LWRTagType.java +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -/** - *

- * Represents the LWRComponentTypes (stack, material, etc) for the object. - *

- * - * @author Scott Forest Hull II - */ -public enum HDF5LWRTagType { - /** - *

- * Represents the ControlBank. - *

- * - */ - CONTROL_BANK("Control Bank"), - /** - *

- * Represents the FuelAssembly. - *

- * - */ - FUEL_ASSEMBLY("Fuel Assembly"), - /** - *

- * Represents the GridLabelProvider. - *

- * - */ - GRID_LABEL_PROVIDER("Grid Label Provider"), - /** - *

- * Represents the IncoreInstrument. - *

- * - */ - INCORE_INSTRUMENT("Incore Instrument"), - /** - *

- * Represents the LWRRod. - *

- * - */ - LWRROD("LWRRod"), - /** - *

- * Represents the Material. - *

- * - */ - MATERIAL("Material"), - /** - *

- * Represents the PWReactor. - *

- * - */ - PWREACTOR("PWReactor"), - /** - *

- * Represents the Ring. - *

- * - */ - RING("Ring"), - /** - *

- * Represents the Rod Cluster Assembly. - *

- * - */ - ROD_CLUSTER_ASSEMBLY("Rod Cluster Assembly"), - /** - *

- * Represents the Tube. - *

- * - */ - TUBE("Tube"), - /** - *

- * Represents a generic LWRComponent. - *

- * - */ - LWRCOMPONENT("LWRComponent"), - /** - *

- * Represents a generic LWRComposite. - *

- * - */ - LWRCOMPOSITE("LWRComposite"), - /** - *

- * Represents a LWReactor. - *

- * - */ - LWREACTOR("LWReactor"), - /** - *

- * Represents a BWReactor. - *

- * - */ - BWREACTOR("BWReactor"), - /** - *

- * Represents a PWRAssembly. - *

- * - */ - PWRASSEMBLY("PWRAssembly"), - /** - *

- * Represents a LWRGridManager. - *

- * - */ - LWRGRIDMANAGER("LWRGridManager"), - - /** - *

- * Represents a MaterialBlock. - *

- * - */ - MATERIALBLOCK("MaterialBlock"); - - /** - * - */ - private String name; - - /** - *

- * The constructor - *

- * - * @param name - *

- * Human readable string associated with enumerated value. - *

- */ - HDF5LWRTagType(String name) { - - this.name = name; - - } - - /** - *

- * Returns the type of enumeration keyed on name. Returns null if invalid - * name. - *

- * - * @param name - *

- * The name associated with the enumerated value. - *

- * @return

- * The type of enumeration. - *

- */ - public static HDF5LWRTagType toType(String name) { - // Cycle over all types - for (HDF5LWRTagType p : values()) { - - // If this property's name equals name - if (p.name.equals(name)) { - - // Return the property - return p; - } - } - - // If not found return null - return null; - } - - /** - *

- * Returns the string name of the enumerated value. - *

- * - * @return

- * The name of the enumerated value. - *

- */ - @Override - public String toString() { - - return name; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/IGridManager.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/IGridManager.java deleted file mode 100644 index 39befd133..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/IGridManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import org.eclipse.ice.datastructures.ICEObject.Component; - -/** - *

- * An interface for managing Components on a grid. - *

- * - * @author Scott Forest Hull II - */ -public interface IGridManager { - /** - *

- * Returns the Component at the provided GridLocation or null if one does - * not exist at the provided location. - *

- * - * @param location - *

- * A GridLocation. - *

- * @return

- * A Component object to return. - *

- */ - public String getComponentName(GridLocation location); - - /** - *

- * Adds a Component and its GridLocation to this GridManager. If a Component - * already exists at that location, then this operation does nothing. - *

- * - * @param component - *

- * A Component object to add. - *

- * @param location - *

- * A GridLocation. - *

- */ - public void addComponent(Component component, GridLocation location); - - /** - *

- * Removes the Component at the provided GridLocation from this GridManager. - *

- * - * @param location - *

- * A GridLocation. - *

- */ - public void removeComponent(GridLocation location); - - /** - *

- * Removes the provided Component from this GridManager. - *

- * - * @param component - *

- * A Component object to remove. - *

- */ - public void removeComponent(Component component); -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/ILWRComponentVisitor.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/ILWRComponentVisitor.java deleted file mode 100644 index a512a9ff5..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/ILWRComponentVisitor.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import org.eclipse.ice.reactor.bwr.BWReactor; -import org.eclipse.ice.reactor.pwr.ControlBank; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.IncoreInstrument; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.eclipse.ice.reactor.pwr.RodClusterAssembly; - -/** - *

- * This interface defines the "visitation" routines that LWRComponents and - * subclasses may use to reveal their types to visitors. - *

- * - * @author Scott Forest Hull II - */ -public interface ILWRComponentVisitor { - /** - *

- * This operation directs a visitor to perform its actions on the - * LWRComponent as a PWReactor. - *

- * - * @param lwrComp - *

- * The PWReactor that must accept this visitor - *

- */ - public void visit(PressurizedWaterReactor lwrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * LWRComponent as a BWReactor. - *

- * - * @param lwrComp - *

- * The BWReactor that must accept this visitor - *

- */ - public void visit(BWReactor lwrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * LWRComponent as a FuelAssembly. - *

- * - * @param lwrComp - *

- * The FuelAssembly that must accept this visitor - *

- */ - public void visit(FuelAssembly lwrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * LWRComponent as a RodClusterAssembly. - *

- * - * @param lwrComp - *

- * The RCA that must accept this visitor - *

- */ - public void visit(RodClusterAssembly lwrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * LWRComponent as a LWRRod. - *

- * - * @param lwrComp - *

- * The LWRRod that must accept this visitor - *

- */ - public void visit(LWRRod lwrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * LWRComponent as a ControlBank. - *

- * - * @param lwrComp - *

- * The ControlBank that must accept this visitor - *

- */ - public void visit(ControlBank lwrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * LWRComponent as an IncoreInstrument. - *

- * - * @param lwrComp - *

- * The IncoreInstrument that must accept this visitor - *

- */ - public void visit(IncoreInstrument lwrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * LWRComponent as a Ring. - *

- * - * @param lwrComp - *

- * The Ring that must accept this visitor - *

- */ - public void visit(Tube lwrComp); - - /** - *

- * This operation directs a visitor to perform its actions on the - * LWRComponent as a Tube. - *

- * - * @param lwrComp - *

- * The Tube that must accept this visitor - *

- */ - public void visit(Ring lwrComp); -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComponent.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComponent.java deleted file mode 100644 index 9006d04ea..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComponent.java +++ /dev/null @@ -1,1246 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.TreeMap; -import java.util.Vector; - -import javax.xml.bind.annotation.XmlTransient; - -import ncsa.hdf.object.Dataset; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.HObject; -import ncsa.hdf.object.h5.H5CompoundDS; -import ncsa.hdf.object.h5.H5Datatype; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.analysistool.IData; -import org.eclipse.ice.analysistool.IDataProvider; -import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener; -import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfWriteable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - *

- * The LWRComponent class represents all reactor components that can be stored - * in a LWRComposite. This class should be treated as an extension of the Java - * Object class where identifying pieces of information are stored on this - * object. This class also implements the IDataProvider interface in order to - * provide state point data capabilities for individual, unique instances of - * this extended class. A key note to understand about this implementation for - * IDataProvider is that for individual changes on a particular position, say a - * Rod at a at a certain coordinate within an assembly changes it's material - * density, then this data should be stored at a higher level within the - * LWRDataProvider on the Assembly. The IDataProvider implementation here is - * designed specifically for showing changes across all named positions of the - * same type. If ,for example, the data changed across the same assembly across - * all of the same rod types, then the statepoint data should be stored on this - * class. - *

- *

- * This class implements the ICE Component interface. - *

- * - * @author Scott Forest Hull II - */ -public class LWRComponent implements IReactorComponent, IDataProvider, - IHdfWriteable, IHdfReadable { - - /** - * Logger for handling event messages and other information. - */ - protected final Logger logger; - - /** - *

- * An ArrayList of ICE IComponentListeners. - *

- * - */ - @XmlTransient - private ArrayList listeners; - /** - *

- * Classifies a LWRComponentType. This should only be set on the lowest - * level constructor AND should represent the lowest level object. - *

- * - */ - @XmlTransient - protected HDF5LWRTagType HDF5LWRTag; - /** - *

- * Name of this LWRComponent. - *

- * - */ - @XmlTransient - protected String name; - /** - *

- * A TreeMap implementation of IData and features. Keep in mind that there - * can be multiple IData for the same feature. - *

- */ - @XmlTransient - private TreeMap> dataTree; - /** - *

- * The current time step. Can not be less than 0, and must be strictly less - * than the number of TimeSteps. Defaults to 0. - *

- * - */ - @XmlTransient - private double time; - /** - *

- * A description of the source of information for this provider and its - * data. - *

- * - */ - @XmlTransient - private String sourceInfo; - /** - *

- * The time unit. - *

- * - */ - @XmlTransient - private String timeUnit; - /** - *

- * The id of this LWRComponent. Can not be less than zero. - *

- * - */ - @XmlTransient - protected int id; - /** - *

- * The description of this LWRComponent. - *

- * - */ - @XmlTransient - protected String description; - - // Names for groups - @XmlTransient - private String dataH5GroupName = "State Point Data"; - @XmlTransient - private String timeStepNamePrefix = "TimeStep: "; - - /** - * The nullary Constructor. - */ - public LWRComponent() { - - // Create the logger - logger = LoggerFactory.getLogger(getClass()); - - // Setup default values - this.name = "Component 1"; - this.id = 0; - this.description = "Component 1's Description"; - - // Setup listeners - this.listeners = new ArrayList(); - - // Setup TreeMap - this.dataTree = new TreeMap>(); - - // Setup Source - this.sourceInfo = "No Source Available"; - - // Setup time - this.time = 0; - this.timeUnit = "seconds"; - - // Setup the HDF5LWRTagType to correct type - this.HDF5LWRTag = HDF5LWRTagType.LWRCOMPONENT; - - } - - /** - * A parameterized Constructor. - * - * @param name - * Name of this LWRComponent - */ - public LWRComponent(String name) { - // Call this constructor - this(); - - // Set name appropriately - this.setName(name); - } - - /** - * This operation notifies the listeners of the LWRComponent that its data - * state has changed. - */ - protected void notifyListeners() { - - // If the listeners are empty, return - if (this.listeners == null || this.listeners.isEmpty()) { - return; - } - // Local Declarations - final LWRComponent compHandle = this; - - // Create a thread on which to notify the listeners. - Thread notifierThread = new Thread() { - - @Override - public void run() { - - // Loop over all listeners and update them - for (int i = 0; i < listeners.size(); i++) { - listeners.get(i).update(compHandle); - } - - return; - } - }; - - // Launch the thread and do the notifications - notifierThread.start(); - - return; - - } - - /** - *

- * Sets the sourceInfo. Can not be null or the empty string. Strings passed - * will be trimmed before being set. - *

- * - * @param sourceInfo - *

- * The sourceInfo to set. - *

- */ - public void setSourceInfo(String sourceInfo) { - if (sourceInfo != null && !sourceInfo.trim().isEmpty()) { - this.sourceInfo = sourceInfo.trim(); - // Notify listeners - this.notifyListeners(); - } - - } - - /** - *

- * Adds a IData piece, keyed on the feature and timeStep, to the dataTree. - * If the feature exists in the tree, it will append to the end of the list. - *

- * - * @param data - *

- * The data to add. - *

- * @param time - */ - public void addData(LWRData data, double time) { - - // Local Declarations - ArrayList featureSetList; - FeatureSet set; - boolean featureExistsFlag = false; - - // Return if the passed parameters are incorrect - if (data == null || time < 0) { - return; - } - - featureSetList = this.dataTree.get(time); - - // If the timestep does not exist in the list, add it to the list - if (featureSetList == null) { - featureSetList = new ArrayList(); - set = new FeatureSet(data.getFeature()); - set.addIData(data); - featureSetList.add(set); - this.dataTree.put(time, featureSetList); - this.notifyListeners(); - - } - - // Otherwise, the timestep exists and needs to append to the current - // running list - else { - - // Append to the current FeatureSet if it exists - for (int i = 0; i < featureSetList.size(); i++) { - // IF the featureset is the same name as the data, add it - if (featureSetList.get(i).getName().equals(data.getFeature())) { - featureSetList.get(i).addIData(data); - featureExistsFlag = true; - this.notifyListeners(); - break; - } - } - - // If the featureSet does not exist, then add it - if (!featureExistsFlag) { - // If it does not, add it - set = new FeatureSet(data.getFeature()); - set.addIData(data); - - // Add it to the list of sets - featureSetList.add(set); - this.notifyListeners(); - } - - } - - } - - /** - *

- * Removes the feature and all associated IData from the dataTree at all - * time steps. If a user wishes to remove a single piece of IData from the - * tree, then use the appropriate getData operation on that feature and - * manipulate the data that way. - *

- * - * @param feature - *

- * The feature. - *

- */ - public void removeAllDataFromFeature(String feature) { - - // Local Declarations - boolean updated = false; - - // If feature is null, return - if (feature == null) { - return; - } - // Get the iterator - Iterator iter; - iter = this.dataTree.keySet().iterator(); - - // Iterate over the list of all timesteps and remove all the features - while (iter.hasNext()) { - ArrayList list = this.dataTree.get(iter.next()); - - // If the FeatureSet with the feature name exists, remove it - for (int i = 0; i < list.size(); i++) { - if (list.get(i).getName().equals(feature)) { - list.remove(i); - updated = true; - break; // Break from for loop, otherwise really bad things - // will happen - } - } - } - - // Notify listeners if updated - if (updated) { - // Notify listeners - this.notifyListeners(); - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Identifiable#setId(int) - */ - @Override - public void setId(int id) { - - // If the id is less 0, then do not set it - if (id >= 0) { - this.id = id; - - // Notify listeners - this.notifyListeners(); - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Identifiable#getDescription() - */ - @Override - public String getDescription() { - - return this.description; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Identifiable#getId() - */ - @Override - public int getId() { - - return this.id; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Identifiable#setName(java.lang.String) - */ - @Override - public void setName(String name) { - - // If the name is not null, and if you trim it, it is not the emptry - // string - if (name != null && !name.trim().isEmpty()) { - // Trim it! - this.name = name.trim(); - - // Notify listeners - this.notifyListeners(); - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Identifiable#getName() - */ - @Override - public String getName() { - - return this.name; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Identifiable#setDescription(java.lang.String) - */ - @Override - public void setDescription(String description) { - - // If the name is not null, and if you trim it, it is not the emptry - // string - if (description != null && !description.trim().isEmpty()) { - // Trim it! - this.description = description.trim(); - - // Notify listeners - this.notifyListeners(); - } - - } - - /* - * Overrides super class method. - */ - @Override - public boolean equals(Object otherObject) { - - // Local declarations - LWRComponent component; - boolean retVal = false; - - // If they are equal to the same object, return true - if (this == otherObject) { - return true; - } - - // If this object is an instance of the LWRComponent, cast it. - // Make sure it is also not null - if (otherObject != null && otherObject instanceof LWRComponent) { - component = (LWRComponent) otherObject; - - // Check values - retVal = (this.id == component.id - && this.description.equals(component.description) - && this.name.equals(component.name) - && this.dataTree.equals(component.dataTree) - && this.time == component.time - && this.sourceInfo.equals(component.sourceInfo) - && this.HDF5LWRTag.equals(component.HDF5LWRTag) && this.timeUnit - .equals(component.timeUnit)); - - } - - // Return retVal - return retVal; - } - - /* - * Overrides super class method. - */ - @Override - public int hashCode() { - // Static hash at 31 - int hash = 31; - - // Calculate hash for name, id, and description - hash += 31 * this.name.hashCode(); - hash += 31 * this.id; - hash += 31 * this.description.hashCode(); - - // Calculate IDataProvider info - hash += 31 * this.dataTree.hashCode(); - hash += 31 * this.time; - hash += 31 * this.sourceInfo.hashCode(); - hash += 31 * this.HDF5LWRTag.hashCode(); - hash += 31 * this.timeUnit.hashCode(); - - // Return hash - return hash; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.IUpdateable#update(java.lang.String, java.lang.String) - */ - @Override - public void update(String updatedKey, String newValue) { - - // This does nothing at this time - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.IUpdateable#register(org.eclipse.ice.datastructures.ICEObject.IUpdateableListener) - */ - @Override - public void register(IUpdateableListener listener) { - // If the listener is not null, add it - if (listener != null) { - this.listeners.add(listener); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Component#accept(org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor) - */ - @Override - public void accept(IComponentVisitor visitor) { - - if (visitor != null) { - visitor.visit(this); - } - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return this.name; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getFeatureList() - */ - @Override - public ArrayList getFeatureList() { - - // Local Declarations - ArrayList featureList = new ArrayList(); - HashMap map = new HashMap(); - - // Get the iterator - Iterator iter; - iter = this.dataTree.keySet().iterator(); - - // Iterate over the list of all timesteps get one unique feature - while (iter.hasNext()) { - ArrayList list = this.dataTree.get(iter.next()); - - // If the map does not have the feature name, add it - for (int i = 0; i < list.size(); i++) { - if (map.get(list.get(i).getName()) == null) { - map.put(list.get(i).getName(), 1); - } - } - } - - // Append to featureList - for (String name : map.keySet()) { - featureList.add(name); - } - - // Return the featureList - return featureList; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getNumberOfTimeSteps() - */ - @Override - public int getNumberOfTimeSteps() { - - return this.dataTree.size(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#setTime(double) - */ - @Override - public void setTime(double step) { - if (step >= 0.0) { - this.time = step; - this.notifyListeners(); - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getDataAtCurrentTime(java.lang.String) - */ - @Override - public ArrayList getDataAtCurrentTime(String feature) { - - // If feature is null, return - if (feature == null) { - return new ArrayList(); - } - // Locate the list - ArrayList list = this.dataTree.get(this.time); - - if (list != null) { - // If the list exists, return the iData - for (int i = 0; i < list.size(); i++) { - if (list.get(i).getName().equals(feature)) { - - // Return the reference to the list of iData - return list.get(i).getIData(); - } - } - } - - return new ArrayList(); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getSourceInfo() - */ - @Override - public String getSourceInfo() { - - return this.sourceInfo; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getFeaturesAtCurrentTime() - */ - @Override - public ArrayList getFeaturesAtCurrentTime() { - - // Local Declarations - ArrayList features = new ArrayList(); - ArrayList list = null; - - // Get the list at the time - list = this.dataTree.get(this.time); - - // If the time does not exist, return empty - if (list == null) { - return features; - } - // Get the features - for (int i = 0; i < list.size(); i++) { - features.add(list.get(i).getName()); - } - - return features; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getTimes() - */ - @Override - public ArrayList getTimes() { - - // Local Declarations - ArrayList times = new ArrayList(); - - // Get the iterator - Iterator iter = this.dataTree.keySet().iterator(); - - // Add the times to the arraylist - while (iter.hasNext()) { - times.add(iter.next()); - } - - // Return the list of times - return times; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getTimeStep(double) - */ - @Override - public int getTimeStep(double time) { - - // Get the iterator - Iterator iter = this.dataTree.keySet().iterator(); - int counter = 0; - - // Iterate the list - while (iter.hasNext()) { - - // If the time is there, return the index - if (iter.next().equals(time)) { - return counter; - } - counter++; - - } - - // Time not found! - return -1; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getTimeUnits() - */ - @Override - public String getTimeUnits() { - - return this.timeUnit; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.io.hdf.IHdfWriteable#createGroup(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public H5Group createGroup(H5File h5File, H5Group parentH5Group) { - - // Create the group for this component - H5Group h5Group = HdfWriterFactory.createH5Group(h5File, name, - parentH5Group); - - // Return the group - return h5Group; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.io.hdf.IHdfWriteable#getWriteableChildren() - */ - @Override - public ArrayList getWriteableChildren() { - return null; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.io.hdf.IHdfWriteable#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - - boolean flag = true; - - flag &= HdfWriterFactory.writeStringAttribute(h5File, h5Group, - "HDF5LWRTag", HDF5LWRTag.toString()); - flag &= HdfWriterFactory.writeStringAttribute(h5File, h5Group, "name", - name); - flag &= HdfWriterFactory.writeIntegerAttribute(h5File, h5Group, "id", - id); - flag &= HdfWriterFactory.writeStringAttribute(h5File, h5Group, - "description", description); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.io.hdf.IHdfWriteable#writeDatasets(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeDatasets(H5File h5File, H5Group h5Group) { - - // If these pieces are null, return - if (h5File == null || h5Group == null) { - return false; - } - // Local Declarations - H5Group dataH5Group, timeStepH5Group; - Iterator iter; - int counter = 0; - String[] featureDSNames = { "value", "uncertainty", "units", "position" }; - - // Preliminary work: Create the dataTypes and setup the DS for it's - // dimensions - - // Each member's type - Datatype[] memberDatatypes = { - HdfWriterFactory.createFloatH5Datatype(h5File), - HdfWriterFactory.createFloatH5Datatype(h5File), - null, // Will replace later with a specific string datatype. - HdfWriterFactory.createFloatH5Datatype(h5File), - HdfWriterFactory.createFloatH5Datatype(h5File), - HdfWriterFactory.createFloatH5Datatype(h5File), }; - - // Create a HDF5Group for data - dataH5Group = HdfWriterFactory.createH5Group(h5File, dataH5GroupName, - h5Group); - - // Get the iterator - iter = this.dataTree.keySet().iterator(); - - // Iterate over the dataTree and create timesteps for each key in the - // tree - while (iter.hasNext()) { - - // Get the time - double time = iter.next(); - - // Get the list of FeatureSets at that time - ArrayList setList = this.dataTree.get(time); - - // Create a new timeStep group based on the prefix and the timeStep - timeStepH5Group = HdfWriterFactory.createH5Group(h5File, - timeStepNamePrefix + "" + counter, dataH5Group); - - // Add attributes to the timeStep group - - // Create attribute: time as Double - HdfWriterFactory.writeDoubleAttribute(h5File, timeStepH5Group, - "time", time); - - // Create attribute: units as String - HdfWriterFactory.writeStringAttribute(h5File, timeStepH5Group, - "units", this.timeUnit); - - // Create a Compound Dataset for each timeStep to represent the - // collection of FeatureSets. This contains the list of Feature Sets - for (int i = 0; i < setList.size(); i++) { - - // Get the FeatureSet - FeatureSet set = setList.get(i); - - // Setup the size of the String array Dataset - int maxLength = 0; - H5Datatype datatype = null; - - // Get the number of IDatas stored on the FeatureSet - int iDataSize = set.getIData().size(); - - // Create the arrays for each dataSet - double[] value = new double[iDataSize]; - double[] uncertainty = new double[iDataSize]; - String[] units = new String[iDataSize]; - double[] position = new double[iDataSize * 3]; - - // Iterate over the IDatas to fill out the arrays listed above - for (int j = 0; j < set.getIData().size(); j++) { - // Get the iData at the location - IData iData = set.getIData().get(j); - - // Copy contents of iData to the array - value[j] = iData.getValue(); - uncertainty[j] = iData.getUncertainty(); - units[j] = iData.getUnits(); - maxLength = Math.max(units[j].length(), maxLength); - - // Get the position - ArrayList pos = iData.getPosition(); - position[3 * j] = pos.get(0); - position[3 * j + 1] = pos.get(1); - position[3 * j + 2] = pos.get(2); - - } - - // Setup the 3rd position in the memberList DataTypes for the - // correct size - // Create a custom String data type for the value - try { - datatype = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, maxLength, Datatype.NATIVE, - Datatype.NATIVE); - - memberDatatypes[2] = datatype; - - // Calculate the dimensions of the length of each dataSet by - // the number of IDatas in the FeatureSet - long[] dims = { 1, set.getIData().size() }; - - // Create the arrayList of objects to add the data to the - // list - ArrayList data = new ArrayList(); - data.add(value); - data.add(uncertainty); - data.add(units); - data.add(position); - - // The member's sizes at each point in the dataset - int[] memberSizes = { 1, 1, 1, 3 }; - - // Create the compound dataset - Dataset dataSet = h5File.createCompoundDS(set.getName(), - timeStepH5Group, dims, null, null, 0, - featureDSNames, memberDatatypes, memberSizes, data); - dataSet.init(); - } catch (Exception e) { - // Break and return - logger.error(getClass().getName() + " Exception!",e); - return false; - } - - } - - // Iterate the counter - counter++; - } - - // Everything passed, return true! - return true; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.io.hdf.IHdfReadable#readChild(org.eclipse.ice.io.hdf.IHdfReadable) - */ - @Override - public boolean readChild(IHdfReadable iHdfReadable) { - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.io.hdf.IHdfReadable#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local attributes (so we only call read ONCE) - // These will clear out by the garbage collector - String name, description; - Integer id; - - // Get the information - name = HdfReaderFactory.readStringAttribute(h5Group, "name"); - description = HdfReaderFactory.readStringAttribute(h5Group, - "description"); - id = HdfReaderFactory.readIntegerAttribute(h5Group, "id"); - - // If any of them are erroneous, return false - if (name == null || description == null || id == null) { - return false; - } - // Set the primitive data - this.name = name; - this.description = description; - this.id = id.intValue(); - - return true; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.io.hdf.IHdfReadable#readDatasets(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readDatasets(H5Group h5Group) { - - // Local Declarations - int numOfTimeSteps = 0; - H5Group dataH5Group, timeStepH5Group; - - // return if null - if (h5Group == null) { - return false; - } - // Get the dataH5Group - dataH5Group = HdfReaderFactory.getChildH5Group(h5Group, - this.dataH5GroupName); - - ArrayList dataH5GroupMembers = HdfReaderFactory - .getChildH5Groups(dataH5Group); - - // Verify the group exists - if (dataH5Group != null && !(dataH5GroupMembers.isEmpty())) { - - // Get the number of timeSteps - numOfTimeSteps = dataH5GroupMembers.size(); - - // Iterate over the timeSteps to create the list of features - for (int i = 0; i < numOfTimeSteps; i++) { - - // Convert the h5Group to a timeStep - timeStepH5Group = dataH5GroupMembers.get(i); - - // Get the local time attribute and setup the featureSet list - double time = HdfReaderFactory.readDoubleAttribute( - timeStepH5Group, "time"); - ArrayList list = new ArrayList(); - - ArrayList timeStepH5GroupMembers = HdfReaderFactory - .getChildH5Members(timeStepH5Group); - - // Get the number of FeatureSets - int numOfFeatureSets = timeStepH5GroupMembers.size(); - - // Iterate over the FeatureSets - for (int j = 0; j < numOfFeatureSets; j++) { - - // Get the FeatureGroup - H5CompoundDS featureGroup = (H5CompoundDS) timeStepH5GroupMembers - .get(j); - - // Get the name of the feature - String featureName = featureGroup.getName(); - - // Create the feature set - FeatureSet set = new FeatureSet(featureName); - - // Get the object data off the dataset - Object data; - try { - data = featureGroup.getData(); - } catch (Exception e) { - logger.error(getClass().getName() + " Exception!",e); - return false; - } - - // Convert the data to a readable format: Cast it as a - // Vector, then grab the pieces out of it - Vector objects = (Vector) data; - - // Cast the objects to their subsets - // Create the arrays for each dataSet - double[] value = (double[]) objects.get(0); - double[] uncertainty = (double[]) objects.get(1); - String[] units = (String[]) objects.get(2); - double[] pos = (double[]) objects.get(3); - - // Iterate over the values and create the correct LWRData - for (int k = 0; k < value.length; k++) { - - // Create the data and setup basic attributes - LWRData lwrdata = new LWRData(featureName); - lwrdata.setValue(value[k]); - lwrdata.setUncertainty(uncertainty[k]); - lwrdata.setUnits(units[k]); - - // Setup position - ArrayList position = new ArrayList(); - position.add(pos[k * 3]); - position.add(pos[k * 3 + 1]); - position.add(pos[k * 3 + 2]); - - // Set position - lwrdata.setPosition(position); - - // Add the lwrdata to the list - set.addIData(lwrdata); - } - - // Add the set to the list - list.add(set); - - } - - // Add the list to the dataTree - this.dataTree.put(time, list); - - } - - } - - return true; - - } - - /** - *

- * Returns the current time step. - *

- * - * @return

- * The current time step. - *

- */ - public double getCurrentTime() { - - return this.time; - } - - /** - *

- * Returns the LWRComponentType. - *

- * - * @return

- * The LWRComponentType. - *

- */ - public HDF5LWRTagType getHDF5LWRTag() { - - return this.HDF5LWRTag; - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(LWRComponent otherObject) { - - // Local Declarations - Iterator iter; - - // If null, return - if (otherObject == null) { - return; - } - // Copy name, id, description - this.name = otherObject.name; - this.id = otherObject.id; - this.description = otherObject.description; - - // Copy dataTree - this.dataTree.clear(); - - // Setup the iterator - iter = otherObject.dataTree.keySet().iterator(); - - // Currently, this will only shallow copy the ArrayList on value. IData - // will have to implement copy and clone routines for it to be a deep - // copy - while (iter.hasNext()) { - Double key = iter.next(); - this.dataTree.put(key, otherObject.dataTree.get(key)); - } - - // Add the listeners to the set - this.listeners.addAll(otherObject.listeners); - - // Copy type - this.HDF5LWRTag = otherObject.HDF5LWRTag; - - // Copy Time info - this.time = otherObject.time; - this.sourceInfo = otherObject.sourceInfo; - this.timeUnit = otherObject.timeUnit; - - // Notify the listeners - notifyListeners(); - - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return

- * The newly instantiated copied object. - *

- */ - @Override - public Object clone() { - - // Local Declarations - LWRComponent component = new LWRComponent(); - - // Copy the component - component.copy(this); - - // Return the component - return component; - - } - - /** - *

- * Sets the time units. - *

- * - * @param timeUnit - *

- * The time unit to be set. - *

- */ - public void setTimeUnits(String timeUnit) { - - if (timeUnit != null && !timeUnit.trim().isEmpty()) { - this.timeUnit = timeUnit; - } - - } - - /** - *

- * This operation accepts an ILWRComponentVisitor that can be visit the - * LWRComponent to ascertain its type and perform various type-specific - * operations. - *

- * - * @param visitor - *

- * The visitor - *

- */ - public void accept(ILWRComponentVisitor visitor) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.IUpdateable#unregister(org.eclipse.ice.datastructures.ICEObject.IUpdateableListener) - */ - @Override - public void unregister(IUpdateableListener listener) { - // TODO Auto-generated method stub - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComponentReader.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComponentReader.java deleted file mode 100644 index 74c4b4dbf..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComponentReader.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfReader; -import org.eclipse.ice.reactor.bwr.BWReactor; -import org.eclipse.ice.reactor.pwr.ControlBank; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.IncoreInstrument; -import org.eclipse.ice.reactor.pwr.PWRAssembly; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.eclipse.ice.reactor.pwr.RodClusterAssembly; - -/** - *

- * The LWRComponentReader class creates and populates an LWRComponent or - * LWRComposite tree from an HDF5 file. This class implements the IHdfReadable - * interface. This takes any type of LWRComponent or LWRComposite and iterates - * from the top of that particular tree down, so a user could read from HDF5 and - * populate that list accordingly to any part of a Reactor or its delegated - * classes that inherit from LWRComponent. - *

- * - * @author Scott Forest Hull II - */ -public class LWRComponentReader implements IHdfReader { - - /** - *

- * A HashMap keyed on HDF5LWRTagType name storing unique LWRComponent - * instances. - *

- */ - private HashMap lWRComponentInstanceMap; - - /** - * The Constructor. - */ - public LWRComponentReader() { - - // Create a new HashMap for the - // LWRComponent instances - this.lWRComponentInstanceMap = new HashMap(); - - // Create and assign default instances to the map - this.lWRComponentInstanceMap.put(HDF5LWRTagType.CONTROL_BANK, - new ControlBank()); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.FUEL_ASSEMBLY, - new FuelAssembly(-1)); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.GRID_LABEL_PROVIDER, - new GridLabelProvider(-1)); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.INCORE_INSTRUMENT, - new IncoreInstrument()); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.LWRROD, new LWRRod()); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.MATERIAL, - new Material()); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.PWREACTOR, - new PressurizedWaterReactor(-1)); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.RING, new Ring()); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.ROD_CLUSTER_ASSEMBLY, - new RodClusterAssembly(-1)); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.MATERIALBLOCK, - new MaterialBlock()); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.TUBE, new Tube()); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.LWRCOMPONENT, - new LWRComponent()); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.LWRCOMPOSITE, - new LWRComposite()); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.LWREACTOR, - new LWReactor(-1)); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.BWREACTOR, - new BWReactor(-1)); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.PWRASSEMBLY, - new PWRAssembly(-1)); - this.lWRComponentInstanceMap.put(HDF5LWRTagType.LWRGRIDMANAGER, - new LWRGridManager(-1)); - - } - - /** - * (non-Javadoc) - * - * @see IHdfReader#read(URI uri) - */ - @Override - public IHdfReadable read(URI uri) { - - // Open the file at the provided uri - H5File h5File = HdfFileFactory.openH5File(uri); - - // If the file is null, then return false - if (h5File == null) { - return null; - } - // Get the root group from the file - H5Group rootH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // If the root group is null, then return null - if (rootH5Group == null) { - return null; - } - // Get the first child group from the root group - H5Group h5Group = HdfReaderFactory.getChildH5Group(rootH5Group, 0); - - // Read the group into the iHdfReadable - IHdfReadable iHdfReadable = this.read(h5Group); - - // Close the file - HdfFileFactory.closeH5File(h5File); - - // Return the iHdfReadable - return iHdfReadable; - - } - - /** - *

- * Returns a clone of the LWRComponent instance corresponding to the - * provided HDF5LWRTagType enumeration literal. - *

- * - * @param HDF5LWRTag - *

- * A HDF5LWRTagType enumeration literal. - *

- * @return

- * A clone of the LWRComponent instance corresponding to the - * provided HDF5LWRTagType enumeration literal. - *

- */ - private LWRComponent getLWRComponentInstance(HDF5LWRTagType HDF5LWRTag) { - - // Get the LWRComponent instance corresponding to the provided tag - LWRComponent lWRComponent = (LWRComponent) lWRComponentInstanceMap.get( - HDF5LWRTag).clone(); - - // Return the instance - return lWRComponent; - } - - /** - *

- * Recursively reads an H5Group and its child H5Groups and Datasets into an - * IHdfReadable. - *

- * - * @param h5Group - *

- * The H5Group to be read. - *

- * @return

- * An IHdfReadable that has been populated by the provided H5Group - * and its child H5Groups and Datasets. - *

- */ - private IHdfReadable read(H5Group h5Group) { - - IHdfReadable iHdfReadable = null; - - // Check for a null h5Group - if (h5Group == null) { - return null; - } - // Get the tag from the group - HDF5LWRTagType HDF5LWRTag = HDF5LWRTagType.toType(HdfReaderFactory - .readStringAttribute(h5Group, "HDF5LWRTag")); - - // If the tag does not exist, skip it - if (HDF5LWRTag != null) { - - // Get an instance from the tag - iHdfReadable = this.getLWRComponentInstance(HDF5LWRTag); - - // Read in the attributes - iHdfReadable.readAttributes(h5Group); - - // Read in the datasets - iHdfReadable.readDatasets(h5Group); - - // Get a list of child groups - ArrayList childGroupList = HdfReaderFactory - .getChildH5Groups(h5Group); - - // If the group has entries - if (!(childGroupList.isEmpty())) { - - // Cycle over these entries - for (H5Group group : childGroupList) { - - // Create and populate a child from the child group - IHdfReadable child = this.read(group); - - // Read the child into the readable - iHdfReadable.readChild(child); - } - - } - } - // Return the top level readable - return iHdfReadable; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComponentWriter.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComponentWriter.java deleted file mode 100644 index 1ecda1e2d..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComponentWriter.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.net.URI; -import java.util.ArrayList; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfFileFactory; -import org.eclipse.ice.io.hdf.IHdfWriteable; -import org.eclipse.ice.io.hdf.IHdfWriter; - -/** - *

- * The LWRComponentReader class writes an LWRComponent or LWRComposite tree to - * an HDF5 file. This class implements the IHdfWriteable interface. This takes - * any type of LWRComponent or LWRComposite and iterates from the top of that - * particular tree down, so a user could write to HDF5 and populate that list - * accordingly to any part of a Reactor or its delegated classes that inherit - * from LWRComponent. - *

- * - * @author Scott Forest Hull II - */ -public class LWRComponentWriter implements IHdfWriter { - - /** - * (non-Javadoc) - * - * @see IHdfWriter#write(IHdfWriteable iHdfWriteable, URI uri) - */ - @Override - public boolean write(IHdfWriteable iHdfWriteable, URI uri) { - - - // Check for a null iHdfWriteable. If null then return false - if (iHdfWriteable == null) { - - return false; - - } - - // Create and open a new h5file with the provided uri - H5File h5File = HdfFileFactory.createH5File(uri); - - // If the file is null, then return false - if (h5File == null) { - - return false; - - } - - // Get the root group from the file - H5Group rootH5Group = (H5Group) ((javax.swing.tree.DefaultMutableTreeNode) h5File - .getRootNode()).getUserObject(); - - // If the root group is null then return false - if (rootH5Group == null) { - - return false; - - } - - // Write the iHdfWriteable to the root group and store the boolean - // result - boolean flag = this.write(iHdfWriteable, h5File, rootH5Group); - - // Close the file - HdfFileFactory.closeH5File(h5File); - - // Return the result - return flag; - } - - /** - *

- * Recursively writes the H5Groups, Attributes, and Datasets of the provided - * IHdfWriteable to the provided H5File. - *

- * - * @param iHdfWriteable - *

- * The IHdfWriteable to be written. - *

- * @param h5File - *

- * The H5File to write to. - *

- * @param parentH5Group - *

- * A H5Group to write for this iteration. - *

- * @return

- * True if the write was successful, false otherwise. - *

- */ - private boolean write(IHdfWriteable iHdfWriteable, H5File h5File, - H5Group parentH5Group) { - - // Create a flag to store and return any write failures - boolean flag = true; - - // Write a new group for this LWRComponent - H5Group h5Group = iHdfWriteable.createGroup(h5File, parentH5Group); - - // Write the attributes for this LWRComponent - flag &= iHdfWriteable.writeAttributes(h5File, h5Group); - - // Write the datasets for this LWRComponent - flag &= iHdfWriteable.writeDatasets(h5File, h5Group); - - // Get the children of iHdfWriteable - ArrayList children = iHdfWriteable - .getWriteableChildren(); - - // If there are children - if (children != null && !(children.isEmpty())) { - - // Cycle over the children - for (IHdfWriteable child : children) { - - // Write the child - flag &= this.write(child, h5File, h5Group); - - } - - } - - // Return the flag - return flag; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComposite.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComposite.java deleted file mode 100644 index cc8ef83ae..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRComposite.java +++ /dev/null @@ -1,420 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; - -import javax.xml.bind.annotation.XmlTransient; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.datastructures.ICEObject.Composite; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfWriteable; - -/** - *

- * The LWRComposite class represents all reactor components that can store and - * manage LWRComponents. This class implements the ICE Composite interface. This - * class was designed as a "branch" within the Reactor package to hold - * references to other LWRComponents. Although this class implements the - * Composite interface, classes that extend LWRComposite should consider if they - * will need to override the Composite Interface's operations to provide - * specific utility as needed. - *

- * - * @author Scott Forest Hull II - */ -public class LWRComposite extends LWRComponent implements Composite { - /** - *

- * A Hashtable keyed on LWRComponent name storing unique LWRComponents. - *

- * - */ - @XmlTransient - protected Hashtable lWRComponents; - - /** - *

- * The Constructor. - *

- * - */ - public LWRComposite() { - - // Setup the composite - this.name = "Composite 1"; - this.id = 1; - this.description = "Composite 1's Description"; - - // Setup hashTable - this.lWRComponents = new Hashtable(); - - // Setup the LWRComponentType to correct type - this.HDF5LWRTag = HDF5LWRTagType.LWRCOMPOSITE; - - } - - /** - *

- * Returns the LWRComponent corresponding to the provided name or null if - * the name is not found. - *

- * - * @param name - *

- * The provided LWRComponent's name. - *

- * @return

- * The LWRComponent corresponding to the provided name or null if - * the name is not found. - *

- */ - public LWRComponent getComponent(String name) { - - // if the name is not null, return the name - if (name != null) { - return this.lWRComponents.get(name); - } - - // Name was null, return - return null; - } - - /** - *

- * Returns an ArrayList of Strings containing the names of all LWRComponents - * contained in this LWRComposite. - *

- * - * @return

- * An ArrayList of Strings containing the names of all LWRComponents - * contained in this LWRComposite - *

- */ - public ArrayList getComponentNames() { - // Local Declarations - ArrayList keys = new ArrayList(); - Iterator iter; - String keyName; - - // Setup iterator - iter = this.lWRComponents.keySet().iterator(); - - // Iterate over the list and get the component - // Only grab the first in the list - while (iter.hasNext()) { - - // Iterate the next piece - keyName = iter.next(); - // Add each string key to the list - keys.add(keyName); - } - - // Return the names - return keys; - } - - /** - *

- * Removes a LWRComponent with the provided name from this LWRComposite. - *

- * - * @param name - *

- * The name of the LWRComponent to remove. - *

- */ - public void removeComponent(String name) { - // Local Declarations - - // IF the name is not null and it is contained in the list (trimmed), - // then remove it - if (name != null && this.lWRComponents.containsKey(name) - && !name.trim().isEmpty()) { - this.lWRComponents.remove(name); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local declarations - LWRComposite composite; - boolean retVal = false; - - // If this object is an instance of the LWRComponent, cast it. - // Make sure it is also not null - if (otherObject != null && otherObject instanceof LWRComposite) { - composite = (LWRComposite) otherObject; - - // If they are on the same heap, return true - if (this == otherObject) { - return true; - } - // Check values - retVal = (super.equals(otherObject) && this.lWRComponents - .equals(composite.lWRComponents)); - - } - - // Return retVal - return retVal; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#hashCode() - */ - @Override - public int hashCode() { - - // Get the super's hashCode - int hash = super.hashCode(); - - // Hash the hashTable - hash += 31 * this.lWRComponents.hashCode(); - - // Return the hashCode - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(LWRComposite otherObject) { - - // Local declarations - Iterator iter; - - // If the object is null, return - if (otherObject == null) { - return; - } - // Copy super contents - super.copy(otherObject); - - // Copy the HashTable's contents - this.lWRComponents.clear(); - iter = otherObject.lWRComponents.keySet().iterator(); - - while (iter.hasNext()) { - String key = iter.next(); - this.lWRComponents.put(key, - otherObject.lWRComponents.get(key)); - - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#clone() - */ - @Override - public Object clone() { - - // Local Declarations - LWRComposite composite = new LWRComposite(); - - // Copy contents - composite.copy(this); - - // Return the newly instantiated object - return composite; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#getWriteableChildren() - */ - @Override - public ArrayList getWriteableChildren() { - - // Get the children in super - ArrayList children = super.getWriteableChildren(); - - // If super had no children - if (children == null) { - - // Initialize to new array list - children = new ArrayList(); - } - - // Add all of these children - children.addAll(lWRComponents.values()); - - return children; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readChild(org.eclipse.ice.io.hdf.IHdfReadable) - */ - @Override - public boolean readChild(IHdfReadable iHdfReadable) { - - // If the child is null or not an instance of LWRComponent, then return - // false. - if (iHdfReadable == null || !(iHdfReadable instanceof LWRComponent)) { - return false; - } - - // Cast the child into a LWRComponent - LWRComponent childComponent = (LWRComponent) iHdfReadable; - - // Remove any child with the new child's name from this LWRComposite - this.removeComponent(childComponent.getName()); - - // Add the new child LWRComponent - this.addComponent(childComponent); - - // Return true for success - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Composite#addComponent(org.eclipse.ice.datastructures.ICEObject.Component) - */ - @Override - public void addComponent(Component child) { - - // If the child is null or if the name is already in the table, return - if (child == null || this.lWRComponents.containsKey(child.getName()) - || !(child instanceof LWRComponent)) { - return; - } - - // Otherwise, add component - this.lWRComponents.put(child.getName(), (LWRComponent) child); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Composite#removeComponent(int) - */ - @Override - public void removeComponent(int childId) { - // Local declarations - Component component = null; - Iterator iter; - - // Setup iterator - iter = this.lWRComponents.values().iterator(); - - // Iterate over the list and get the component - // Only grab the first in the list - while (iter.hasNext()) { - - // Iterate the next piece - component = iter.next(); - - // If the component's id matches the required child's id, remove the - // component - if (component.getId() == childId) { - this.removeComponent(component.getName()); - } - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Composite#getComponent(int) - */ - @Override - public Component getComponent(int childId) { - // Local declarations - Component component = null; - Iterator iter; - - // Setup iterator - iter = this.lWRComponents.values().iterator(); - - // Iterate over the list and get the component - // Only grab the first in the list - while (iter.hasNext()) { - - // Iterate the next piece - component = iter.next(); - - // If the component's id matches the required child's id, return the - // component - if (component.getId() == childId) { - return component; - } - } - - // Nothing was found! - return null; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Composite#getNumberOfComponents() - */ - @Override - public int getNumberOfComponents() { - - // Return the size - return this.lWRComponents.size(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.datastructures.ICEObject.Composite#getComponents() - */ - @Override - public ArrayList getComponents() { - // Local Declarations - ArrayList components = new ArrayList(); - Component component; - Iterator iter; - - // Setup iterator - iter = this.lWRComponents.values().iterator(); - - // Iterate over the list and get the component - // Only grab the first in the list - while (iter.hasNext()) { - - // Iterate the next piece - component = iter.next(); - // Add the component to the list - components.add(component); - } - - // Return the list - return components; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRData.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRData.java deleted file mode 100644 index 3f4489907..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRData.java +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; - -import org.eclipse.ice.analysistool.IData; - -/** - *

- * A class that implements the IData interface. It provides setters for the - * particular sets of IData associated with this class along with some basic - * equality and copying routines for convenience. - *

- *

- *

- *

- *

- * - * @author Scott Forest Hull II - */ -public class LWRData implements IData { - /** - *

- * The representation of the x, y, z coordinate. - *

- * - */ - private ArrayList position; - /** - *

- * The value. - *

- * - */ - private double value; - /** - *

- * The uncertainty value. - *

- * - */ - private double uncertainty; - /** - *

- * The representation of the type of "Unit" represented by the value - * (Meters, velocity, etc). - *

- * - */ - private String units; - /** - *

- * The feature (unique name) of this object. - *

- * - */ - private String feature; - - /** - *

- * The constructor. Sets up the default values for the LWRData. - *

- * - */ - public LWRData() { - // Setup the default values for the listed attributes - this.feature = "Feature 1"; - - // Setup position with 3 default values - this.position = new ArrayList(); - this.position.add(0.0); - this.position.add(0.0); - this.position.add(0.0); - - this.uncertainty = 0.0; - this.units = "seconds"; - this.value = 0.0; - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param feature - *

- * The name of the feature - *

- */ - public LWRData(String feature) { - // Call nullary constructor - this(); - - // Set the feature - this.setFeature(feature); - } - - /** - *

- * Sets the position of the LWRData. The passed parameter can not be null - * and must be equal to three dimensions (x, y, z coordinate plane and in - * that order for less than 3 dimensions). If working in less than 3 - * dimensions, the offset values should be set to 0. - *

- * - * @param position - *

- * The position - *

- */ - public void setPosition(ArrayList position) { - - // If the position is not 3, return - if (position.size() == 3) { - // Add all uniquely - this.position.clear(); - // Iterate over the list and add each position - for (int i = 0; i < position.size(); i++) { - this.position.add(position.get(i)); - } - } - - } - - /** - *

- * Sets the value. - *

- * - * @param value - *

- * The value. - *

- */ - public void setValue(double value) { - - this.value = value; - - } - - /** - *

- * Sets the uncertainty. - *

- * - * @param uncertainty - *

- * The uncertainty. - *

- */ - public void setUncertainty(double uncertainty) { - - this.uncertainty = uncertainty; - - } - - /** - *

- * Sets the units. Can not be null or the empty string. Strings are trimmed - * accordingly upon being set. - *

- * - * @param units - *

- * The units. - *

- */ - public void setUnits(String units) { - - // If the String is not null and it is not empty string (when trimmed) - // set accordingly - if (units != null && !units.trim().isEmpty()) { - this.units = units.trim(); - } - - } - - /** - *

- * Sets the feature. Can not set to null or the empty string. Strings are - * trimmed accordingly upon being set. - *

- * - * @param feature - *

- * The feature. - *

- */ - public void setFeature(String feature) { - // If the String is not null and it is not empty string (when trimmed) - // set accordingly - if (feature != null && !feature.trim().isEmpty()) { - this.feature = feature.trim(); - } - - } - - /** - * - * @param otherObject - *

- * The object to be compared. - *

- * @return

- * True if otherObject is equal. False otherwise. - *

- */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - LWRData data; - boolean retVal = false; - - // If they are equal to the same object, return true - if (this == otherObject) { - return true; - } - // If this object is an instance of the LWRData, cast it. - // Make sure it is also not null - if (otherObject != null && otherObject instanceof LWRData) { - data = (LWRData) otherObject; - - // Check values - retVal = (this.position.equals(data.position) - && this.value == data.value - && this.uncertainty == data.uncertainty - && this.units.equals(data.units) && this.feature - .equals(data.feature)); - - } - - // Return retVal - return retVal; - - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return

- * The hash. - *

- */ - @Override - public int hashCode() { - - // Local Declarations - int hash = 31; - - // Calculate the hashCode for the following attributes - hash += 31 * this.position.hashCode(); - hash += 31 * this.value; - hash += 31 * this.uncertainty; - hash += 31 * this.units.hashCode(); - hash += 31 * this.feature.hashCode(); - - // Return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(LWRData otherObject) { - - // If object is null, return - if (otherObject == null) { - return; - } - // Copy contents - this.position.clear(); - // Deep copy position - for (int i = 0; i < otherObject.position.size(); i++) { - this.position.add(new Double(otherObject.position.get(i) - .doubleValue())); - } - this.feature = otherObject.feature; - this.uncertainty = otherObject.uncertainty; - this.units = otherObject.units; - this.value = otherObject.value; - - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return A new clone of this object. - */ - @Override - public Object clone() { - - // Local Declarations - LWRData data = new LWRData(); - - // Copy contents - data.copy(this); - - // Return the newly instantiated object - return data; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IData#getPosition() - */ - @Override - public ArrayList getPosition() { - - return this.position; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IData#getValue() - */ - @Override - public double getValue() { - - return this.value; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IData#getUncertainty() - */ - @Override - public double getUncertainty() { - - return this.uncertainty; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IData#getUnits() - */ - @Override - public String getUnits() { - - return this.units; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IData#getFeature() - */ - @Override - public String getFeature() { - - return this.feature; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRDataProvider.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRDataProvider.java deleted file mode 100644 index 9dbda775a..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRDataProvider.java +++ /dev/null @@ -1,551 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.TreeMap; - -import org.eclipse.ice.analysistool.IData; -import org.eclipse.ice.analysistool.IDataProvider; - -/** - *

- * An implementation of the IDataProvider. This class is used to store State - * point data, usually for material decompositions or powers, that can be used - * to store and display changes in value overtime across different features. - *

- * - * @author Scott Forest Hull II - */ -public class LWRDataProvider implements IDataProvider { - /** - *

- * A TreeMap implementation of IData and features. Keep in mind that there - * can be multiple IData for the same feature. - *

- * - */ - private TreeMap> dataTree; - /** - *

- * The current time step. Can not be less than 0, and must be strictly less - * than the number of TimeSteps. Defaults to 0. - *

- * - */ - private double time; - /** - *

- * A description of the source of information for this provider and its - * data. - *

- * - */ - private String sourceInfo; - /** - *

- * The time unit. - *

- * - */ - private String timeUnit; - - /** - *

- * The constructor. - *

- * - */ - public LWRDataProvider() { - // Setup TreeMap - this.dataTree = new TreeMap>(); - - // Setup Source - this.sourceInfo = "No Source Available"; - - // Setup time - this.time = 0; - this.timeUnit = "seconds"; - } - - /** - *

- * Sets the sourceInfo. Can not be null or the empty string. Strings passed - * will be trimmed before being set. - *

- * - * @param sourceInfo - *

- * The sourceInfo to set. - *

- */ - public void setSourceInfo(String sourceInfo) { - if (sourceInfo != null && !sourceInfo.trim().isEmpty()) { - this.sourceInfo = sourceInfo.trim(); - } - - } - - /** - *

- * Adds a IData piece, keyed on the feature and timeStep, to the dataTree. - * If the feature exists in the tree, it will append to the end of the list. - *

- * - * @param data - *

- * The data to add. - *

- * @param time - */ - public void addData(LWRData data, double time) { - - // Local Declarations - ArrayList featureSetList; - FeatureSet set; - boolean featureExistsFlag = false; - - // Return if the passed parameters are incorrect - if (data == null || time < 0) { - return; - } - - featureSetList = this.dataTree.get(time); - - // If the timestep does not exist in the list, add it to the list - if (featureSetList == null) { - featureSetList = new ArrayList(); - set = new FeatureSet(data.getFeature()); - set.addIData(data); - featureSetList.add(set); - this.dataTree.put(time, featureSetList); - - } - - // Otherwise, the timestep exists and needs to append to the current - // running list - else { - - // Append to the current FeatureSet if it exists - for (int i = 0; i < featureSetList.size(); i++) { - // IF the featureset is the same name as the data, add it - if (featureSetList.get(i).getName().equals(data.getFeature())) { - featureSetList.get(i).addIData(data); - featureExistsFlag = true; - break; - } - } - - // If the featureSet does not exist, then add it - if (!featureExistsFlag) { - // If it does not, add it - set = new FeatureSet(data.getFeature()); - set.addIData(data); - - // Add it to the list of sets - featureSetList.add(set); - } - - } - - } - - /** - *

- * Removes the feature and all associated IData from the dataTree at all - * time steps. If a user wishes to remove a single piece of IData from the - * tree, then use the appropriate getData operation on that feature and - * manipulate the data that way. - *

- * - * @param feature - *

- * The feature. - *

- */ - public void removeAllDataFromFeature(String feature) { - - // If feature is null, return - if (feature == null) { - return; - } - // Get the iterator - Iterator iter; - iter = this.dataTree.keySet().iterator(); - - // Iterate over the list of all timesteps and remove all the features - while (iter.hasNext()) { - ArrayList list = this.dataTree.get(iter.next()); - - // If the FeatureSet with the feature name exists, remove it - for (int i = 0; i < list.size(); i++) { - if (list.get(i).getName().equals(feature)) { - list.remove(i); - break; // Break from for loop, otherwise really bad things - // will happen - } - } - } - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(LWRDataProvider otherObject) { - - // Local Declarations - Iterator iter; - - // If null, return - if (otherObject == null) { - return; - } - // Copy dataTree - this.dataTree.clear(); - - // Setup the iterator - iter = otherObject.dataTree.keySet().iterator(); - - // Currently, this will only shallow copy the ArrayList on value. IData - // will have to implement copy and clone routines for it to be a deep - // copy - while (iter.hasNext()) { - Double key = iter.next(); - this.dataTree.put(key, otherObject.dataTree.get(key)); - } - - // Copy Time info - this.time = otherObject.time; - this.sourceInfo = otherObject.sourceInfo; - this.timeUnit = otherObject.timeUnit; - - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return

- * The newly instantiated copied object. - *

- */ - @Override - public Object clone() { - - // Local Declarations - LWRDataProvider component = new LWRDataProvider(); - - // Copy the component - component.copy(this); - - // Return the component - return component; - - } - - /** - *

- * Sets the time units. - *

- * - * @param timeUnit - *

- * The time unit to be set. - *

- */ - public void setTimeUnits(String timeUnit) { - - if (timeUnit != null && !timeUnit.trim().isEmpty()) { - this.timeUnit = timeUnit; - } - - } - - /** - *

- * Equality check. Returns true if equals, false otherwise. - *

- * - * @param otherObject - *

- * Object to equate. - *

- * @return

- * True if equal, false otherwise. - *

- */ - @Override - public boolean equals(Object otherObject) { - - // Local declarations - LWRDataProvider component; - boolean retVal = false; - - // If they are equal to the same object, return true - if (this == otherObject) { - return true; - } - // If this object is an instance of the LWRDataProvider, cast it. - // Make sure it is also not null - if (otherObject != null && otherObject instanceof LWRDataProvider) { - component = (LWRDataProvider) otherObject; - - // Check values - retVal = (this.dataTree.equals(component.dataTree) - && this.time == component.time - && this.sourceInfo.equals(component.sourceInfo) && this.timeUnit - .equals(component.timeUnit)); - - } - - // Return retVal - return retVal; - } - - /** - *

- * The hashcode. - *

- * - * @return

- * the hash. - *

- */ - @Override - public int hashCode() { - - int hash = 31; - - // Calculate IDataProvider info - hash += 31 * this.dataTree.hashCode(); - hash += 31 * this.time; - hash += 31 * this.sourceInfo.hashCode(); - hash += 31 * this.timeUnit.hashCode(); - - // return hash - return hash; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getFeatureList() - */ - @Override - public ArrayList getFeatureList() { - - // Local Declarations - ArrayList featureList = new ArrayList(); - HashMap map = new HashMap(); - - // Get the iterator - Iterator iter; - iter = this.dataTree.keySet().iterator(); - - // Iterate over the list of all timesteps get one unique feature - while (iter.hasNext()) { - ArrayList list = this.dataTree.get(iter.next()); - - // If the map does not have the feature name, add it - for (int i = 0; i < list.size(); i++) { - if (map.get(list.get(i).getName()) == null) { - map.put(list.get(i).getName(), 1); - } - } - } - - // Append to featureList - for (String name : map.keySet()) { - featureList.add(name); - } - - // Return the featureList - return featureList; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getNumberOfTimeSteps() - */ - @Override - public int getNumberOfTimeSteps() { - - return this.dataTree.size(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#setTime(double) - */ - @Override - public void setTime(double step) { - if (step >= 0.0) { - this.time = step; - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getDataAtCurrentTime(java.lang.String) - */ - @Override - public ArrayList getDataAtCurrentTime(String feature) { - - // If feature is null, return - if (feature == null) { - return new ArrayList(); - } - // Locate the list - ArrayList list = this.dataTree.get(this.time); - - if (list != null) { - // If the list exists, return the iData - for (int i = 0; i < list.size(); i++) { - if (list.get(i).getName().equals(feature)) { - - // Return the reference to the list of iData - return list.get(i).getIData(); - } - } - } - - return new ArrayList(); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getSourceInfo() - */ - @Override - public String getSourceInfo() { - - return this.sourceInfo; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getFeaturesAtCurrentTime() - */ - @Override - public ArrayList getFeaturesAtCurrentTime() { - - // Local Declarations - ArrayList features = new ArrayList(); - ArrayList list = null; - - // Get the list at the time - list = this.dataTree.get(this.time); - - // If the time does not exist, return empty - if (list == null) { - return features; - } - // Get the features - for (int i = 0; i < list.size(); i++) { - features.add(list.get(i).getName()); - } - - return features; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getTimes() - */ - @Override - public ArrayList getTimes() { - - // Local Declarations - ArrayList times = new ArrayList(); - - // Get the iterator - Iterator iter = this.dataTree.keySet().iterator(); - - // Add the times to the arraylist - while (iter.hasNext()) { - times.add(iter.next()); - } - - // Return the list of times - return times; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getTimeStep(double) - */ - @Override - public int getTimeStep(double time) { - - // Get the iterator - Iterator iter = this.dataTree.keySet().iterator(); - int counter = 0; - - // Iterate the list - while (iter.hasNext()) { - - // If the time is there, return the index - if (iter.next().equals(time)) { - return counter; - } - counter++; - - } - - // Time not found! - return -1; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.analysistool.IDataProvider#getTimeUnits() - */ - @Override - public String getTimeUnits() { - - return this.timeUnit; - - } - - /** - *

- * Returns the current time step. - *

- * - * @return

- * The current time step. - *

- */ - public double getCurrentTime() { - - return this.time; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRGridManager.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRGridManager.java deleted file mode 100644 index 670f8cf51..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRGridManager.java +++ /dev/null @@ -1,1041 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; -import java.util.TreeMap; - -import ncsa.hdf.object.Dataset; -import ncsa.hdf.object.Datatype; -import ncsa.hdf.object.HObject; -import ncsa.hdf.object.h5.H5Datatype; -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.analysistool.IData; -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; - -/** - *

- * The LWRGridManager class manages LWRComponents and their GridLocations on a - * Cartesian grid with an equal number of rows and columns. This class - * implements the ICE IGridManager interface. - *

- *

- * This class also allows a "pass through" for LWRDataProviders, which are used - * to store state point data. This is a preferred method for storing data over - * time instead of using LWRComponent's IDataProvider directly. Please see - * GridLocation for more details on the usage of this delegation class. - *

- * - * @author Scott Forest Hull II - */ -public class LWRGridManager extends LWRComponent implements IGridManager { - /** - * - */ - private TreeMap lWRComponents; - - /** - *

- * The size of the rows and columns. - *

- * - */ - private int size; - - /** - *

- * A grid table suffix for reading the dataset. - *

- * - */ - protected String hdf5GridTableSuffix = "'s Grid Table"; - // Names for groups - private String dataH5GroupName = "Positions"; - private String timeStepNamePrefix = "TimeStep: "; - - private String headTableString = " headTable"; - private String dataTableString = " dataTable"; - - /** - *

- * The Constructor. - *

- * - * @param size - *

- * The maximum number of rows or columns. - *

- *

- *

- */ - - public LWRGridManager(int size) { - - // Setup LWRComponent Attributes - this.name = "LWRGridManager 1"; - this.description = "LWRGridManager 1's Description"; - this.id = 1; - - // Setup defaults for the LWRGridManager - lWRComponents = new TreeMap(); - this.size = 1; - - // Setup size if it is at least 1 or greater. Otherwise use defaults - if (size > 0) { - this.size = size; - } - - // Setup the HDF5LWRTagType to correct type - this.HDF5LWRTag = HDF5LWRTagType.LWRGRIDMANAGER; - - } - - /** - *

- * Returns the maximum number of rows or columns. - *

- * - * @return

- * Returns the maximum number of rows or columns. - *

- */ - public int getSize() { - - return this.size; - } - - /** - *

- * Overrides the equals operation to check the attributes on this object - * with another object of the same type. Returns true if the objects are - * equal. False otherwise. - *

- * - * @param otherObject - *

- * The object to be compared. - *

- * @return

- * True if otherObject is equal. False otherwise. - *

- */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - LWRGridManager manager; - boolean retVal = false; - - // Make sure the object is not null and is an instance of this object - if (otherObject != null && otherObject instanceof LWRGridManager) { - manager = (LWRGridManager) otherObject; - - // If they are equal to the same heap, return true - if (this == otherObject) { - return true; - } - // Check values - retVal = (super.equals(otherObject) - && this.lWRComponents.equals(manager.lWRComponents) && this.size == manager.size); - - // If the size is not equal, return false - if (this.lWRComponents.size() != manager.lWRComponents.size()) { - return false; - } - - // Check the map for comparisons - for (Map.Entry entry : this.lWRComponents - .entrySet()) { - - // Grab the location - GridLocation location = entry.getKey(); - boolean objectFound = false; - - // Iterate over the manager's list to see if the object exists. - // If it does, mark it as true - for (Map.Entry managerEntry : manager.lWRComponents - .entrySet()) { - if (managerEntry.getKey().equals(location) - && managerEntry.getValue().equals(entry.getValue())) { - objectFound = true; - break; - } - } - // If the object was not found, then return false. - if (!objectFound) { - return false; - } - } - - } - - // Return retVal - return retVal; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return

- * The hash of the object. - *

- */ - @Override - public int hashCode() { - - // Local Declarations - int hash = super.hashCode(); - - // Compute hash of attributes - hash += 31 * this.lWRComponents.hashCode(); - hash += 31 * this.size; - - // Return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(LWRGridManager otherObject) { - - // Local Declarations - Iterator iter; - GridLocation location; - - // If the otherObject is null, return - if (otherObject == null) { - return; - } - // Copy contents- super - super.copy(otherObject); - - // Copy contents - - this.size = otherObject.size; - - // Perform a deep copy of the tree - this.lWRComponents.clear(); - - // Get the iterator - iter = otherObject.lWRComponents.keySet().iterator(); - - // Iterate over the list, deep copy the lWRComponents and values - while (iter.hasNext()) { - location = iter.next(); - this.lWRComponents.put((GridLocation) location.clone(), - otherObject.lWRComponents.get(location)); - } - - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return

- * The newly instantiated copied object. - *

- */ - @Override - public Object clone() { - - // Local Declarations - LWRGridManager manager = new LWRGridManager(0); - - // Copy the contents of this manager - manager.copy(this); - - // Return the newly instantiated object - return manager; - - } - - /** - * (non-Javadoc) - * - * @see IGridManager#getComponentName(GridLocation location) - */ - @Override - public String getComponentName(GridLocation location) { - - // If the location is not null, return the component - if (location != null) { - return this.lWRComponents.get(location); - } - return null; - } - - /** - * (non-Javadoc) - * - * @see IGridManager#addComponent(Component component, GridLocation - * location) - */ - @Override - public void addComponent(Component component, GridLocation location) { - - // If the passed args are not null and if the locations are valid, add - // to the grid - // Also, if the location does already exist, do not add component - if (component != null && location != null - && location.getRow() < this.size - && location.getColumn() < this.size && location.getRow() >= 0 - && location.getColumn() >= 0 - && !this.lWRComponents.containsKey(location)) { - this.lWRComponents.put(location, component.getName()); - } - - } - - /** - * (non-Javadoc) - * - * @see IGridManager#removeComponent(GridLocation location) - */ - @Override - public void removeComponent(GridLocation location) { - - // If the location is not null, remove location - if (location != null) { - this.lWRComponents.remove(location); - } - - } - - /** - * (non-Javadoc) - * - * @see IGridManager#removeComponent(Component component) - */ - @Override - public void removeComponent(Component component) { - - // If the component is not null, remove the associated component - if (component != null) { - - // Iterate over a map - for (Map.Entry entry : this.lWRComponents - .entrySet()) { - String lComponent = entry.getValue(); - - // If the components are equal, remove the entry - if (lComponent.equals(component.getName())) { - this.lWRComponents.remove(entry.getKey()); - return; - } - } - - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeIntegerAttribute(h5File, h5Group, "size", - size); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeDatasets(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeDatasets(H5File h5File, H5Group h5Group) { - - // Return if the file or group is null - if (h5File == null || h5Group == null) { - return false; - } - // Call super's method - super.writeDatasets(h5File, h5Group); - - // Return true if there are no operations to write - if (this.lWRComponents.isEmpty()) { - return true; - } - return this.writeFeatureSets(h5File, h5Group); - } - - /** - * This writes the FeatureSets due to a given location - * - * @param The - * H5File - * @param The - * Group - * - * @return True if successful, false otherwise - */ - private boolean writeFeatureSets(H5File h5File, H5Group h5Group) { - - // Return if the file or group is null - if (h5File == null || h5Group == null) { - return false; - } - // Gather all units and put into a table later. - ArrayList unitsList = new ArrayList(); - ArrayList positionNames = new ArrayList(); - H5Group mainH5Group = null; - - // Setup the size of the String array Dataset - int maxLength = 0; - int maxPositionLength = 0; - - if (this.lWRComponents.isEmpty()) { - return true; - } - - // Make the main group - mainH5Group = HdfWriterFactory.createH5Group(h5File, - this.dataH5GroupName, h5Group); - - // Iterate over the GridLocations and add them to the list - // Iterate over a map - for (Map.Entry entry : this.lWRComponents - .entrySet()) { - - GridLocation location = entry.getKey(); - - // Local Declarations - H5Group dataH5Group; - double previousTime = 0; - - // Create a HDF5Group for data - dataH5Group = HdfWriterFactory.createH5Group(h5File, "Position " - + location.getRow() + " " + location.getColumn(), - mainH5Group); - - // Create a Dataset. This contains Row, Column, and a position in - // the positionNames table. - long[] dimsPosition = { 3 }; - int[] positionData = new int[3]; - - // Get the position - if (!positionNames.contains(entry.getValue())) { - positionNames.add(entry.getValue()); - maxPositionLength = Math.max(entry.getValue().length(), - maxPositionLength); - } - - // Store row, col, and the name at that position - positionData[0] = location.getRow(); - positionData[1] = location.getColumn(); - // Get the index of that that position - positionData[2] = positionNames.indexOf(entry.getValue()); - - // Get the datatype for integer - Datatype dataTypeInteger = HdfWriterFactory - .createIntegerH5Datatype(h5File); - - // Create the simple dataset - dataList - try { - Dataset positionDataset = h5File.createScalarDS( - "Position Dataset", dataH5Group, dataTypeInteger, - dimsPosition, null, null, 0, positionData); - - positionDataset.init(); - } catch (Exception e) { - logger.error(getClass().getName() + " Exception!",e); - return false; - } - - previousTime = location.getLWRDataProvider().getCurrentTime(); - - // Get the LWRDataProvider - LWRDataProvider provider = location.getLWRDataProvider(); - - // Write the data at the individual time steps. If false, return - if (!this.writeTimeAtFeatureSet(dataH5Group, h5File, provider, - unitsList)) { - - // Reset time - location.getLWRDataProvider().setTime(previousTime); - - return false; - } - - // Reset time - location.getLWRDataProvider().setTime(previousTime); - } - try { - - // Externalize names - if (!(positionNames.isEmpty())) { - // Externalize units - String[] arrayUnits = new String[positionNames.size()]; - for (int w = 0; w < positionNames.size(); w++) { - arrayUnits[w] = positionNames.get(w); - } - - // Setup dimensions - long[] dimsStrings = { positionNames.size() }; - - // Setup string datatype - H5Datatype datatypeString = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, maxPositionLength, - Datatype.NATIVE, Datatype.NATIVE); - Dataset dataSet3 = h5File.createScalarDS( - "Simple Position Names Table", mainH5Group, - datatypeString, dimsStrings, null, null, 0, null); - dataSet3.write(arrayUnits); - - dataSet3.init(); - - } - - // Only write if there are units to write! - if (!(unitsList.isEmpty())) { - // Externalize the units - String[] arrayUnits = new String[unitsList.size()]; - for (int w = 0; w < unitsList.size(); w++) { - - // Get the length of the units - maxLength = Math.max(unitsList.get(w).length(), maxLength); - arrayUnits[w] = unitsList.get(w); - } - - // Setup dimensions - long[] dimsStrings = { unitsList.size() }; - - // Setup string datatype - H5Datatype datatypeString = (H5Datatype) h5File.createDatatype( - Datatype.CLASS_STRING, maxLength, Datatype.NATIVE, - Datatype.NATIVE); - Dataset dataSet3 = h5File.createScalarDS("Units Table", - mainH5Group, datatypeString, dimsStrings, null, null, - 0, null); - dataSet3.write(arrayUnits); - - dataSet3.init(); - } - - } catch (Exception e) { - // Break and return - logger.error(getClass().getName() + " Exception!",e); - return false; - - } - - return true; - - } - - /** - * Writes the Datasets for all the time steps to the group. Returns true if - * the operation was successful, false otherwise. - * - * @param dataH5Group - * The main data group - * @param h5File - * The h5file - * @param provider - * The LWRGridDataProvider @ Location - * @param unitsList - * The list of units. Must be passed to keep the list maintained! - * @return True if successful, false otherwise. - */ - private boolean writeTimeAtFeatureSet(H5Group dataH5Group, H5File h5File, - LWRDataProvider provider, ArrayList unitsList) { - - // Iterate over the dataTree and create timesteps for each key in - // the tree - for (int w = 0; w < provider.getTimes().size(); w++) { - - // Get the time - double time = provider.getTimes().get(w); - - // Set the time in order to get the FeatureSet - provider.setTime(time); - - // Create a new timeStep group based on the prefix and the - // timeStep - H5Group timeStepH5Group = HdfWriterFactory.createH5Group(h5File, - timeStepNamePrefix + "" + w, dataH5Group); - - // Add attributes to the timeStep group - - // Create attribute: time as Double - HdfWriterFactory.writeDoubleAttribute(h5File, timeStepH5Group, - "time", time); - - // Create a Compound Dataset for each timeStep to represent the - // collection of FeatureSets. This contains the list of Feature - // Sets - for (int i = 0; i < provider.getFeaturesAtCurrentTime().size(); i++) { - - // Get the FeatureSet - ArrayList set = provider.getDataAtCurrentTime(provider - .getFeatureList().get(i)); - - // Get the number of IDatas stored on the FeatureSet - int iDataSize = set.size(); - - // Create a 2D array n x 5 - double[][] dataList = new double[iDataSize][5]; - - // Create a head data table - long[][] headData = new long[iDataSize][2]; - - // Iterate over the IDatas to fill out the arrays listed - // above - for (int j = 0; j < set.size(); j++) { - // Get the iData at the location - IData iData = set.get(j); - - // Set value and uncertainty - dataList[j][0] = iData.getValue(); - dataList[j][1] = iData.getUncertainty(); - - // Get the position - ArrayList pos = iData.getPosition(); - dataList[j][2] = pos.get(0).doubleValue(); - dataList[j][3] = pos.get(1); - dataList[j][4] = pos.get(2); - - // If the unitsList does not contain the units, add them! - if (!unitsList.contains(iData.getUnits())) { - unitsList.add(iData.getUnits()); - - } - - // Once this is done, append to the headList. Note that - // this is to be externalized out of this loop in the - // future - // Set the dataList id and the unitsList id - headData[j][0] = j; - headData[j][1] = unitsList.indexOf(iData.getUnits()); - - } - - try { - - // Calculate the dimensions of the length of each - // dataSet by - // the number of IDatas in the FeatureSet - long[] dimsData = { iDataSize, 5 }; - long[] dimsHead = { iDataSize, 2 }; - - // Get the datatype for integer and LONG (int) - Datatype dataTypeDouble = HdfWriterFactory - .createFloatH5Datatype(h5File); - Datatype dataTypeLong = h5File.createDatatype( - Datatype.CLASS_INTEGER, 8, Datatype.NATIVE, - Datatype.NATIVE); - - // Create the simple dataset - dataList - Dataset dataSet1 = h5File.createScalarDS(set.get(0) - .getFeature() + this.dataTableString, - timeStepH5Group, dataTypeDouble, dimsData, null, - null, 0, dataList); - - // Create the simple dataset - headData - Dataset dataSet2 = h5File.createScalarDS(set.get(0) - .getFeature() + this.headTableString, - timeStepH5Group, dataTypeLong, dimsHead, null, - null, 0, headData); - - dataSet1.init(); - dataSet2.init(); - } catch (Exception e) { - // Break and return - logger.error(getClass().getName() + " Exception!",e); - - return false; - } - } - - } - - // Operation successful, return true - return true; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readDatasets(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readDatasets(H5Group h5Group) { - - // Call super - boolean flag = super.readDatasets(h5Group); - - if (!flag) { - return false; - } - // Open the Positions dataSet - H5Group dataH5Group = HdfReaderFactory.getChildH5Group(h5Group, - this.dataH5GroupName); - Dataset unitsSet; - Dataset positionNamesSet; - String[] arrayStrings = null; - String[] arrayPositions = null; - - // Return true if this is hit. Means that no positions were added at - // this time. - if (dataH5Group == null) { - return true; - } - // Clear the tree - this.lWRComponents.clear(); - - // If the dataGroup is 0, return - if (dataH5Group.getNumberOfMembersInFile() == 0) { - return true; - } - // Get the last member list and make sure it is correct - if (HdfReaderFactory.getDataset(dataH5Group, "Units Table") == null) { - // Do nothing - } else { - unitsSet = HdfReaderFactory.getDataset(dataH5Group, "Units Table"); - - // Cast to array list - try { - // Get data - Object unitListData = unitsSet.getData(); - - // Cast to array of Strings - arrayStrings = (String[]) unitListData; - - } catch (Exception e) { - logger.error(getClass().getName() + " Exception!",e); - return false; - } - } - - // Get the Position names table - if (HdfReaderFactory.getDataset(dataH5Group, - "Simple Position Names Table") == null) { - // Return false. This is bad - System.err - .println("LWRGridManager: Can't find dataset for reading the positions table."); - return false; - } else { - - try { - - // Get the dataset - positionNamesSet = HdfReaderFactory.getDataset(dataH5Group, - "Simple Position Names Table"); - - // Get data - Object positionsNamesData = positionNamesSet.getData(); - - // Cast to array of strings - arrayPositions = (String[]) positionsNamesData; - } catch (Exception e) { - logger.error(getClass().getName() + " Exception!",e); - return false; - } - } - - // Iterate over ONLY the groups - ArrayList positionsMemberList = HdfReaderFactory - .getChildH5Groups(dataH5Group); - - // Iterate over the group list - for (int i = 0; i < positionsMemberList.size(); i++) { - - // Get the position - H5Group position = positionsMemberList.get(i); - - // Get the position information from dataset - Dataset positionDataset = HdfReaderFactory.getDataset(position, - "Position Dataset"); - - // Convert dataset to data - Object positionData; - try { - positionDataset.init(); - positionData = positionDataset.getData(); - } catch (Exception e) { - logger.error(getClass().getName() + " Exception!",e); - return false; - } - - // Get the positionInformation - int[] positionInfo = { 3 }; - positionInfo = (int[]) positionData; - - // Create the location and add it to the tree - GridLocation location = new GridLocation(positionInfo[0], - positionInfo[1]); - String name = arrayPositions[positionInfo[2]]; - - // Put it in the tree - this.lWRComponents.put(location, name); - - // This is important: If there is a units table with no data in it, - // then there should be no positions. Flag error and exit - if (arrayStrings == null && position.getNumberOfMembersInFile() > 1) { - return false; - } - // Iterate over ONLY the groups - ArrayList timeStepsMemberList = HdfReaderFactory - .getChildH5Groups(position); - LWRDataProvider provider = location.getLWRDataProvider(); - - // Pass the LWRDataProvider, the groups, and the array of units to - // read the time steps at the feature. - // Return if the operation returns false - if (!this.readTimeStepsAtFeature(provider, timeStepsMemberList, - arrayStrings)) { - return false; - } - - } - - return true; - - } - - /** - * Reads the time steps at a feature and adds the time steps to the - * GridLocation. Returns true if the operation was successful, false - * otherwise. - * - * @param provider - * The LWRDataProvider - * @param timeStepsMemberList - * The time steps on that group - * @param arrayStrings - * An array of strings used to specify the unit list. - * @return True if the operation was successful, false otherwise. - */ - private boolean readTimeStepsAtFeature(LWRDataProvider provider, - ArrayList timeStepsMemberList, String[] arrayStrings) { - - // Iterate over the time groups - for (int j = 0; j < timeStepsMemberList.size(); j++) { - - H5Group timeGroup = timeStepsMemberList.get(j); - double time = HdfReaderFactory.readDoubleAttribute(timeGroup, - "time"); - - ArrayList memberList = HdfReaderFactory - .getChildH5Members(timeGroup); - - // Iterate over the available datasets. Note there will be two - // dataSets per feature. - // NOTE K+=2!!!!! - int timeListSize = memberList.size(); - for (int k = 0; k < timeListSize; k += 2) { - - // Get the FeatureGroupHead - Dataset featureGroupData = (Dataset) memberList.get(k); - Dataset featureGroupHead = (Dataset) memberList.get(k + 1); - - // Get the name of the feature - note replace the - // dataTableString - String featureName = featureGroupData.getName().replace( - this.dataTableString, ""); - - // call init - featureGroupData.init(); - featureGroupHead.init(); - - // Get the object data off the dataset - Object headListData; - Object dataListData; - try { - dataListData = featureGroupData.getData(); - headListData = featureGroupHead.getData(); - } catch (Exception e) { - logger.error(getClass().getName() + " Exception!",e); - return false; - } - - // get the dimensions of data and head - long dataColSize = featureGroupData.getDims()[1]; - long headColSize = featureGroupHead.getDims()[1]; - - // Convert the data to a readable format - double[] dataArray = (double[]) dataListData; - long[] headArray = (long[]) headListData; - - // Iterate over the list and grab values as necessary - - // Counts the iterations in the following value grabber - int counter = 0; - - // Iterate over the values and create the correct LWRData - // Iterate by columnsize - for (int l = 0; l < dataArray.length; l += dataColSize) { - - // Create the data and setup basic attributes - LWRData lwrdata = new LWRData(featureName); - lwrdata.setValue(dataArray[l]); - lwrdata.setUncertainty(dataArray[l + 1]); - - // This states: At position X in the array of string - // units, give me the headArray's second (or last) - // column value for each row. - // The last column value should represent the unitsID, - // or the id to represent the units - lwrdata.setUnits(arrayStrings[(int) headArray[(int) ((counter) * headColSize) + 1]]); - - // Setup position - ArrayList positionss = new ArrayList(); - positionss.add(dataArray[l + 2]); - positionss.add(dataArray[l + 3]); - positionss.add(dataArray[l + 4]); - - // Set position - lwrdata.setPosition(positionss); - - // Add the lwrdata to the location - provider.addData(lwrdata, time); - - counter++; - } - - } - - } - - // Operation successful. Return true - return true; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - Integer size = HdfReaderFactory.readIntegerAttribute(h5Group, "size"); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (size == null || !flag || h5Group == null) { - return false; - } - // If everything is valid, then set data - this.size = size.intValue(); - - // Reset map - this.lWRComponents.clear(); - - return true; - - } - - /** - *

- * Returns the data provider at the grid location or null if it does not - * exist. - *

- * - * @param location - *

- * The grid location. - *

- * @return

- * The provider at that location - *

- */ - public LWRDataProvider getDataProviderAtLocation(GridLocation location) { - - if (location == null) { - return null; - } - // Iterate over a map - for (Map.Entry entry : this.lWRComponents - .entrySet()) { - - // If the key exists, return - if (location.getRow() == entry.getKey().getRow() - && location.getColumn() == entry.getKey().getColumn()) { - return entry.getKey().getLWRDataProvider(); - } - } - - // Not found! - return null; - - } - - /** - *

- * Returns the list of grid locations at the given name. If none are found, - * returns an empty list. - *

- * - * @param name - *

- * The name - *

- * @return

- * The locations - *

- */ - public ArrayList getGridLocationsAtName(String name) { - - // Local Declarations - ArrayList locations = new ArrayList(); - - if (name == null) { - return locations; - } - // Iterate over a map - for (Map.Entry entry : this.lWRComponents - .entrySet()) { - - // If the key exists, return - if (name.equals(entry.getValue())) { - locations.add((GridLocation) entry.getKey().clone()); - } - } - - // Return list - return locations; - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRRod.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRRod.java deleted file mode 100644 index 853eb42bf..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWRRod.java +++ /dev/null @@ -1,487 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; -import java.util.TreeSet; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfWriteable; - -/** - *

- * The LWRRod class is a generalized class representing a basic rod as a - * collection of materialBlocks contained by a ring (aka the clad). A LWRRod - * should be considered the basis for all "rod-tyoes" implemented within a - * reactor. Details concerning material compositions should be taken care of on - * the collections of rings on the materialblocks. - *

- *

- * Please note that the MaterialBlocks MUST HAVE UNIQUE POSITIONS SET! If there - * are material blocks with 2 of the same EXACT position type, then the first - * materialblock will be overridden by the second materialblock of the same - * position value. This is very important to understand when adding - * materialBlocks to the grid. - *

- *

- *

- * - * @author Scott Forest Hull II - */ -public class LWRRod extends LWRComponent { - /** - *

- * An annular Ring which surrounds this LWRRod's MaterialBlocks list. - *

- * - */ - private Ring clad; - /** - *

- * A Material of MaterialType.GAS that fills the voids within this LWRRod. - *

- * - */ - private Material fillGas; - /** - *

- * The pressure of the fillGas Material. Can not be less than or equal to 0. - *

- * - */ - private double pressure; - /** - * - */ - private TreeSet materialBlocks; - - /** - *

- * The nullary Constructor. - *

- * - */ - public LWRRod() { - - // Set default LWRComponent Values - this.name = "LWRRod"; - this.description = "LWRRod's Description"; - this.id = 1; - - // Set default values for privates - this.pressure = 2200.00; - Material cladMaterial = new Material("Zirc", MaterialType.SOLID); - this.clad = new Ring("Clad", cladMaterial, -1.0, -1.0); - this.fillGas = new Material("Void", MaterialType.GAS); - this.materialBlocks = new TreeSet(); - - // Setup LWRComponentType to correct type - this.HDF5LWRTag = HDF5LWRTagType.LWRROD; - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this LWRRod. - *

- */ - public LWRRod(String name) { - // Call nullary operator - this(); - // Pass name - this.setName(name); - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this LWRRod. - *

- * @param fillGas - *

- * A Material of MaterialType.GAS that fills the voids within - * this LWRRod. - *

- * @param pressure - *

- * The pressure of the fillGas Material. - *

- * @param materialBlocks - *

- * The MaterialBlock list within this LWRRod. - *

- */ - public LWRRod(String name, Material fillGas, double pressure, - TreeSet materialBlocks) { - - // Call the respective operators for passed parameters - this(name); - this.setFillGas(fillGas); - this.setPressure(pressure); - this.setMaterialBlocks(materialBlocks); - - } - - /** - *

- * Returns a Material of MaterialType.GAS that fills the voids within this - * LWRRod. - *

- * - * @return

- * A Material of MaterialType.GAS that fills the voids within this - * LWRRod. - *

- */ - public Material getFillGas() { - return this.fillGas; - } - - /** - *

- * Sets the Material of MaterialType.GAS that fills the voids within this - * LWRRod. Can not be set to null. - *

- * - * @param fillGas - *

- * A Material of MaterialType.GAS that fills the voids within - * this LWRRod. - *

- */ - public void setFillGas(Material fillGas) { - // if fillGas is not null - if (fillGas != null) { - this.fillGas = fillGas; - } - - } - - /** - *

- * Sets the pressure of the fillGas Material. Can not be set less than or - * equal to 0. - *

- * - * @param pressure - *

- * The pressure of the fillGas Material. - *

- */ - public void setPressure(double pressure) { - // if pressure is not 0 or negative - if (pressure > 0.0) { - this.pressure = pressure; - } - - } - - /** - *

- * Returns the pressure of the fillGas Material. - *

- * - * @return

- * The pressure of the fillGas Material. - *

- */ - public double getPressure() { - return this.pressure; - } - - /** - *

- * Returns the list of MaterialBlocks within this LWRRod. - *

- * - * @return

- * The Stack object within this LWRRod. - *

- */ - public TreeSet getMaterialBlocks() { - return this.materialBlocks; - } - - /** - *

- * Sets the list of MaterialBlocks within this LWRRod. Can not be set null. - *

- * - * @param materialBlocks - *

- * The materialBlocks list within this LWRRod. - *

- */ - public void setMaterialBlocks(TreeSet materialBlocks) { - if (materialBlocks != null && !(materialBlocks.isEmpty())) { - this.materialBlocks = materialBlocks; - } - - } - - /** - *

- * Returns the clad object of this LWRRod object, if set or null. - *

- * - * @return The rod's clad, which is a Ring, or {@code null} if not set. - */ - public Ring getClad() { - return this.clad; - } - - /** - *

- * Sets the clad object for this LWRRod. It can not be set to null. - *

- * - * @param clad - */ - public void setClad(Ring clad) { - // if clad is not null - if (clad != null) { - this.clad = clad; - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - LWRRod rod; - boolean retVal = false; - // If the objects are the same on the heap, return true - if (this == otherObject) { - return true; - } - // If the object is null or not an instance of this object, return false - if (otherObject != null && otherObject instanceof LWRRod) { - // Cast it - rod = (LWRRod) otherObject; - // Check values - retVal = (super.equals(otherObject) && this.clad.equals(rod.clad) - && this.fillGas.equals(rod.fillGas) - && this.materialBlocks.equals(rod.materialBlocks) && this.pressure == rod.pressure); - } - - // Return retVal - return retVal; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#hashCode() - */ - @Override - public int hashCode() { - - // Local Declarations - int hash = super.hashCode(); - - // Hash local contents - hash += 31 * this.pressure; - hash += 31 * this.clad.hashCode(); - hash += 31 * this.fillGas.hashCode(); - hash += 31 * this.materialBlocks.hashCode(); - - // Return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(LWRRod otherObject) { - - // If the otherObject is null, return - if (otherObject == null) { - return; - } - // Copy contents - super - super.copy(otherObject); - - // Copy local contents - deep copy - this.clad = (Ring) otherObject.clad.clone(); - this.fillGas = (Material) otherObject.fillGas.clone(); - this.pressure = otherObject.pressure; - this.materialBlocks.clear(); - for (int i = 0; i < otherObject.materialBlocks.size(); i++) { - this.materialBlocks - .add((MaterialBlock) ((MaterialBlock) otherObject.materialBlocks - .toArray()[i]).clone()); - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#clone() - */ - @Override - public Object clone() { - - // Local Declarations - LWRRod rod = new LWRRod(); - - // Copy contents - rod.copy(this); - - // Return newly instantiated object - return rod; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeDoubleAttribute(h5File, h5Group, - "pressure", pressure); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#getWriteableChildren() - */ - @Override - public ArrayList getWriteableChildren() { - - // Get the children in super - ArrayList children = super.getWriteableChildren(); - - // If super had no children - if (children == null) { - - // Initialize to new array list - children = new ArrayList(); - } - - // Add the materialBlocks, clad and fillGas to children - children.add(this.clad); - children.add(this.fillGas); - children.addAll(this.materialBlocks); - - return children; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readChild(org.eclipse.ice.io.hdf.IHdfReadable) - */ - @Override - public boolean readChild(IHdfReadable iHdfReadable) { - - // If the child is null or not an instance of LWRComponent, then return - // false. - if (iHdfReadable == null || !(iHdfReadable instanceof LWRComponent)) { - return false; - } - - // Cast the child into a LWRComponent - LWRComponent childComponent = (LWRComponent) iHdfReadable; - - // If this is a Ring - if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.RING) { - - // Assign to correct object - this.clad = (Ring) childComponent; - - // If this is a material - } else if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.MATERIAL) { - - // Assign to correct object - this.fillGas = (Material) childComponent; - - // If this is a Material Block - } else if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.MATERIALBLOCK) { - - // Assign to correct object - this.materialBlocks.add((MaterialBlock) childComponent); - - } - - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - Double pressure = HdfReaderFactory.readDoubleAttribute(h5Group, - "pressure"); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (pressure == null || !flag || h5Group == null) { - return false; - } - // If everything is valid, then set data - this.pressure = pressure; - - return true; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#accept(org.eclipse.ice.reactor.ILWRComponentVisitor) - */ - @Override - public void accept(ILWRComponentVisitor visitor) { - visitor.visit(this); - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWReactor.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWReactor.java deleted file mode 100644 index a793bac62..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/LWReactor.java +++ /dev/null @@ -1,281 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import javax.xml.bind.annotation.XmlTransient; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; - -/** - *

- * The LWReactor class represents any Light Water Nuclear Reactor. - *

- * - * @author Scott Forest Hull II - */ -public class LWReactor extends LWRComposite { - - /** - *

- * The size. Defaults to 1 if not set correctly in the constructor. - *

- * - */ - @XmlTransient - protected int size; - - /** - * A default constructor that should ONLY be used for persistence and - * testing. It is equivalent to LWReactor(15). - */ - public LWReactor() { - this(15); - } - - /** - *

- * A parameterized constructor. - *

- * - * @param size - *

- * The size of the reactor. - *

- */ - public LWReactor(int size) { - - // Setup size - this.size = size; - if (size <= 0) { - this.size = 1; - } - - // Setup default LWRComponent info - this.name = "LWReactor 1"; - this.description = "LWReactor 1's Description"; - this.id = 1; - - // Setup LWRComponentType to correct type - this.HDF5LWRTag = HDF5LWRTagType.LWREACTOR; - - } - - /** - *

- * An operation that overrides the LWRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param component - *

- * The Component to be added. - *

- */ - @Override - public void addComponent(Component component) { - - // Does nothing - - } - - /** - *

- * An operation that overrides the LWRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param childId - *

- * The id of the Component to remove. - *

- */ - @Override - public void removeComponent(int childId) { - - // Does nothing - - } - - /** - *

- * An operation that overrides the LWRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param name - *

- * The name of the Component to remove. - *

- */ - @Override - public void removeComponent(String name) { - - // Does nothing - - } - - /** - *

- * Returns the size (usually the diameter) of the reactor. - *

- * - * @return The size. - */ - public int getSize() { - - return this.size; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeIntegerAttribute(h5File, h5Group, "size", - size); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - LWReactor reactor; - boolean retVal = false; - - // Check to see if they are equal to the same heap - return true - if (otherObject == this) { - return true; - } - // If otherObject is null or is not an instance of this object, return - // false - if (otherObject != null && otherObject instanceof LWReactor) { - - // Cast it - reactor = (LWReactor) otherObject; - - // Check values - retVal = super.equals(otherObject) && this.size == reactor.size; - } - - // Return retVal - return retVal; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#hashCode() - */ - @Override - public int hashCode() { - - // Local Declarations - int hash = super.hashCode(); - - // Hash local values - hash += 31 * this.size; - - // Return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(LWReactor otherObject) { - - // If the otherObject is null, return - if (otherObject == null) { - return; - } - // Copy contents - super - super.copy(otherObject); - - // Copy local contents - this.size = otherObject.size; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#clone() - */ - @Override - public Object clone() { - - // Local Declarations - LWReactor reactor = new LWReactor(0); - - // Copy contents - reactor.copy(this); - - // Return newly instantiated object - return reactor; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - Integer size = HdfReaderFactory.readIntegerAttribute(h5Group, "size"); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (size == null || !flag || h5Group == null) { - return false; - } - // If everything is valid, then set data - this.size = size.intValue(); - - return true; - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/Material.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/Material.java deleted file mode 100644 index b6e92ad94..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/Material.java +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; - -/** - *

- * The Material class is a representation of any material property of any class - * within an LWReactor. The setName for this class should represent the material - * name. The Material Class can also indicate what type of material is defined - * (solid, liquid, gas). - *

- * - * @author Scott Forest Hull II - */ -public class Material extends LWRComponent { - /** - *

- * The phase of this Material. Must be one of the enumeration values listed - * in MaterialType. - *

- * - */ - private MaterialType materialType; - - /** - *

- * The nullary Constructor. - *

- * - */ - public Material() { - - // Default Values - this.name = "Material"; - this.description = "Material's Description"; - this.id = 1; - - // Setup Default Material Type - this.materialType = MaterialType.SOLID; - - // Setup LWRComponentType to correct type - this.HDF5LWRTag = HDF5LWRTagType.MATERIAL; - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this Material. - *

- */ - public Material(String name) { - - // Call the nullary constructor - this(); - // Set the name with the LWRComponent's setName method. - this.setName(name); - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this Material. - *

- * @param materialType - *

- * The phase of this Material. Must be one of the enumeration - * values listed in MaterialType. - *

- */ - public Material(String name, MaterialType materialType) { - // Call the nullary constructor - this(); - // Set the name with the LWRComponent's setName method. - this.setName(name); - // Set the material type with the correct method - this.setMaterialType(materialType); - } - - /** - *

- * Sets the phase of this Material. Must be one of the enumeration values - * listed in MaterialType. - *

- * - * @param materialType - *

- * The phase of this Material. Must be one of the enumeration - * values listed in MaterialType. - *

- */ - public void setMaterialType(MaterialType materialType) { - - // If the material type is not null, set the type. - if (materialType != null) { - this.materialType = materialType; - } - - } - - /** - *

- * Returns the phase of this Material. Must be one of the enumeration values - * listed in MaterialType. - *

- * - * @return

- * The phase of this Material. Must be one of the enumeration values - * listed in MaterialType. - *

- */ - public MaterialType getMaterialType() { - - return this.materialType; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - Material material; - boolean retVal = false; - - // If they are equal to the same object, return true - if (this == otherObject) { - return true; - } - // If the otherObject is null or is not an instance of this object, - // return false - if (otherObject != null && otherObject instanceof Material) { - - // Cast object - material = (Material) otherObject; - - // Check values - retVal = (super.equals(otherObject) && this.materialType - .equals(material.materialType)); - - } - - // Return retVal - return retVal; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#hashCode() - */ - @Override - public int hashCode() { - - // Local Declarations - int hash = 31; - - // Hash values - hash += super.hashCode(); - hash += 31 * this.materialType.hashCode(); - - // return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(Material otherObject) { - - // If otherObject is null, return - if (otherObject == null) { - return; - } - // Copy contents - super.copy(otherObject); - this.materialType = otherObject.materialType; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#clone() - */ - @Override - public Object clone() { - // Local Delcarations - Material material = new Material(); - - // Copy contents - material.copy(this); - - // Return newly instantiated object - return material; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeStringAttribute(h5File, h5Group, - "materialType", materialType.toString()); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - MaterialType type1 = MaterialType.GAS; - MaterialType type = type1.toType((HdfReaderFactory.readStringAttribute( - h5Group, "materialType"))); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (type == null || !flag || h5Group == null) { - return false; - } - // If everything is valid, then set data - this.materialType = type; - - return true; - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/MaterialBlock.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/MaterialBlock.java deleted file mode 100644 index a0e1af7f6..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/MaterialBlock.java +++ /dev/null @@ -1,525 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.TreeSet; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfWriteable; - -/** - *

- * The MaterialBlock class is a generalized class containing a set of concentric - * and/or radial collection of Rings that constitute the inner core of an - * LWRRod. - *

- * - * @author Scott Forest Hull II - */ -public class MaterialBlock extends LWRComponent implements - Comparable { - /** - *

- * A TreeMap of Rings. - *

- * - */ - private TreeSet rings; - - /** - *

- * The position from the bottom of the rod. - *

- * - */ - private double pos; - - /** - *

- * The nullary Constructor. - *

- * - */ - public MaterialBlock() { - - // Call super constructor - super(); - // Create the TreeSet - this.rings = new TreeSet(); - - // Setup default values - this.name = "MaterialBlock 1"; - this.description = "MaterialBlock 1's Description"; - this.id = 1; - this.pos = 0; - - // Setup the LWRComponentType to correct Type - this.HDF5LWRTag = HDF5LWRTagType.MATERIALBLOCK; - - } - - /** - *

- * Adds a Ring to this MaterialBlock's ring collection. If the ring could - * not be successfully added, then false is returned. This could be due to a - * ring existing at within the inner and outer radius of an existing Ring - * object in the Slice. - *

- * - * @param ring - *

- * The ring to add to this MaterialBlock's Ring collection. - *

- * @return

- * True, if the Ring was successfully added. - *

- */ - public boolean addRing(Ring ring) { - - // Check for a null ring - if (ring == null) { - return false; - } - - // Get the Ring iterator - Iterator itr = this.rings.iterator(); - - // Loop over the iterator - while (itr.hasNext()) { - - // Get the next Ring - Ring currentRing = itr.next(); - - // Check if this ring overlaps the current ring from the iterator - if (currentRing.compareTo(ring) == 0) { - - // We found an overlapping ring. Do not add to the rings - // collection. - return false; - - } - - } - - // We could not locate an overlapping ring - // therefore add the new ring - rings.add(ring); - - return true; - } - - /** - *

- * Returns the Ring located at the provided radius value or null if one - * could not be found. - *

- * - * @param radius - *

- * A radius value. - *

- * @return

- * The Ring located at the provided radius value or null if one - * could not be found. - *

- */ - public Ring getRing(double radius) { - - // Get the Ring iterator from the rings TreeSet - Iterator itr = rings.iterator(); - - // Cycle through the iterator - while (itr.hasNext()) { - - // Get the next ring - Ring ring = itr.next(); - - // Check if the provided radius is equal to or - // between this ring's inner and outer radius. - // We are looking for the first Ring in rings - // which qualifies these constraints. - if (ring.getInnerRadius() <= radius - && ring.getOuterRadius() >= radius) { - - // Return the ring - return ring; - - } - - } - - return null; - } - - /** - *

- * Returns the Ring with the provided name or null if one could not be - * found. - *

- * - * @param ringName - *

- * A Ring name. - *

- * @return

- * The Ring with the provided name or null if one could not be - * found. - *

- */ - public Ring getRing(String ringName) { - - // if the ringName is not null, return the name - if (ringName != null) { - - // Get the Ring iterator - Iterator itr = this.rings.iterator(); - - // Loop over the iterator - while (itr.hasNext()) { - - // Get the next Ring - Ring ring = itr.next(); - - // If the Ring's name matches the provided name - if (ring.getName().equals(ringName)) { - - // Return the Ring - return ring; - - } - } - } - - // Name was null or not found in the rings TreeSet - return null; - } - - /** - *

- * Returns an ArrayList of Rings ordered by ascending radii. - *

- * - * @return

- * An ArrayList of Rings ordered by ascending radii. - *

- */ - public ArrayList getRings() { - - // Create the ArrayList - ArrayList list = new ArrayList(); - - // Add all of the elements from the TreeSet to the ArrayList - list.addAll(rings); - - // Return the ArrayList - return list; - } - - /** - *

- * Removes the Ring from this MaterialBlock's ring collection that has the - * provided name. Returns true, if the Ring was successfully removed. - *

- * - * @param ringName - *

- * The name of the Ring to remove. - *

- * @return

- * True, if the Ring was successfully removed from this - * MaterialBlock's Ring collection. - *

- */ - public boolean removeRing(String ringName) { - - // if the ringName is not null, return the name - if (ringName != null) { - - // Get the Ring iterator - Iterator itr = this.rings.iterator(); - - // Loop over the iterator - while (itr.hasNext()) { - - // Get the next Ring - Ring ring = itr.next(); - - // If the Ring's name matches the provided name - if (ring.getName().equals(ringName)) { - - // Remove the Ring - this.rings.remove(ring); - - return true; - - } - } - } - - // Name was null or not found in the rings TreeSet - return false; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - MaterialBlock materialBlock; - boolean retVal = false; - - // If they are equal to the same object, return true - if (this == otherObject) { - return true; - } - // If the otherObject is null or not an instance of the current object, - // return false - if (otherObject != null && otherObject instanceof MaterialBlock) { - - // Cast - materialBlock = (MaterialBlock) otherObject; - - // Check values - retVal = super.equals(otherObject) - && this.rings.equals(materialBlock.rings) - && this.pos == materialBlock.pos; - - } - - // Return retVal - return retVal; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#hashCode() - */ - @Override - public int hashCode() { - - // Local Declarations - int hash = super.hashCode(); - - // Hash local values - hash += 31 * this.rings.hashCode(); - hash += 31 * this.pos; - - // Return hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(MaterialBlock otherObject) { - - // Local Declarations - Iterator iter; - - // if otherObject is null, return - if (otherObject == null) { - return; - } - // copy contents - super - super.copy(otherObject); - - this.pos = otherObject.pos; - - // Copy local contents - // Deep Copy the Tree's contents - this.rings.clear(); - iter = otherObject.rings.iterator(); - - // Iterate over the list and clone each Ring - while (iter.hasNext()) { - Ring key = iter.next(); - this.rings.add((Ring) key.clone()); - - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#clone() - */ - @Override - public Object clone() { - - // Local Declarations - MaterialBlock materialBlock = new MaterialBlock(); - - // Copy contents - materialBlock.copy(this); - - // Return newly instantiated object - return materialBlock; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#getWriteableChildren() - */ - @Override - public ArrayList getWriteableChildren() { - - // Get the children in super - ArrayList children = super.getWriteableChildren(); - - // If super had no children - if (children == null) { - - // Initialize to new array list - children = new ArrayList(); - } - - // Add all of the Rings to the children array list - children.addAll(rings); - - return children; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readChild(org.eclipse.ice.io.hdf.IHdfReadable) - */ - @Override - public boolean readChild(IHdfReadable iHdfReadable) { - - if (iHdfReadable == null || !(iHdfReadable instanceof LWRComponent)) { - return false; - } - - // Cast the child into a LWRComponent - LWRComponent childComponent = (LWRComponent) iHdfReadable; - - // If this is ring - if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.RING) { - - // Ass to the collection of Rings - this.addRing((Ring) childComponent); - - } - - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeDoubleAttribute(h5File, h5Group, - "position", this.pos); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - Double position = HdfReaderFactory.readDoubleAttribute(h5Group, - "position"); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (position == null || !flag || h5Group == null) { - return false; - } - // If everything is valid, then set data - this.pos = position.doubleValue(); - - return true; - } - - /** - *

- * Sets the position. - *

- * - * @param pos - *

- * the position to set - *

- */ - public void setPosition(double pos) { - if (pos >= 0.0) { - this.pos = pos; - } - } - - /** - *

- * Gets the position - *

- * - * @return

- * The position set. - *

- */ - public double getPosition() { - return this.pos; - } - - /* - * (non-Javadoc) - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(MaterialBlock arg0) { - - if (this.pos < arg0.pos) { - return -1; - } else if (this.pos > arg0.pos) { - return 1; - } else { - return 0; - } - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/MaterialType.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/MaterialType.java deleted file mode 100644 index 77fcd5ae9..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/MaterialType.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -/** - *

The MaterialType enumeration describes each type of material phase.

- * @author Scott Forest Hull II - */ -public enum MaterialType { - /** - *

This literal indicates a gas material phase.

- */ - GAS("Gas"), - /** - *

This literal indicates a liquid material phase.

- */ - LIQUID("Liquid"), - /** - *

This literal indicates a solid material phase.

- */ - SOLID("Solid"); - - /** - *

Human readable string associated with enumerated value.

- */ - private String name; - - /** - *

The constructor.

- * @param name - */ - MaterialType(String name) { - - this.name = name; - - } - - /** - *

Returns the type of enumeration keyed on name. Returns null if invalid name.

- * @param name

The name associated with the enumerated value.

- * @return

The type of enumeration.

- */ - public MaterialType toType(String name) { - - //Cycle over all types - for (MaterialType p : values()) { - - //If this property's name equals name - if (p.name.equals(name)) { - - //Return the property - return p; - } - } - - //If not found return null - return null; - - } - - /** - *

Returns the string name of the enumerated value.

- * @return

The name of the enumerated value.

- */ - @Override - public String toString() { - - return name; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/Ring.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/Ring.java deleted file mode 100644 index 7d012f83c..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/Ring.java +++ /dev/null @@ -1,565 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import java.util.ArrayList; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfWriteable; - -/** - *

- * The ring class represents a single instance of a material at a particular - * radial coordinate within a cylindrical location on the rod. The height - * variable on this class should uniformly represent the height from the bottom - * of the MaterialBlock (or Z coordinate displacement) to help compensate for - * varying types of materials across a cylindrical segment of a rod. - *

- * - * @author Scott Forest Hull II - */ -public class Ring extends LWRComponent implements Comparable { - /** - *

- * The height of this Ring, which must be greater than zero. - *

- * - */ - protected double height; - /** - *

- * The inner radius of this Ring, which must be greater than or equal to - * zero and less than the outer radius. - *

- * - */ - protected double innerRadius; - /** - *

- * The outer radius of this Ring, which must be greater than the innerRadius - * value and greater than 0. - *

- * - */ - protected double outerRadius; - /** - *

- * The Material for this Ring. - *

- * - */ - protected Material material; - - /** - *

- * The nullary Constructor. - *

- * - */ - public Ring() { - - // Set default LWRComponent values - this.name = "Ring"; - this.description = "Ring's Description"; - this.id = 1; - - // Set default values for other pieces - this.height = 1.0; - this.outerRadius = 1.0; - this.innerRadius = 0.0; - this.material = new Material(); - - // Setup the LWRComponentType to correct type - this.HDF5LWRTag = HDF5LWRTagType.RING; - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this Ring. - *

- */ - public Ring(String name) { - // Call nullary constructor - this(); - - // Pass values to operations - this.setName(name); - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this Ring. - *

- * @param material - *

- * The Material for this Ring. - *

- * @param height - *

- * The height of this Ring, which must be greater than zero. - *

- * @param outerRadius - *

- * The outer radius of this Ring, which must be greater than the - * innerRadius value. - *

- */ - public Ring(String name, Material material, double height, - double outerRadius) { - // Call nullary constructor - this(); - - // Pass values to operations - this.setName(name); - this.setMaterial(material); - this.setHeight(height); - this.setOuterRadius(outerRadius); - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this Ring. - *

- * @param material - *

- * The Material for this Ring. - *

- * @param height - *

- * The height of this Ring, which must be greater than zero. - *

- * @param innerRadius - *

- * The inner radius of this Ring, which must be greater than or - * equal to zero. - *

- * @param outerRadius - *

- * The outer radius of this Ring, which must be greater than the - * innerRadius value. - *

- */ - public Ring(String name, Material material, double height, - double innerRadius, double outerRadius) { - // Call lower level nullary constructor - this(name, material, height, outerRadius); - - // Set other values - this.setInnerRadius(innerRadius); - - } - - /** - *

- * Returns the height of this Ring. - *

- * - * @return

- * The height of this Ring. - *

- */ - public double getHeight() { - return this.height; - } - - /** - *

- * Sets the height of this Ring, which must be greater than zero. - *

- * - * @param height - *

- * The height of this Ring, which must be greater than zero. - *

- */ - public void setHeight(double height) { - - // If the height is not less than zero, valid - if (height > 0.0) { - this.height = height; - } - - } - - /** - *

- * Returns the inner radius of this Ring. - *

- * - * @return

- * The inner radius of this Ring. - *

- */ - public double getInnerRadius() { - return this.innerRadius; - - } - - /** - *

- * Sets the inner radius of this Ring, which must be greater than or equal - * to zero and less than the outer radius. - *

- * - * @param innerRadius - *

- * The inner radius of this Ring, which must be greater than or - * equal to zero. - *

- */ - public void setInnerRadius(double innerRadius) { - - // If the inner Radius is greater than or equal to 0 AND it is less than - // current outer radius - if (innerRadius >= 0.0 && innerRadius < this.outerRadius) { - this.innerRadius = innerRadius; - } - - } - - /** - *

- * Returns the outer radius for this Ring. Must be greater than 0 and the - * inner radius. - *

- * - * @return

- * The outer radius for this Ring - *

- */ - public double getOuterRadius() { - - return this.outerRadius; - } - - /** - *

- * Sets the outer radius of this Ring, which must be greater than the - * innerRadius value. - *

- * - * @param outerRadius - *

- * The outer radius of this Ring, which must be greater than the - * innerRadius value. - *

- */ - public void setOuterRadius(double outerRadius) { - - // If the outer Radius is greater than 0 AND it is greater than current - // inner radius - if (outerRadius > 0 && outerRadius > this.innerRadius) { - this.outerRadius = outerRadius; - } - - } - - /** - *

- * Returns the Material for this ring. - *

- * - * @return

- * The Material for this Ring. - *

- */ - public Material getMaterial() { - return this.material; - } - - /** - *

- * Sets the material. Can not set to null. - *

- * - * @param material - *

- * The Material for this Ring. - *

- */ - public void setMaterial(Material material) { - - // If the material is not null - if (material != null) { - this.material = material; - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - Ring ring; - boolean retVal = false; - - // If this object is the same on the heap, return true - - if (this == otherObject) { - return true; - } - // If the otherObject is null or not an instance of this object, return - // false - if (otherObject != null && otherObject instanceof Ring) { - - // Cast - ring = (Ring) otherObject; - - // Check values - retVal = (super.equals(otherObject) && this.height == ring.height - && this.innerRadius == ring.innerRadius - && this.outerRadius == ring.outerRadius && this.material - .equals(ring.material)); - - } - - // Return the retVal - return retVal; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#hashCode() - */ - @Override - public int hashCode() { - - // Local Declarations - int hash = 31; - - // Get super's hash - hash += super.hashCode(); - - // Get hash from local attributes - hash += 31 * this.height; - hash += 31 * this.innerRadius; - hash += 31 * this.outerRadius; - hash += 31 * this.material.hashCode(); - - // Return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(Ring otherObject) { - - // If the otherObject is null, return - if (otherObject == null) { - return; - } - // Copy values - super - super.copy(otherObject); - - // Copy local values - this.height = otherObject.height; - this.innerRadius = otherObject.innerRadius; - this.outerRadius = otherObject.outerRadius; - - // Deep copy Material - this.material = (Material) otherObject.material.clone(); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#clone() - */ - @Override - public Object clone() { - - // Local Declarations - Ring ring = new Ring(); - - // Copy contents - ring.copy(this); - - // Return newly instantiated object - return ring; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeDoubleAttribute(h5File, h5Group, - "height", height); - flag &= HdfWriterFactory.writeDoubleAttribute(h5File, h5Group, - "innerRadius", innerRadius); - flag &= HdfWriterFactory.writeDoubleAttribute(h5File, h5Group, - "outerRadius", outerRadius); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#getWriteableChildren() - */ - @Override - public ArrayList getWriteableChildren() { - - // Get the children in super - ArrayList children = super.getWriteableChildren(); - - // If super had no children - if (children == null) { - - // Initialize to new array list - children = new ArrayList(); - } - - // Add the material to children - children.add(this.material); - - return children; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - Double height = HdfReaderFactory.readDoubleAttribute(h5Group, "height"); - Double innerRadius = HdfReaderFactory.readDoubleAttribute(h5Group, - "innerRadius"); - Double outerRadius = HdfReaderFactory.readDoubleAttribute(h5Group, - "outerRadius"); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (height == null || innerRadius == null || outerRadius == null - || !flag || h5Group == null) { - return false; - } - // If everything is valid, then set data - this.height = height.doubleValue(); - this.innerRadius = innerRadius.doubleValue(); - this.outerRadius = outerRadius.doubleValue(); - - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readChild(org.eclipse.ice.io.hdf.IHdfReadable) - */ - @Override - public boolean readChild(IHdfReadable iHdfReadable) { - - if (iHdfReadable == null || !(iHdfReadable instanceof LWRComponent)) { - return false; - } - - // Cast the child into a LWRComponent - LWRComponent childComponent = (LWRComponent) iHdfReadable; - - // If this is a material - if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.MATERIAL) { - - // Assign to correct object - this.material = (Material) childComponent; - - } - - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#accept(org.eclipse.ice.reactor.ILWRComponentVisitor) - */ - @Override - public void accept(ILWRComponentVisitor visitor) { - visitor.visit(this); - } - - /* - * (non-Javadoc) - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(Ring ring) { - // Create some constants - final int BEFORE = -1; - final int EQUAL = 0; - final int AFTER = 1; - - // Check if this ring's outer radius is less than or equal to that - // ring's inner radius - if (this.getOuterRadius() <= ring.getInnerRadius()) { - return BEFORE; - } - - // Check if this ring's inner radius is less than or equal to that - // ring's outer radius - if (this.getInnerRadius() >= ring.getOuterRadius()) { - return AFTER; - } - - // Otherwise return equal which means in this context that the rings - // overlap - return EQUAL; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/Tube.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/Tube.java deleted file mode 100644 index 18a2a052c..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/Tube.java +++ /dev/null @@ -1,359 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; - -/** - *

- * The Tube class represents the hollow tubes in a FuelAssembly which allow for - * the insertion of discrete poison rodlets (Guide Tubes) and instrument - * thimbles (Instrument Tube). - *

- * - * @author Scott Forest Hull II - */ -public class Tube extends Ring { - /** - *

- * One of the TubeType enumeration values. - *

- * - */ - private TubeType tubeType; - - /** - *

- * The nullary Constructor. - *

- * - */ - public Tube() { - // Call super constructor - sets up defaults - super(); - - // Set name and description for tube - this.name = "Tube"; - this.description = "Tube's Description"; - - // Setup other attributes for tube - this.tubeType = TubeType.GUIDE; - - // Setup the LWRComponentType to the correct type - this.HDF5LWRTag = HDF5LWRTagType.TUBE; - - } - - /** - *

- * The parameterized Constructor. - *

- * - * @param name - *

- * The name of this Tube. - *

- */ - public Tube(String name) { - // Call nullary constructor - this(); - - // Set the name - this.setName(name); - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this Tube. - *

- * @param tubeType - *

- * The TubeType enumeration value for this Tube. - *

- */ - public Tube(String name, TubeType tubeType) { - - // Call non-nullary constructor - this(name); - - // Call extra operations - this.setTubeType(tubeType); - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this Tube. - *

- * @param tubeType - *

- * The TubeType enumeration value for this Tube. - *

- * @param material - *

- * The Material for this Tube. - *

- * @param height - *

- * The height of this Tube, which must be greater than zero. - *

- * @param outerRadius - *

- * The outer radius of this Tube, which must be greater than the - * innerRadius value. - *

- */ - public Tube(String name, TubeType tubeType, Material material, - double height, double outerRadius) { - // Call non-nullary constructor - this(name, tubeType); - - // Set other values - super.setMaterial(material); - super.setHeight(height); - super.setOuterRadius(outerRadius); - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this Tube. - *

- * @param tubeType - *

- * The TubeType enumeration value for this Tube. - *

- * @param material - *

- * The Material for this Tube. - *

- * @param height - *

- * The height of this Tube, which must be greater than zero. - *

- * @param innerRadius - *

- * The inner radius of this Tube, which must be greater than or - * equal to zero. - *

- * @param outerRadius - *

- * The outer radius of this Tube, which must be greater than the - * innerRadius value. - *

- */ - public Tube(String name, TubeType tubeType, Material material, - double height, double innerRadius, double outerRadius) { - // Call non-nullary constructor - this(name, tubeType, material, height, outerRadius); - - // Set other values - this.setInnerRadius(innerRadius); - - } - - /** - *

- * Returns the TubeType enumeration value for this Tube. - *

- * - * @return

- * The TubeType enumeration value for this Tube. - *

- */ - public TubeType getTubeType() { - - return this.tubeType; - } - - /** - *

- * Sets the TubeType enumeration value for this Tube. Can not set to null. - *

- * - * @param tubeType - *

- * The TubeType enumeration value for this Tube. - *

- */ - public void setTubeType(TubeType tubeType) { - - // If tube type is not null - if (tubeType != null) { - this.tubeType = tubeType; - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.Ring#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - Tube tube; - boolean retVal = false; - - // If they are equal to the same object, return true - if (this == otherObject) { - return true; - } - if (otherObject != null && otherObject instanceof Tube) { - - // Cast - tube = (Tube) otherObject; - - // Check values - retVal = super.equals(otherObject) - && this.tubeType.equals(tube.tubeType); - } - - // Return retVal - return retVal; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.Ring#hashCode() - */ - @Override - public int hashCode() { - - // Get hash from super - int hash = super.hashCode(); - - // Get local hash - hash += 31 * this.tubeType.hashCode(); - - // Return the hashCode - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(Tube otherObject) { - - // If the otherObject is null, return - if (otherObject == null) { - return; - } - // Copy contents - super - super.copy(otherObject); - - // copy local contents - this.tubeType = otherObject.tubeType; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.Ring#clone() - */ - @Override - public Object clone() { - // Local Declarations - Tube tube = new Tube(); - - // Copy contents - tube.copy(this); - - // Return newly instantiated object - return tube; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.Ring#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeStringAttribute(h5File, h5Group, - "tubeType", tubeType.toString()); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.Ring#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - TubeType type1 = TubeType.GUIDE; - TubeType type = type1.toType((HdfReaderFactory.readStringAttribute( - h5Group, "tubeType"))); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (type == null || !flag || h5Group == null) { - return false; - } - // If everything is valid, then set data - this.tubeType = type; - - return true; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.Ring#accept(org.eclipse.ice.reactor.ILWRComponentVisitor) - */ - @Override - public void accept(ILWRComponentVisitor visitor) { - visitor.visit(this); - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/TubeType.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/TubeType.java deleted file mode 100644 index b9929acab..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/TubeType.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor; - -/** - *

- * The TubeType enumeration describes the types of Tubes that can be created. - *

- * - * @author Scott Forest Hull II - */ -public enum TubeType { - /** - *

- * This literal indicates a guide tube. - *

- * - */ - GUIDE("Guide"), - /** - *

- * This literal indicates an instrument tube. - *

- * - */ - INSTRUMENT("Instrument"); - - /** - *

- * Human readable string associated with enumerated value. - *

- * - */ - private String name; - - /** - *

- * The constructor. - *

- * - * @param name - *

- * The name of the enumeration value. - *

- */ - TubeType(String name) { - - this.name = name; - - } - - /** - *

- * Returns the type of enumeration keyed on name. Returns null if invalid - * name. - *

- * - * @param name - *

- * The name associated with the enumerated value. - *

- * @return

- * The type of enumeration. - *

- */ - public TubeType toType(String name) { - - // Cycle over all types - for (TubeType p : values()) { - - // If this property's name equals name - if (p.name.equals(name)) { - - // Return the property - return p; - } - } - - // If not found return null - return null; - - } - - /** - *

- * Returns the string name of the enumerated value. - *

- * - * @return

- * The name of the enumerated value. - *

- */ - @Override - public String toString() { - - return this.name; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/bwr/BWReactor.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/bwr/BWReactor.java deleted file mode 100644 index 108f00c4f..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/bwr/BWReactor.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.bwr; - -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.ILWRComponentVisitor; -import org.eclipse.ice.reactor.LWReactor; - -/** - *

- * The BWReactor class represents any Boiling Water Reactor. - *

- * - * @author Scott Forest Hull II - */ -public class BWReactor extends LWReactor { - - /** - *

- * The constructor. - *

- * - * @param size - *

- * The size of the reactor. - *

- */ - public BWReactor(int size) { - - // Call super constructor - super(size); - - // Setup default attributes - this.name = "BWReactor 1"; - this.description = "BWReactor 1's Description"; - this.HDF5LWRTag = HDF5LWRTagType.BWREACTOR; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWReactor#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // No attributes to compare. Call super - return super.equals(otherObject); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWReactor#hashCode() - */ - @Override - public int hashCode() { - - // No attributes to compare. Call super - return super.hashCode(); - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(BWReactor otherObject) { - - // Call super - super.copy(otherObject); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWReactor#clone() - */ - @Override - public Object clone() { - - // Local Declarations - BWReactor reactor = new BWReactor(0); - - // Copy Contents - reactor.copy(this); - - // Return newly instantiated object - return reactor; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#accept(org.eclipse.ice.reactor.ILWRComponentVisitor) - */ - @Override - public void accept(ILWRComponentVisitor visitor) { - visitor.visit(this); - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/ControlBank.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/ControlBank.java deleted file mode 100644 index 2d4f905fb..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/ControlBank.java +++ /dev/null @@ -1,320 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.pwr; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.ILWRComponentVisitor; -import org.eclipse.ice.reactor.LWRComponent; - -/** - *

- * The ControlBank class contains properties associated with axially movable - * RodClusterAssembly objects known as Rod Cluster Control Assemblies. A Bank is - * a group of RCCA's that are positioned simultaneously by the plant operations. - * A Bank may have 8 individual RCCAs, for instance, located symmetrically - * around the core. For a core with 50+ RCCAs, usually only 8 or so banks are - * controlled independently. - *

- * - * @author Scott Forest Hull II - */ -public class ControlBank extends LWRComponent { - /** - *

- * The distance between an axial step. - *

- * - */ - private double stepSize; - /** - *

- * The maximum number of axial steps. - *

- * - */ - private int maxNumberOfSteps; - - /** - *

- * The nullary Constructor. - *

- * - */ - public ControlBank() { - this.setMaxNumberOfSteps(1); - this.setStepSize(0.0); - this.setName("ControlBank 1"); - this.setDescription("Default Control Bank"); - this.setId(1); - this.HDF5LWRTag = HDF5LWRTagType.CONTROL_BANK; - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - * The name of the component. - * @param stepSize - *

- * The distance between an axial step. - *

- * @param maxNumberOfSteps - *

- * The maximum number of axial steps. - *

- */ - public ControlBank(String name, double stepSize, int maxNumberOfSteps) { - this(); - this.setStepSize(stepSize); - this.setMaxNumberOfSteps(maxNumberOfSteps); - this.setName(name); - } - - /** - *

- * Sets the axial step size. - *

- * - * @param stepSize - *

- * The axial step size. - *

- */ - public void setStepSize(double stepSize) { - if (stepSize > 0.0) { - this.stepSize = stepSize; - } else { - this.stepSize = 0.0; - } - } - - /** - *

- * Sets the maximum number of axial steps. - *

- * - * @param maxNumberOfSteps - *

- * The maximum number of axial steps. - *

- */ - public void setMaxNumberOfSteps(int maxNumberOfSteps) { - if (maxNumberOfSteps > 0) { - this.maxNumberOfSteps = maxNumberOfSteps; - } else { - this.maxNumberOfSteps = 1; - } - } - - /** - *

- * Returns the maximum number of axial steps. - *

- * - * @return

- * The maximum number of axial steps. - *

- */ - public int getMaxNumberOfSteps() { - return this.maxNumberOfSteps; - } - - /** - *

- * Returns the axial step size. - *

- * - * @return

- * The axial step size. - *

- */ - public double getStepSize() { - return this.stepSize; - } - - /** - *

- * Calculates and returns the stroke length, which is the axial step size - * multiplied by the maximum number of axial steps. - *

- * - * @return

- * The axial step size multiplied by the maximum number of axial - * steps. - *

- */ - public double getStrokeLength() { - - return (this.maxNumberOfSteps) * this.stepSize; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeDoubleAttribute(h5File, h5Group, - "stepSize", stepSize); - flag &= HdfWriterFactory.writeIntegerAttribute(h5File, h5Group, - "maxNumberOfSteps", maxNumberOfSteps); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - boolean retVal = false; - ControlBank bank; - - // If they are the same on the heap, return true - if (otherObject == this) { - return true; - } - - // Make sure the otherObject is not null and an instance of this object - if (otherObject != null && otherObject instanceof ControlBank) { - - // Cast it - bank = (ControlBank) otherObject; - - // Compare values - retVal = (super.equals(otherObject) - && this.maxNumberOfSteps == bank.maxNumberOfSteps && this.stepSize == bank.stepSize); - } - - // Return retVal - return retVal; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#hashCode() - */ - @Override - public int hashCode() { - - // Local Declarations - int hash = super.hashCode(); - - hash += 31 * this.maxNumberOfSteps; - hash += 31 * this.stepSize; - - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(ControlBank otherObject) { - - // If otherObject is null, return - if (otherObject == null) { - return; - } - - // Copy contents - super - super.copy(otherObject); - - // Copy local contents - this.maxNumberOfSteps = otherObject.maxNumberOfSteps; - this.stepSize = otherObject.stepSize; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#clone() - */ - @Override - public Object clone() { - - // Local Declarations - ControlBank bank = new ControlBank(); - - // Copy contents - bank.copy(this); - - // Return newly instantiated object - return bank; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - Double stepSize = HdfReaderFactory.readDoubleAttribute(h5Group, - "stepSize"); - Integer maxNumberOfSteps = HdfReaderFactory.readIntegerAttribute( - h5Group, "maxNumberOfSteps"); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (stepSize == null || maxNumberOfSteps == null || !flag - || h5Group == null) { - return false; - } - - // If everything is valid, then set data - this.stepSize = stepSize.doubleValue(); - this.maxNumberOfSteps = maxNumberOfSteps.intValue(); - - return true; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#accept(org.eclipse.ice.reactor.ILWRComponentVisitor) - */ - @Override - public void accept(ILWRComponentVisitor visitor) { - visitor.visit(this); - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/FuelAssembly.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/FuelAssembly.java deleted file mode 100644 index 2ecf76817..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/FuelAssembly.java +++ /dev/null @@ -1,720 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.pwr; - -import java.util.ArrayList; - -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfWriteable; -import org.eclipse.ice.reactor.GridLabelProvider; -import org.eclipse.ice.reactor.GridLocation; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.ILWRComponentVisitor; -import org.eclipse.ice.reactor.LWRComponent; -import org.eclipse.ice.reactor.LWRComposite; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.eclipse.ice.reactor.LWRGridManager; -import org.eclipse.ice.reactor.Tube; - -/** - *

- * The FuelAssembly class is a PWRAssembly populated with a collection of Tubes - * positioned on a fixed grid. When the addTube() operation is used, if a Tube - * with the same name exists in the collection, then the Tube will not be added - * and a value of false will be returned. When using the setTubeLocation() - * operation, if a Tube with the same name exists at the provided location, then - * the current Tube name at the provided location will be overwritten. - *

- *

- * StatePointData for Tubes should be stored by position and accessed by the - * getTubeDataProviderAtLocation operation. - *

- * - * @author Scott Forest Hull II - */ -public class FuelAssembly extends PWRAssembly { - /** - *

- * The RodClusterAssembly associated with this FuelAssembly. - *

- * - */ - private RodClusterAssembly rodClusterAssembly; - /** - *

- * A LWRComposite for Tubes. - *

- * - */ - private LWRComposite tubeComposite; - /** - * - */ - private LWRGridManager tubeGridManager; - /** - *

- * The GridLabelProvider for this FuelAssembly. - *

- * - */ - private GridLabelProvider gridLabelProvider; - - private static final String TUBE_COMPOSITE_NAME = "Tubes"; - private static final String TUBE_GRID_MANAGER_NAME = "Tube Grid"; - private static final String GRID_LABEL_PROVIDER_NAME = "Grid Labels"; - - /** - *

- * A parameterized Constructor. - *

- * - * @param size - *

- * The size of either dimension of the location grid. - *

- */ - public FuelAssembly(int size) { - - // Call super constructor - super(size); - - // Set defaults for FuelAssembly - this.name = "FuelAssembly"; - this.description = "FuelAssembly's Description"; - this.id = 1; - - // Setup rows and cols - this.gridLabelProvider = new GridLabelProvider(this.size); - this.gridLabelProvider.setName(FuelAssembly.GRID_LABEL_PROVIDER_NAME); - - // Setup tube map - this.tubeComposite = new LWRComposite(); - this.tubeComposite.setName(FuelAssembly.TUBE_COMPOSITE_NAME); - this.tubeComposite - .setDescription("A Composite that contains many Tubes."); - this.tubeComposite.setId(2); - - // Setup tube grid manager - this.tubeGridManager = new LWRGridManager(this.size); - this.tubeGridManager.setName(FuelAssembly.TUBE_GRID_MANAGER_NAME); - - // Add tubeComposite to components - - // this has to be added manually - this.lWRComponents - .put(this.tubeComposite.getName(), this.tubeComposite); - - // Setup the LWRComponentType to correct type - this.HDF5LWRTag = HDF5LWRTagType.FUEL_ASSEMBLY; - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this FuelAssembly. - *

- * @param size - *

- * The size of either dimension of the location grid. - *

- */ - public FuelAssembly(String name, int size) { - - // Call this constructor - this(size); - - // Setup name - this.setName(name); - } - - /** - *

- * Returns the RodClusterAssembly associated with this FuelAssembly or null - * if one has not been set. - *

- * - * @return

- * The RodClusterAssembly associated with this FuelAssembly or null - * if one has not been set. - *

- */ - public RodClusterAssembly getRodClusterAssembly() { - return this.rodClusterAssembly; - } - - /** - *

- * Sets the RodClusterAssembly associated with this FuelAssembly. - *

- * - * @param rodClusterAssembly - *

- * The RodClusterAssembly associated with this FuelAssembly. - *

- */ - public void setRodClusterAssembly(RodClusterAssembly rodClusterAssembly) { - - // RodClusterAssembly can be null - this.rodClusterAssembly = rodClusterAssembly; - - } - - /** - *

- * Adds a Tube to the collection of Tubes. If a Tube with the same name - * exists in the collection or if the passed tube is null, then the Tube - * will not be added and a value of false will be returned. - *

- * - * @param tube - *

- * The Tube to add to the collection of Tubes. - *

- * @return

- * True, if the Tube was added successfully. - *

- */ - public boolean addTube(Tube tube) { - - // Add the component to the composite - this.tubeComposite.addComponent(tube); - - // If the component is not contained, return false - if (!this.tubeComposite.getComponents().contains(tube)) { - return false; - } - - // The component was added to the composite, return true! - return true; - } - - /** - *

- * Removes a Tube from the collection of Tubes. Returns false if the - * tubeName does not exist or if the string passed is null. - *

- * - * @param tubeName - *

- * The name of the Tube to be removed. - *

- * @return

- * True, if the Tube was removed successfully. - *

- */ - public boolean removeTube(String tubeName) { - - // If the name does not exist, return - if (this.tubeComposite.getComponent(tubeName) == null) { - return false; - } - - // Remove it from the grid as well - this.tubeGridManager.removeComponent(this.tubeComposite - .getComponent(tubeName)); - - // Remove the component from the composite with the given name - this.tubeComposite.removeComponent(tubeName); - - // Remove it from the grid as well - this.tubeGridManager.removeComponent(this.tubeComposite - .getComponent(tubeName)); - - // If name does not exist, return true. Else false - if (this.tubeComposite.getComponent(tubeName) != null) { - return false; - } - - // The component was deleted from the composite, return true! - return true; - - } - - /** - *

- * Removes the Tube at the provided location. Returns true if the removal - * was successful. - *

- * - * @param row - *

- * The row position. - *

- * @param column - *

- * The column position. - *

- * @return

- * True, if the Tube removal was successful. - *

- */ - public boolean removeTubeFromLocation(int row, int column) { - // Local Declarations - GridLocation location = new GridLocation(row, column); - - // If the rows and columns dont match the location, return false - if (location.getColumn() != column || location.getRow() != row) { - return false; - } - // Check to make sure that a name exists there. - if (this.tubeGridManager.getComponentName(location) == null) { - return false; - } - - // Remove the component from the location - this.tubeGridManager.removeComponent(location); - - // If the composite at that location is null, then return true - if (this.tubeGridManager.getComponentName(location) == null) { - return true; - } - - // Nothing was changed, return false - return false; - - } - - /** - *

- * Returns an ArrayList of names for each element of the collection of - * Tubes. - *

- * - * @return

- * An ArrayList of names for each element of the collection of - * Tubes. - *

- */ - public ArrayList getTubeNames() { - // Return the Component's names - return this.tubeComposite.getComponentNames(); - } - - /** - *

- * Returns the Tube corresponding to the provided name or null if the name - * is not found. - *

- * - * @param name - *

- * The provided Tube's name. - *

- * @return

- * The Tube corresponding to the provided name or null if the name - * is not found. - *

- */ - public Tube getTubeByName(String name) { - return (Tube) this.tubeComposite.getComponent(name); - } - - /** - *

- * Returns the Tube corresponding to the provided column and row or null if - * one is not found at the provided location. - *

- * - * @param row - *

- * The row position. - *

- * @param column - *

- * The column position. - *

- * @return

- * The Tube corresponding to the provided column and row or null if - * one is not found at the provided location. - *

- */ - public Tube getTubeByLocation(int row, int column) { - String name = ""; - - // Get the component name - name = this.tubeGridManager.getComponentName(new GridLocation(row, - column)); - - // Return the component by name - return this.getTubeByName(name); - } - - /** - *

- * Returns the number of Tubes in the collection of Tubes. - *

- * - * @return

- * The number of Tubes. - *

- */ - public int getNumberOfTubes() { - // Return the number of components - return this.tubeComposite.getNumberOfComponents(); - } - - /** - *

- * Sets the location for the provided name. Overrides the location of - * another component name as required. Returns true if this operation was - * successful, false otherwise. Note it will return true if the same name is - * overridden. - *

- * - * @param tubeName - *

- * The Tube's name. - *

- * @param row - *

- * The row position. - *

- * @param column - *

- * The column position. - *

- * @return

- * True, if the location of the LWRRod was set successfully. - *

- */ - public boolean setTubeLocation(String tubeName, int row, int column) { - - // Local declarations - GridLocation location = new GridLocation(row, column); - - // If the rows and columns dont match the location, return false - if (location.getColumn() != column || location.getRow() != row) { - return false; - } - - // Set the location - this.tubeGridManager - .addComponent( - this.tubeComposite.getComponent(tubeName), - location); - - // If the name changed, then return true - if (this.tubeGridManager.getComponentName(location) != null - && this.tubeGridManager.getComponentName(location).equals( - tubeName)) { - return true; - } - - // Otherwise, name did not change - return false; - - } - - /** - *

- * Returns the GridLabelProvider for this FuelAssembly. - *

- * - * @return

- * The GridLabelProvider for this FuelAssembly. - *

- */ - public GridLabelProvider getGridLabelProvider() { - - return this.gridLabelProvider; - } - - /** - *

- * Sets the GridLabelProvider for this FuelAssembly. Can not be set to null. - *

- * - * @param gridLabelProvider - *

- * The GridLabelProvider for this FuelAssembly. - *

- */ - public void setGridLabelProvider(GridLabelProvider gridLabelProvider) { - - // If the GridLabelProvider passed is not null and of the same size. - if (gridLabelProvider != null - && gridLabelProvider.getSize() == this.size) { - this.gridLabelProvider = gridLabelProvider; - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.pwr.PWRAssembly#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - FuelAssembly assembly; - boolean retVal = false; - - // If they are equal to the same place on the heap, return true - if (otherObject == this) { - return true; - } - - // If the otherObject is null or not an instanceof this object, return - // false - if (otherObject != null && otherObject instanceof FuelAssembly) { - - // Cast it - assembly = (FuelAssembly) otherObject; - - // Compare values - retVal = super.equals(otherObject) - && this.gridLabelProvider - .equals(assembly.gridLabelProvider) - && this.tubeComposite.equals(assembly.tubeComposite) - && this.tubeGridManager.equals(assembly.tubeGridManager); - - // RodClusterAssembly can be null: - if (this.rodClusterAssembly == null) { - retVal = retVal - && this.rodClusterAssembly == assembly.rodClusterAssembly; - } else { - retVal = retVal - && this.rodClusterAssembly - .equals(assembly.rodClusterAssembly); - } - - } - - // Return retVal - return retVal; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.pwr.PWRAssembly#hashCode() - */ - @Override - public int hashCode() { - int hash = super.hashCode(); - - // Hash local values - hash += 31 * this.gridLabelProvider.hashCode(); - hash += 31 * (null == this.rodClusterAssembly ? 1 - : this.rodClusterAssembly.hashCode()); - hash += 31 * this.tubeComposite.hashCode(); - hash += 31 * this.tubeGridManager.hashCode(); - - // Return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(FuelAssembly otherObject) { - - // If otherObject is null, return - if (otherObject == null) { - return; - } - - // Copy contents - super - super.copy(otherObject); - - // Copy local values - this.gridLabelProvider = (GridLabelProvider) otherObject.gridLabelProvider - .clone(); - // If the other object is null, set to null. Else, set the other object - // to the clone - this.rodClusterAssembly = (null == otherObject.rodClusterAssembly ? null - : (RodClusterAssembly) otherObject.rodClusterAssembly.clone()); - this.tubeComposite = (LWRComposite) otherObject.tubeComposite.clone(); - this.tubeGridManager = (LWRGridManager) otherObject.tubeGridManager - .clone(); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.pwr.PWRAssembly#clone() - */ - @Override - public Object clone() { - - // Local Declarations - FuelAssembly assembly = new FuelAssembly(0); - - // Copy contents - assembly.copy(this); - - // Return newly instantiated object - return assembly; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.pwr.PWRAssembly#getWriteableChildren() - */ - @Override - public ArrayList getWriteableChildren() { - - // Get the children in super - ArrayList children = super.getWriteableChildren(); - - // If super had no children - if (children == null) { - - // Initialize to new array list - children = new ArrayList(); - } - - // Add children - children.add(this.gridLabelProvider); - children.add(this.tubeGridManager); - - return children; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.pwr.PWRAssembly#readChild(org.eclipse.ice.io.hdf.IHdfReadable) - */ - @Override - public boolean readChild(IHdfReadable iHdfReadable) { - - // If the child is null or not an instance of LWRComponent, then return - // false. - if (iHdfReadable == null || !(iHdfReadable instanceof LWRComponent)) { - return false; - } - - // Call readChild on PWRAssembly - super.readChild(iHdfReadable); - - // Cast the child into a LWRComponent - LWRComponent childComponent = (LWRComponent) iHdfReadable; - - // If this is a GridLabelProvider - if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.GRID_LABEL_PROVIDER - && childComponent.getName().equals(GRID_LABEL_PROVIDER_NAME)) { - - // Assign to correct object - this.gridLabelProvider = (GridLabelProvider) childComponent; - - // If this is a LwrGridManager - } else if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.LWRGRIDMANAGER) { - - // Cast into a LWRGridManager object - LWRGridManager lWRGridManager = (LWRGridManager) childComponent; - - // Assign to correct object - if (lWRGridManager.getName().equals(FuelAssembly.TUBE_GRID_MANAGER_NAME)) { - - this.tubeGridManager = (LWRGridManager) childComponent; - - } - - // If this is an LWRComposite - } else if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.LWRCOMPOSITE) { - - // Cast into a LWRComposite object - LWRComposite lWRComposite = (LWRComposite) childComponent; - - // Assign to correct object - if (lWRComposite.getName().equals(FuelAssembly.TUBE_COMPOSITE_NAME)) { - - // Remove the tube from the composite and add it back - this.lWRComponents.remove(FuelAssembly.TUBE_COMPOSITE_NAME); - this.tubeComposite = lWRComposite; - this.lWRComponents.put(tubeComposite.getName(), tubeComposite); - - } - - // If it is a rod cluster assembly - } else if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.ROD_CLUSTER_ASSEMBLY) { - - this.rodClusterAssembly = (RodClusterAssembly) childComponent; - - } - - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.pwr.PWRAssembly#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - boolean flag = super.readAttributes(h5Group); - - if (flag) { - this.gridLabelProvider = new GridLabelProvider(this.size); - this.gridLabelProvider.setName(GRID_LABEL_PROVIDER_NAME); - this.tubeGridManager = new LWRGridManager(this.size); - this.tubeGridManager.setName(TUBE_GRID_MANAGER_NAME); - } - - return flag; - - } - - /** - *

- * Returns the data provider for specific group at location or null if it - * does not exist. - *

- * - * @param row - *

- * the row - *

- * @param column - *

- * The column - *

- * @return

- * the provider - *

- */ - public LWRDataProvider getTubeDataProviderAtLocation(int row, int column) { - - // Pass through - return this.tubeGridManager.getDataProviderAtLocation(new GridLocation( - row, column)); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#accept(org.eclipse.ice.reactor.ILWRComponentVisitor) - */ - @Override - public void accept(ILWRComponentVisitor visitor) { - visitor.visit(this); - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/IncoreInstrument.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/IncoreInstrument.java deleted file mode 100644 index ec8f627da..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/IncoreInstrument.java +++ /dev/null @@ -1,269 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.pwr; - -import java.util.ArrayList; - -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfWriteable; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.ILWRComponentVisitor; -import org.eclipse.ice.reactor.LWRComponent; -import org.eclipse.ice.reactor.Ring; - -/** - *

- * The IncoreInstrument class represents instruments (or detectors) that are - * used for power distribution monitoring inside of a PWReactor. This class - * contains a ring of data designed to be the "thimble" for material composition - * on this class. - *

- * - * @author Scott Forest Hull II - */ -public class IncoreInstrument extends LWRComponent { - /** - *

- * An empty thimble tube used a boundary between the detector and the - * reactor. - *

- * - */ - private Ring thimble; - - /** - *

- * The nullary Constructor. - *

- * - */ - public IncoreInstrument() { - // set default values - this.setName("Instrument 1"); - this.setDescription("Default Instrument"); - this.setId(1); - - thimble = new Ring("thimble"); - - this.HDF5LWRTag = HDF5LWRTagType.INCORE_INSTRUMENT; - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this IncoreInstrument. - *

- * @param thimble - *

- * An empty thimble tube used a boundary between the detector and - * the reactor. - *

- */ - public IncoreInstrument(String name, Ring thimble) { - // call nullary constructor - this(); - this.setName(name); - this.setThimble(thimble); - } - - /** - *

- * Sets an empty thimble tube used a boundary between the detector and the - * reactor. - *

- * - * @param thimble - *

- * An empty thimble tube used a boundary between the detector and - * the reactor. - *

- */ - public void setThimble(Ring thimble) { - // if thimble is not Null set value - if (thimble != null) { - this.thimble = thimble; - } - } - - /** - *

- * Returns an empty thimble tube used a boundary between the detector and - * the reactor. - *

- * - * @return

- * An empty thimble tube used a boundary between the detector and - * the reactor. - *

- */ - public Ring getThimble() { - return this.thimble; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#getWriteableChildren() - */ - @Override - public ArrayList getWriteableChildren() { - - // Get the children in super - ArrayList children = super.getWriteableChildren(); - - // If super had no children - if (children == null) { - - // Initialize to new array list - children = new ArrayList(); - } - - // Add the thimble Ring to children - children.add(this.thimble); - - return children; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readChild(org.eclipse.ice.io.hdf.IHdfReadable) - */ - @Override - public boolean readChild(IHdfReadable iHdfReadable) { - - // If the child is null or not an instance of LWRComponent, then return - // false. - if (iHdfReadable == null || !(iHdfReadable instanceof LWRComponent)) { - return false; - } - - // Cast the child into a LWRComponent - LWRComponent childComponent = (LWRComponent) iHdfReadable; - - // If this is a Ring - if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.RING) { - - // Assign to correct object - this.thimble = (Ring) childComponent; - - } - - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - IncoreInstrument instrument; - boolean retVal = false; - - // If the same ref on heap, return - if (otherObject == this) { - return true; - } - - // Make sure the otherObject is not null and of the same type as this - // object - if (otherObject != null && otherObject instanceof IncoreInstrument) { - - // Cast it - instrument = (IncoreInstrument) otherObject; - - // check values - retVal = (super.equals(otherObject) && this.thimble - .equals(instrument.thimble)); - - } - - // Return retVal - return retVal; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#hashCode() - */ - @Override - public int hashCode() { - - // Local Declarations - int hash = super.hashCode(); - - // Local contents of the hash - hash += 31 * this.thimble.hashCode(); - - // Return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(IncoreInstrument otherObject) { - - // If null, return - if (otherObject == null) { - return; - } - - // Copy contents - super - super.copy(otherObject); - - // Copy local contents - this.thimble = (Ring) otherObject.thimble.clone(); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#clone() - */ - @Override - public Object clone() { - - // Local Declarations - IncoreInstrument instrument = new IncoreInstrument(); - - // Copy contents - instrument.copy(this); - - // Return newly instantiated object - return instrument; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#accept(org.eclipse.ice.reactor.ILWRComponentVisitor) - */ - @Override - public void accept(ILWRComponentVisitor visitor) { - visitor.visit(this); - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/PWRAssembly.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/PWRAssembly.java deleted file mode 100644 index e4c3fe9f4..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/PWRAssembly.java +++ /dev/null @@ -1,763 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.pwr; - -import java.util.ArrayList; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfWriteable; -import org.eclipse.ice.reactor.GridLocation; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.LWRComponent; -import org.eclipse.ice.reactor.LWRComposite; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.eclipse.ice.reactor.LWRGridManager; -import org.eclipse.ice.reactor.LWRRod; - -/** - *

- * The PWRAssembly class contains a collection of LWRRods mapped to locations on - * a grid. When the addLWRRod() operation is used, if a LWRRod with the same - * name exists in the collection, then the LWRRod will not be added and a value - * of false will be returned. When using the setLWRRodLocation() operation, if a - * LWRRod with the same name exists at the provided location, then the current - * LWRRod name at the provided location will be overwritten. - *

- *

- *

- *

- * StatePointData for LWRRods should be stored by position and accessed by the - * getLWRRodDataProviderAtLocation operation. - *

- * - * @author Scott Forest Hull II - */ -public class PWRAssembly extends LWRComposite { - /** - *

- * The size of either dimension of this PWRAssembly. - *

- * - */ - protected int size; - /** - *

- * A LWRComposite for LWRRods. - *

- * - */ - protected LWRComposite lWRRodComposite; - /** - * - */ - protected LWRGridManager lWRRodGridManager; - /** - *

- * The distance between centers of adjacent fuel rods in the fuel grid. - * Must be greater than zero. - *

- * - */ - protected double rodPitch; - - // Private attributes for readChild operations. - private static final String LWRROD_COMPOSITE_NAME = "LWRRods"; - private static final String LWRROD_GRID_MANAGER_NAME = "LWRRod Grid"; - - /** - *

- * A parameterized Constructor. - *

- * - * @param size - *

- * The size of either dimension of this PWRAssembly. - *

- */ - public PWRAssembly(int size) { - super(); - // Setup default values - LWRComponent - this.name = "PWRAssembly"; - this.description = "PWRAssembly's Description"; - this.id = 1; - - // Setup default values for size and map - this.size = 1; - - // Set the size if it is greater than 0 - if (size > 0) { - this.size = size; - } - - // Setup the LWRComposite and associated values. - this.lWRRodComposite = new LWRComposite(); - this.lWRRodComposite.setName(PWRAssembly.LWRROD_COMPOSITE_NAME); - this.lWRRodComposite - .setDescription("A Composite that contains many LWRRods."); - this.lWRRodComposite.setId(1); - - // Setup GridManager - this.lWRRodGridManager = new LWRGridManager(this.size); - this.lWRRodGridManager.setName(PWRAssembly.LWRROD_GRID_MANAGER_NAME); - - // Add the component to the LWRComposite list - super.addComponent(lWRRodComposite); - - // Default size for rod pitch - this.rodPitch = 1.0; - - // Setup the LWRComponentType to the correct type - this.HDF5LWRTag = HDF5LWRTagType.PWRASSEMBLY; - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this PWRAssembly. - *

- * @param size - *

- * The size of either dimension of this PWRAssembly. - *

- */ - public PWRAssembly(String name, int size) { - // Call shorter constructor - this(size); - - // Set name - this.setName(name); - - } - - /** - *

- * Returns the size of either dimension of this PWRAssembly. - *

- * - * @return

- * The size of either dimension of this PWRAssembly. - *

- */ - public int getSize() { - return this.size; - - } - - /** - *

- * Adds a LWRRod to the collection of LWRRods. If a LWRRod with the same - * name exists in the collection or the passed parameter is null, then the - * LWRRod will not be added and a value of false will be returned. - *

- * - * @param lWRRod - *

- * The LWRRod to add to the collection of LWRRods. - *

- * @return

- * True, if the LWRRod was added successfully. - *

- */ - public boolean addLWRRod(LWRRod lWRRod) { - // Add the component to the composite - this.lWRRodComposite.addComponent(lWRRod); - - // If the component is not contained, return false - if (!this.lWRRodComposite.getComponents().contains(lWRRod)) { - return false; - } - - // The component was added to the composite, return true! - return true; - - } - - /** - *

- * Removes a LWRRod from the collection of LWRRods. The passed string can - * not be null. - *

- * - * @param lWRRodName - *

- * The name of the LWRRod to be removed. Returns true if the - * LWRRod was removed successfully. - *

- * @return

- * True, if the LWRRod was removed successfully. - *

- */ - public boolean removeLWRRod(String lWRRodName) { - // If the name does not exist, return - if (this.lWRRodComposite.getComponent(lWRRodName) == null) { - return false; - } - - // Remove it from the grid as well - this.lWRRodGridManager.removeComponent(this.lWRRodComposite - .getComponent(lWRRodName)); - - // Remove the component from the composite with the given name - this.lWRRodComposite.removeComponent(lWRRodName); - - // Remove it from the grid as well - this.lWRRodGridManager.removeComponent(this.lWRRodComposite - .getComponent(lWRRodName)); - - // If name does not exist, return true. Else false - if (this.lWRRodComposite.getComponent(lWRRodName) != null) { - return false; - } - - // The component was deleted from the composite, return true! - return true; - } - - /** - *

- * Returns an ArrayList of names for each element of the collection of - * LWRRods. - *

- * - * @return

- * An ArrayList of names for each element of the collection of - * LWRRods. - *

- */ - public ArrayList getLWRRodNames() { - - // Return the Component's names - return this.lWRRodComposite.getComponentNames(); - } - - /** - *

- * Returns the LWRRod corresponding to the provided name or null if the name - * is not found. - *

- * - * @param name - *

- * The provided LWRRod's name. - *

- * @return

- * The LWRRod corresponding to the provided name or null if the name - * is not found. - *

- */ - public LWRRod getLWRRodByName(String name) { - - return (LWRRod) this.lWRRodComposite.getComponent(name); - } - - /** - *

- * Returns the LWRRod corresponding to the provided column and row or null - * if one is not found at the provided location. - *

- * - * @param row - *

- * The row position. - *

- * @param column - *

- * The column position. - *

- * @return

- * The LWRRod corresponding to the provided column and row or null - * if one is not found at the provided location. - *

- */ - public LWRRod getLWRRodByLocation(int row, int column) { - - // Local Declarations - String name = ""; - - // Get the name - name = this.lWRRodGridManager.getComponentName(new GridLocation(row, - column)); - - // Return the component - return this.getLWRRodByName(name); - - } - - /** - *

- * Returns the number of LWRRods in the collection of LWRRods. - *

- * - * @return

- * The number of LWRRods in the collection of LWRRods. - *

- */ - public int getNumberOfLWRRods() { - - // Return the number of components - return this.lWRRodComposite.getNumberOfComponents(); - - } - - /** - *

- * Sets the location for the provided name. Overrides the location of - * another component name as required. Returns true if this operation was - * successful, false otherwise. Note it will return true if the same name is - * overridden. - *

- * - * @param lWRRodName - *

- * The LWRRod's name. - *

- * @param row - *

- * The row position. - *

- * @param column - *

- * The column position. - *

- * @return

- * True, if the location of the LWRRod was set successfully. - *

- */ - public boolean setLWRRodLocation(String lWRRodName, int row, int column) { - // Local declarations - GridLocation location = new GridLocation(row, column); - - // If the rows and columns dont match the location, return false - if (location.getColumn() != column || location.getRow() != row) { - return false; - } - - // Set the location - this.lWRRodGridManager.addComponent( - this.lWRRodComposite.getComponent(lWRRodName), - location); - - // If the name changed, then return true - if (this.lWRRodGridManager.getComponentName(location) != null - && this.lWRRodGridManager.getComponentName(location).equals( - lWRRodName)) { - return true; - } - - // Otherwise, name did not change - return false; - - } - - /** - *

- * Removes the LWRRod at the provided location. Returns true if the removal - * was successful. - *

- * - * @param row - *

- * The row position. - *

- * @param column - *

- * The column position. - *

- * @return

- * True, if the removal was successful. - *

- */ - public boolean removeLWRRodFromLocation(int row, int column) { - // Local Declarations - GridLocation location = new GridLocation(row, column); - - // If the rows and columns dont match the location, return false - if (location.getColumn() != column || location.getRow() != row) { - return false; - } - - // Check to make sure that a name exists there. - if (this.lWRRodGridManager.getComponentName(location) == null) { - return false; - } - - // Remove the component from the location - this.lWRRodGridManager.removeComponent(location); - - // If the composite at that location is null, then return true - if (this.lWRRodGridManager.getComponentName(location) == null) { - return true; - } - - // Nothing was changed, return false - return false; - - } - - /** - *

- * Returns the distance between centers of adjacent fuel rods. - *

- * - * @return

- * The distance between centers of adjacent fuel rods in the fuel - * lattice. - *

- */ - public double getRodPitch() { - - return this.rodPitch; - - } - - /** - *

- * Sets the distance between centers of adjacent fuel rods in the fuel - * lattice. The rodPitch value must be greater than zero. - *

- * - * @param rodPitch - *

- * The distance between centers of adjacent fuel rods in the fuel - * lattice. - *

- */ - public void setRodPitch(double rodPitch) { - - // If the rod pitch is less than zero, do not set to new value. - if (rodPitch > 0) { - this.rodPitch = rodPitch; - } - - } - - /** - *

- * This operation overrides the LWRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param component - *

- * The component to be added. - *

- */ - @Override - public void addComponent(Component component) { - - // Does nothing - } - - /** - *

- * An operation that overrides the LWRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param childId - *

- * The id of the LWRComponent to remove. - *

- */ - @Override - public void removeComponent(int childId) { - - // Does nothing - - } - - /** - *

- * An operation that overrides the LWRComposite's operation. This operation - * does nothing and requires that the appropriate, more defined, associated - * operation to be utilized on this class. - *

- * - * @param name - *

- * The name of the LWRComponent to remove. - *

- */ - @Override - public void removeComponent(String name) { - - // Does nothing - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Local Declarations - PWRAssembly assembly; - boolean retVal = false; - - // If they are equal to the same place on the heap, return true - if (otherObject == this) { - return true; - } - - // If the otherObject is null or not an instanceof this object, return - // false - if (otherObject != null && otherObject instanceof PWRAssembly) { - - // Cast it - assembly = (PWRAssembly) otherObject; - - // Compare values - retVal = super.equals(otherObject) - && this.lWRRodComposite.equals(assembly.lWRRodComposite) - && this.lWRRodGridManager - .equals(assembly.lWRRodGridManager) - && this.size == assembly.size - && this.rodPitch == assembly.rodPitch; - - } - - // Return retVal - return retVal; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#hashCode() - */ - @Override - public int hashCode() { - - // Local Declarations - int hash = super.hashCode(); - - // Add hashes of local attributes - hash += 31 * this.rodPitch; - hash += 31 * this.size; - hash += 31 * this.lWRRodComposite.hashCode(); - hash += 31 * this.lWRRodGridManager.hashCode(); - - // Return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(PWRAssembly otherObject) { - - // If the otherObject is null, return - if (otherObject == null) { - return; - } - - // Copy contents - super - super.copy(otherObject); - - // Copy local contents - this.rodPitch = otherObject.rodPitch; - this.size = otherObject.size; - this.lWRRodComposite = (LWRComposite) otherObject.lWRRodComposite - .clone(); - this.lWRRodGridManager = (LWRGridManager) otherObject.lWRRodGridManager - .clone(); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#clone() - */ - @Override - public Object clone() { - - // Local Declarations - PWRAssembly assembly = new PWRAssembly(0); - - // Copy contents - assembly.copy(this); - - // Return newly instantiated object - return assembly; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeIntegerAttribute(h5File, h5Group, "size", - this.size); - flag &= HdfWriterFactory.writeDoubleAttribute(h5File, h5Group, - "rodPitch", rodPitch); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#getWriteableChildren() - */ - @Override - public ArrayList getWriteableChildren() { - - // Get the children in super - ArrayList children = super.getWriteableChildren(); - - // If super had no children - if (children == null) { - - // Initialize to new array list - children = new ArrayList(); - } - - // Add children - children.add(this.lWRRodGridManager); - - return children; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - // Local Declarations - boolean flag = true; - - // Get values - Integer size = HdfReaderFactory.readIntegerAttribute(h5Group, "size"); - Double rodPitch = HdfReaderFactory.readDoubleAttribute(h5Group, - "rodPitch"); - - // Call super - flag &= super.readAttributes(h5Group); - - // check values - if (size == null || rodPitch == null || !flag || h5Group == null) { - return false; - } - - // If everything is valid, then set data - this.size = size.intValue(); - this.rodPitch = rodPitch.doubleValue(); - - // Reset the sizes on the grids - this.lWRRodGridManager = new LWRGridManager(size.intValue()); - this.lWRRodGridManager.setName(PWRAssembly.LWRROD_GRID_MANAGER_NAME); - - return true; - - } - - /** - *

- * Returns the data provider for specific group at location or null if it - * does not exist. - *

- * - * @param row - *

- * the row - *

- * @param column - *

- * The column - *

- * @return

- * the provider - *

- */ - public LWRDataProvider getLWRRodDataProviderAtLocation(int row, int column) { - - return this.lWRRodGridManager - .getDataProviderAtLocation(new GridLocation(row, column)); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#readChild(org.eclipse.ice.io.hdf.IHdfReadable) - */ - @Override - public boolean readChild(IHdfReadable iHdfReadable) { - - // If the child is null or not an instance of LWRComponent, then return - // false. - if (iHdfReadable == null || !(iHdfReadable instanceof LWRComponent)) { - return false; - } - - // Cast the child into a LWRComponent - LWRComponent childComponent = (LWRComponent) iHdfReadable; - - // If this is a LWRGridManager - if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.LWRGRIDMANAGER) { - - // Cast into a LWRGridManager object - LWRGridManager lWRGridManager = (LWRGridManager) childComponent; - - // Assign to the correct object - if (lWRGridManager.getName().equals(PWRAssembly.LWRROD_GRID_MANAGER_NAME)) { - this.lWRRodGridManager = (LWRGridManager) childComponent; - - } - - // If this is an LWRComposite - } else if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.LWRCOMPOSITE) { - - // Cast into a LWRComposite object - LWRComposite lWRComposite = (LWRComposite) childComponent; - // Assign to the correct object - if (lWRComposite.getName().equals(PWRAssembly.LWRROD_COMPOSITE_NAME)) { - super.removeComponent(PWRAssembly.LWRROD_COMPOSITE_NAME); - this.lWRRodComposite = lWRComposite; - super.addComponent(lWRRodComposite); - - } - - } - - return true; - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/PressurizedWaterReactor.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/PressurizedWaterReactor.java deleted file mode 100644 index dcc949067..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/PressurizedWaterReactor.java +++ /dev/null @@ -1,993 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.pwr; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import ncsa.hdf.object.h5.H5File; -import ncsa.hdf.object.h5.H5Group; - -import org.eclipse.ice.io.hdf.HdfReaderFactory; -import org.eclipse.ice.io.hdf.HdfWriterFactory; -import org.eclipse.ice.io.hdf.IHdfReadable; -import org.eclipse.ice.io.hdf.IHdfWriteable; -import org.eclipse.ice.reactor.AssemblyType; -import org.eclipse.ice.reactor.GridLabelProvider; -import org.eclipse.ice.reactor.GridLocation; -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.ILWRComponentVisitor; -import org.eclipse.ice.reactor.LWRComponent; -import org.eclipse.ice.reactor.LWRComposite; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.eclipse.ice.reactor.LWRGridManager; -import org.eclipse.ice.reactor.LWReactor; - -/** - *

- * The PressurizedWaterReactor (PWReactor) class represents any Pressurized - * Water Reactor. This class extends the LWReactor and provides a defined - * utility for representing a PWReactor. It can store specific assemblies in - * their own grids, so that one type of assembly can share the same position as - * another type. - *

- *

- * Keep in mind although there are many ways to prevent erroneous - * PressurizedWaterReactors from being built, this class should not manage the - * deeper logic behind building a reactor. For example, there is no logic to - * stop a user from setting all assemblies in all locations (although it does - * have logic to stop two assemblies of the same type to be stored at the same - * location). The deeper types of logic are up to the user of this class who - * delegates the conversion between their reactor model to this model. This is - * to allow flexibility and portability to many applications so that other users - * can apply this model to earlier or later versions of a - * PressurizedWaterReactor with minimal restrictions. - *

- *

- * Please note that when the add<Component>() operation is used, if a - * <Component> with the same name exists in the <Component> - * collection, then the <Component> will not be added. When using the - * set<Component>Location() operation, if a <Component>with the same - * name exists at the provided location, then the current <Component> name - * at the provided location will be overwritten. Here, <Component> can be - * (but not limited to) "ControlBanks", "FuelAssembly", "IncoreInstrument", or - * "RodClusterAssembly". Please check the enumeration called AssemblyTypes for a - * complete list of Assemblies that could be managed by this class. - *

- *

- *

- *

- *

- * - * @author Scott Forest Hull II - */ -@XmlRootElement -public class PressurizedWaterReactor extends LWReactor { - /** - *

- * The map of grid managers, keyed by AssemblyType, that manage state point - * data for the assemblies. - *

- * - */ - @XmlTransient - private HashMap managers; - /** - *

- * The map of assembly composites, keyed by AssemblyType, that represent the - * collections of the different assemblies in this reactor. - *

- * - */ - @XmlTransient - private HashMap assemblyComposites; - /** - *

- * The distance between assemblies in the core, determined by the seating - * location in the core plates. - *

- * - */ - @XmlTransient - private double fuelAssemblyPitch; - /** - *

- * The GridLabelProvider for this PWReactor. - *

- * - */ - @XmlTransient - private GridLabelProvider gridLabelProvider; - - @XmlTransient - private static final String CONTROL_BANK_COMPOSITE_NAME = "Control Banks"; - @XmlTransient - private static final String FUEL_ASSEMBLY_COMPOSITE_NAME = "Fuel Assemblies"; - @XmlTransient - private static final String INCORE_INSTRUMENT_COMPOSITE_NAME = "Incore Instruments"; - @XmlTransient - private static final String ROD_CLUSTER_ASSEMBLY_COMPOSITE_NAME = "Rod Cluster Assemblies"; - @XmlTransient - private static final String CONTROL_BANK_GRID_MANAGER_NAME = "Control Bank Grid"; - @XmlTransient - private static final String FUEL_ASSEMBLY_GRID_MANAGER_NAME = "Fuel Assembly Grid"; - @XmlTransient - private static final String INCORE_INSTRUMENT_GRID_MANAGER_NAME = "Incore Instrument Grid"; - @XmlTransient - private static final String ROD_CLUSTER_ASSEMBLY_GRID_MANAGER_NAME = "Rod Cluster Assembly Grid"; - @XmlTransient - private static final String GRID_LABEL_PROVIDER_NAME = "Grid Labels"; - - /** - * A default constructor that should ONLY be used for persistence and - * testing. It is equivalent to PressurizedWaterReactor(15). - */ - public PressurizedWaterReactor() { - this(15); - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param size - *

- * The number of fuel assemblies across the core. - *

- */ - public PressurizedWaterReactor(int size) { - super(size); - - // Set the default value of size - if (size > 0) { - this.size = size; - } else { - this.size = 17; // Auto default size! - } - - // Initialize everything - // Setup row and column information - - // Setup Control Banks information - LWRComposite controlBankComposite = new LWRComposite(); - controlBankComposite.setName(PressurizedWaterReactor.CONTROL_BANK_COMPOSITE_NAME); - controlBankComposite - .setDescription("A Composite that contains many ControlBank Components."); - controlBankComposite.setId(1); - // Put into the lWRComponents - this.lWRComponents.put(controlBankComposite.getName(), - controlBankComposite); - - // Setup Grid Manager - LWRGridManager controlBankGridManager = new LWRGridManager(this.size); - controlBankGridManager.setName(PressurizedWaterReactor.CONTROL_BANK_GRID_MANAGER_NAME); - - // Setup Fuel Assemblies information - LWRComposite fuelAssemblyComposite = new LWRComposite(); - fuelAssemblyComposite.setName(PressurizedWaterReactor.FUEL_ASSEMBLY_COMPOSITE_NAME); - fuelAssemblyComposite - .setDescription("A Composite that contains many FuelAssembly Components."); - fuelAssemblyComposite.setId(2); - // Put into the lWRComponents - this.lWRComponents.put(fuelAssemblyComposite.getName(), - fuelAssemblyComposite); - - // Setup Grid Manager - LWRGridManager fuelAssemblyGridManager = new LWRGridManager(this.size); - fuelAssemblyGridManager.setName(PressurizedWaterReactor.FUEL_ASSEMBLY_GRID_MANAGER_NAME); - - this.fuelAssemblyPitch = 0.0; - - // Setup InCoreInstruments - LWRComposite incoreInstrumentComposite = new LWRComposite(); - incoreInstrumentComposite - .setName(PressurizedWaterReactor.INCORE_INSTRUMENT_COMPOSITE_NAME); - incoreInstrumentComposite - .setDescription("A Composite that contains many IncoreInstrument Components."); - incoreInstrumentComposite.setId(3); - // Put into the lWRComponents - this.lWRComponents.put(incoreInstrumentComposite.getName(), - incoreInstrumentComposite); - - // Setup Grid Manager - LWRGridManager incoreInstrumentGridManager = new LWRGridManager( - this.size); - incoreInstrumentGridManager - .setName(PressurizedWaterReactor.INCORE_INSTRUMENT_GRID_MANAGER_NAME); - - // Setup RodClusterAssemblies - LWRComposite rodClusterAssemblyComposite = new LWRComposite(); - rodClusterAssemblyComposite - .setName(PressurizedWaterReactor.ROD_CLUSTER_ASSEMBLY_COMPOSITE_NAME); - rodClusterAssemblyComposite - .setDescription("A Composite that contains many RodClusterAssembly Components."); - rodClusterAssemblyComposite.setId(4); - // Put into the lWRComponents - this.lWRComponents.put(rodClusterAssemblyComposite.getName(), - rodClusterAssemblyComposite); - - // Setup Grid Manager - LWRGridManager rodClusterAssemblyGridManager = new LWRGridManager( - this.size); - rodClusterAssemblyGridManager - .setName(PressurizedWaterReactor.ROD_CLUSTER_ASSEMBLY_GRID_MANAGER_NAME); - - // Add a default GridLabelProvider - this.gridLabelProvider = new GridLabelProvider(this.size); - this.gridLabelProvider.setName(PressurizedWaterReactor.GRID_LABEL_PROVIDER_NAME); - - // Setup the Name, Id, Description - this.name = "PWReactor 1"; - this.id = 1; - this.description = "PWReactor 1's Description"; - - // Setup the LWRComponentType to the correct Type - this.HDF5LWRTag = HDF5LWRTagType.PWREACTOR; - - // Setup the composite map - assemblyComposites = new HashMap(); - assemblyComposites.put(AssemblyType.ControlBank, controlBankComposite); - assemblyComposites.put(AssemblyType.Fuel, fuelAssemblyComposite); - assemblyComposites.put(AssemblyType.IncoreInstrument, - incoreInstrumentComposite); - assemblyComposites.put(AssemblyType.RodCluster, - rodClusterAssemblyComposite); - - // Setup the grid map - managers = new HashMap(); - managers.put(AssemblyType.ControlBank, controlBankGridManager); - managers.put(AssemblyType.Fuel, fuelAssemblyGridManager); - managers.put(AssemblyType.IncoreInstrument, incoreInstrumentGridManager); - managers.put(AssemblyType.RodCluster, rodClusterAssemblyGridManager); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWReactor#getSize() - */ - @Override - public int getSize() { - - return this.size; - } - - /** - *

- * Returns the GridLabelProvider for this PWReactor. - *

- * - * @return

- * The GridLabelProvider for this PWReactor. - *

- */ - public GridLabelProvider getGridLabelProvider() { - - return this.gridLabelProvider; - } - - /** - *

- * Sets the GridLabelProvider for this PWReactor. - *

- * - * @param gridLabelProvider - *

- * The GridLabelProvider for this FuelAssembly. - *

- */ - public void setGridLabelProvider(GridLabelProvider gridLabelProvider) { - - // Set the grid label provider if it is not null and the same size - if (gridLabelProvider != null - && gridLabelProvider.getSize() == this.size) { - this.gridLabelProvider = gridLabelProvider; - } - - } - - /** - *

- * Returns the distance between assemblies in the core, determined by the - * seating location in the core plates. - *

- * - * @return

- * The distance between assemblies in the core, determined by the - * seating location in the core plates. - *

- */ - public double getFuelAssemblyPitch() { - - return this.fuelAssemblyPitch; - - } - - /** - *

- * Sets the distance between assemblies in the core, determined by the - * seating location in the core plates. - *

- * - * @param fuelAssemblyPitch - *

- * The distance between assemblies in the core, determined by the - * seating location in the core plates. - *

- */ - public void setFuelAssemblyPitch(double fuelAssemblyPitch) { - - if (fuelAssemblyPitch >= 0.0) { - this.fuelAssemblyPitch = fuelAssemblyPitch; - } - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWReactor#readAttributes(ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean readAttributes(H5Group h5Group) { - - boolean flag = super.readAttributes(h5Group); - - Double fuelAssemblyPitch = HdfReaderFactory.readDoubleAttribute( - h5Group, "fuelAssemblyPitch"); - - // If any of them are erroneous, return false - if (fuelAssemblyPitch == null || !flag) { - return false; - } - - // Set the primitive data - this.fuelAssemblyPitch = fuelAssemblyPitch.doubleValue(); - - // Reset info - this.gridLabelProvider = new GridLabelProvider(this.size); - this.gridLabelProvider.setName(PressurizedWaterReactor.GRID_LABEL_PROVIDER_NAME); - - LWRGridManager controlBankGridManager = new LWRGridManager(this.size); - controlBankGridManager.setName(PressurizedWaterReactor.CONTROL_BANK_GRID_MANAGER_NAME); - LWRGridManager fuelAssemblyGridManager = new LWRGridManager(this.size); - fuelAssemblyGridManager.setName(FUEL_ASSEMBLY_GRID_MANAGER_NAME); - LWRGridManager incoreInstrumentGridManager = new LWRGridManager( - this.size); - incoreInstrumentGridManager - .setName(INCORE_INSTRUMENT_GRID_MANAGER_NAME); - LWRGridManager rodClusterAssemblyGridManager = new LWRGridManager( - this.size); - rodClusterAssemblyGridManager - .setName(ROD_CLUSTER_ASSEMBLY_GRID_MANAGER_NAME); - - // Setup the grid map - managers = new HashMap(); - managers.put(AssemblyType.ControlBank, controlBankGridManager); - managers.put(AssemblyType.Fuel, fuelAssemblyGridManager); - managers.put(AssemblyType.IncoreInstrument, incoreInstrumentGridManager); - managers.put(AssemblyType.RodCluster, rodClusterAssemblyGridManager); - - return true; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWReactor#writeAttributes(ncsa.hdf.object.h5.H5File, ncsa.hdf.object.h5.H5Group) - */ - @Override - public boolean writeAttributes(H5File h5File, H5Group h5Group) { - - boolean flag = true; - - flag &= super.writeAttributes(h5File, h5Group); - flag &= HdfWriterFactory.writeDoubleAttribute(h5File, h5Group, - "fuelAssemblyPitch", fuelAssemblyPitch); - - return flag; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWReactor#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - // Local Declarations - PressurizedWaterReactor reactor; - boolean retVal = false; - // Return true if they are equal on the heap - if (otherObject == this) { - return true; - } - // If the otherObject is null or if the otherObject is not an instance - // of this object, return false - if (otherObject != null - && otherObject instanceof PressurizedWaterReactor) { - // Cast it - reactor = (PressurizedWaterReactor) otherObject; - // Compare values - retVal = super.equals(otherObject) - && this.size == reactor.size - && this.fuelAssemblyPitch == reactor.fuelAssemblyPitch - && this.managers.equals(reactor.managers) - && this.assemblyComposites - .equals(reactor.assemblyComposites) - && this.gridLabelProvider.equals(reactor.gridLabelProvider); - } - // Return retVal - return retVal; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#getWriteableChildren() - */ - @Override - public ArrayList getWriteableChildren() { - - // Get the children in super - ArrayList children = super.getWriteableChildren(); - - // If super had no children - if (children == null) { - - // Initialize to new array list - children = new ArrayList(); - } - - // Add the label provider to the children - children.add(this.gridLabelProvider); - - // Add all the managers - children.addAll(this.managers.values()); - - return children; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComposite#readChild(org.eclipse.ice.io.hdf.IHdfReadable) - */ - @Override - public boolean readChild(IHdfReadable iHdfReadable) { - - // If the child is null or not an instance of LWRComponent, then return - // false. - if (iHdfReadable == null || !(iHdfReadable instanceof LWRComponent)) { - return false; - } - - // Cast the child into a LWRComponent - LWRComponent childComponent = (LWRComponent) iHdfReadable; - - // If this is a GridLabelProvider - if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.GRID_LABEL_PROVIDER - && childComponent.getName().equals(GRID_LABEL_PROVIDER_NAME)) { - - // Assign to variable - this.gridLabelProvider = (GridLabelProvider) childComponent; - - // If this is a LwrGridManager - } else if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.LWRGRIDMANAGER) { - - // Cast into a LWRGridManager object - LWRGridManager lWRGridManager = (LWRGridManager) childComponent; - - // Check the name and assign to correct object - if (lWRGridManager.getName().equals( - PressurizedWaterReactor.CONTROL_BANK_GRID_MANAGER_NAME)) { - - this.managers.put(AssemblyType.ControlBank, lWRGridManager); - - } else if (lWRGridManager.getName().equals( - PressurizedWaterReactor.FUEL_ASSEMBLY_GRID_MANAGER_NAME)) { - - this.managers.put(AssemblyType.Fuel, lWRGridManager); - - } else if (lWRGridManager.getName().equals( - PressurizedWaterReactor.INCORE_INSTRUMENT_GRID_MANAGER_NAME)) { - - this.managers - .put(AssemblyType.IncoreInstrument, lWRGridManager); - - } else if (lWRGridManager.getName().equals( - PressurizedWaterReactor.ROD_CLUSTER_ASSEMBLY_GRID_MANAGER_NAME)) { - - this.managers.put(AssemblyType.RodCluster, lWRGridManager); - - } - - // If this is an LWRComposite - } else if (childComponent.getHDF5LWRTag() == HDF5LWRTagType.LWRCOMPOSITE) { - - // Cast into a LWRComposite object - LWRComposite lWRComposite = (LWRComposite) childComponent; - - // Check the name and assign to correct object - if (lWRComposite.getName().equals(PressurizedWaterReactor.CONTROL_BANK_COMPOSITE_NAME)) { - - // Remove existing component and replace with new one - this.lWRComponents.remove(lWRComposite.getName()); - this.lWRComponents.put(lWRComposite.getName(), lWRComposite); - this.assemblyComposites.put(AssemblyType.ControlBank, - lWRComposite); - - } else if (lWRComposite.getName().equals( - PressurizedWaterReactor.FUEL_ASSEMBLY_COMPOSITE_NAME)) { - - // Remove existing component and replace with new one - this.lWRComponents.remove(lWRComposite.getName()); - this.lWRComponents.put(lWRComposite.getName(), lWRComposite); - this.assemblyComposites.put(AssemblyType.Fuel, lWRComposite); - - } else if (lWRComposite.getName().equals( - PressurizedWaterReactor.INCORE_INSTRUMENT_COMPOSITE_NAME)) { - - // Remove existing component and replace with new one - this.lWRComponents.remove(lWRComposite.getName()); - this.lWRComponents.put(lWRComposite.getName(), lWRComposite); - this.assemblyComposites.put(AssemblyType.IncoreInstrument, - lWRComposite); - - } else if (lWRComposite.getName().equals( - PressurizedWaterReactor.ROD_CLUSTER_ASSEMBLY_COMPOSITE_NAME)) { - - // Remove existing component and replace with new one - this.lWRComponents.remove(lWRComposite.getName()); - this.lWRComponents.put(lWRComposite.getName(), lWRComposite); - this.assemblyComposites.put(AssemblyType.RodCluster, - lWRComposite); - - } - - } - - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWReactor#hashCode() - */ - @Override - public int hashCode() { - - // Local Declarations - int hash = super.hashCode(); - - // Get the hash of local attributes - hash += 31 * this.fuelAssemblyPitch; - hash += 31 * this.size; - hash += 31 * this.assemblyComposites.hashCode(); - hash += 31 * this.managers.hashCode(); - hash += 31 * this.gridLabelProvider.hashCode(); - - // Return the hash - return hash; - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(PressurizedWaterReactor otherObject) { - - // If otherObject is null, return - if (otherObject == null) { - return; - } - - // Copy contents - super - super.copy(otherObject); - - // Copy local contents - this.fuelAssemblyPitch = otherObject.fuelAssemblyPitch; - this.size = otherObject.size; - - // Deep copy gridManagers - this.managers.clear(); - - // Get the iterator for the GridManagers - for (Map.Entry entry : otherObject.managers - .entrySet()) { - - // Clone and add - this.managers.put(entry.getKey(), (LWRGridManager) entry.getValue() - .clone()); - - // Add reference - - } - - // Due to the super's deep copy, we will need to grab the references - // from the cloned components above - // So, we will add them and then OVERRIDE the mapping within the - // lwrComponents - - // Clear the assemblyComposites - this.assemblyComposites.clear(); - - for (Map.Entry entry : otherObject.assemblyComposites - .entrySet()) { - this.lWRComponents.remove(entry.getKey()); - } - - // Add them back - for (Map.Entry entry : otherObject.assemblyComposites - .entrySet()) { - LWRComposite composite = (LWRComposite) entry.getValue().clone(); - this.assemblyComposites.put(entry.getKey(), composite); - - // Add back to the lwrComponents - this.lWRComponents.put(composite.getName(), composite); - } - - // Copy the GridLabelProvider - this.gridLabelProvider = (GridLabelProvider) otherObject.gridLabelProvider - .clone(); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWReactor#clone() - */ - @Override - public Object clone() { - - // Local Declarations - PressurizedWaterReactor reactor = new PressurizedWaterReactor(0); - - // copy contents - reactor.copy(this); - - // Return newly instantiated object - return reactor; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#accept(org.eclipse.ice.reactor.ILWRComponentVisitor) - */ - @Override - public void accept(ILWRComponentVisitor visitor) { - visitor.visit(this); - } - - /** - *

- * This operation adds an assembly of the specified AssemblyType to the - * reactor and return true. If an assembly of the same name and type already - * exists in the reactor, then the new assembly will not be added and this - * operation will return false. - *

- * - * @param type - *

- * The type of the assembly. - *

- * @param assembly - *

- * The assembly to add to the collection of FuelAssemblies. - *

- * @return

- * True, if the assembly was added successfully. - *

- */ - public boolean addAssembly(AssemblyType type, LWRComponent assembly) { - - // Local Declarations - LWRComposite composite = assemblyComposites.get(type); - boolean status = false; - - // Add the component to the composite - composite.addComponent(assembly); - - // Set the return flag - status = composite.getComponents().contains(assembly); - - return status; - - } - - /** - *

- * Removes an assembly of the specified type from the collection of - * assemblies. Returns true if the operation was successful, false - * otherwise. - *

- * - * @param type - *

- * The type of the assembly. - *

- * @param assemblyName - *

- * The name of the assembly to be removed. - *

- * @return

- * True, if the assembly was removed successfully. - *

- */ - public boolean removeAssembly(AssemblyType type, String assemblyName) { - - // Local Declarations - LWRComposite composite = assemblyComposites.get(type); - LWRComponent component = composite.getComponent(assemblyName); - LWRGridManager manager = managers.get(type); - boolean status = true; - - // Only do this if the component exists - if (component != null) { - // Remove the assembly from the composite and grid - manager.removeComponent(component); - composite.removeComponent(assemblyName); - } else { - status = false; - } - - return status; - - } - - /** - *

- * Returns an list of names for each assembly in the reactor of the - * specified type. - *

- * - * @param type - *

- * The type of the assembly. - *

- * @return

- * An ArrayList of names for each element of the collection of - * assemblies. - *

- */ - public ArrayList getAssemblyNames(AssemblyType type) { - - // Local Declarations - LWRComposite composite = assemblyComposites.get(type); - - return composite.getComponentNames(); - } - - /** - *

- * Returns the assembly of the specified type with the provided name or null - * if an assembly of that type and name does not exist. - *

- * - * @param type - *

- * The type of the assembly. - *

- * @param name - *

- * The name of the assembly to find. - *

- * @return

- * The assembly - *

- */ - public LWRComponent getAssemblyByName(AssemblyType type, String name) { - - // Local Declarations - LWRComposite composite = assemblyComposites.get(type); - - // Return the composite - return composite.getComponent(name); - - } - - /** - *

- * Returns the assembly of the specified type at the specified column and - * row in the reactor or null if one is not found at the provided location. - *

- * - * @param type - *

- * The type of the assembly. - *

- * @param row - *

- * The row id. - *

- * @param column - *

- * The column id. - *

- * @return

- * The assembly corresponding to the provided type, column and row - * or null if one is not found at the provided location. - *

- */ - public LWRComponent getAssemblyByLocation(AssemblyType type, int row, - int column) { - - // Local Declarations - LWRGridManager manager = managers.get(type); - String name = ""; - - // Get the name - name = manager.getComponentName(new GridLocation(row, column)); - - // Return the component - return getAssemblyByName(type, name); - - } - - /** - *

- * Sets the location for the assembly of the specified type with the - * provided name. Overrides the location of another assembly as required. - * Returns true if this operation was successful, false otherwise. Note it - * will return true if the same name is overridden. - *

- * - * @param type - *

- * The type of the assembly. - *

- * @param assemblyName - *

- * The name of the assembly. - *

- * @param row - *

- * The row id. - *

- * @param column - *

- * The column id. - *

- * @return

- * True, if the location of the assembly was set successfully. - *

- */ - public boolean setAssemblyLocation(AssemblyType type, String assemblyName, - int row, int column) { - - // Local declarations - LWRComposite composite = assemblyComposites.get(type); - LWRComponent component = composite.getComponent(assemblyName); - LWRGridManager manager = managers.get(type); - GridLocation location = new GridLocation(row, column); - boolean status = false; - - // Set the location, but only if it is valid. This makes sure that - // negative row numbers and other nasty things were not passed to this - // operation. - if (location.getColumn() == column && location.getRow() == row) { - - // Set the location - manager.addComponent(component, location); - - // Update the status - status = (manager.getComponentName(location) != null && manager - .getComponentName(location).equals(assemblyName)); - } - - return status; - } - - /** - *

- * Removes the assembly at the provided location and of the specified if it - * exists. Returns true if the removal was successful, false otherwise. - *

- * - * @param type - *

- * The type of the assembly. - *

- * @param row - *

- * The row id. - *

- * @param column - *

- * The column id. - *

- * @return

- * True, if the assembly removal was successful. - *

- */ - public boolean removeAssemblyFromLocation(AssemblyType type, int row, - int column) { - - // Local Declarations - LWRGridManager manager = managers.get(type); - boolean status = true; - GridLocation location = new GridLocation(row, column); - String name = manager.getComponentName(location); - - // Only do this if there is a component at the specified location - if (name != null) { - // Remove the component from the location - manager.removeComponent(location); - } else { - status = false; - } - - return status; - } - - /** - *

- * Returns the data provider for the assembly of the specified type at the - * given location or null if it does not exist. - *

- * - * @param type - *

- * The type of the assembly. - *

- * @param row - *

- * The row id. - *

- * @param column - *

- * The column id. - *

- * @return

- * The DataProvider that manages state point data for the specified - * assembly. - *

- */ - public LWRDataProvider getAssemblyDataProviderAtLocation(AssemblyType type, - int row, int column) { - - // Local Declarations - LWRGridManager manager = managers.get(type); - - // Return the provider - return manager.getDataProviderAtLocation(new GridLocation(row, column)); - - } - - /** - *

- * This operation returns the number of assemblies of the specified type. - *

- * - * @param type - *

- * The type of the assembly. - *

- * @return

- * The number of assemblies of the specified type. - *

- */ - public int getNumberOfAssemblies(AssemblyType type) { - return assemblyComposites.get(type).getNumberOfComponents(); - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/PressurizedWaterReactorXMLAdapter.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/PressurizedWaterReactorXMLAdapter.java deleted file mode 100644 index 8b4b2d752..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/PressurizedWaterReactorXMLAdapter.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.pwr; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -/** - * This is a custom XMLAdapter that marshalls PressurizedWaterReactors to a - * string that indicates they are unsupported and unmarshalls them to an empty - * object. - * - * PressurizedWaterReactors are very large classes that represent information - * already stored in an HDF5 file and shouldn't be duplicated. - * - * @author Jay Jay Billings - * - */ -public class PressurizedWaterReactorXMLAdapter extends - XmlAdapter { - - @Override - public PressurizedWaterReactor unmarshal(String v) throws Exception { - // Just return a PWR with 15x15 assemblies - return new PressurizedWaterReactor(15); - } - - @Override - public String marshal(PressurizedWaterReactor v) throws Exception { - // Just return a string noting the lack of support. - return "PWRs are not stored in XML. Please check the HDF5 file."; - } - -} diff --git a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/RodClusterAssembly.java b/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/RodClusterAssembly.java deleted file mode 100644 index b9d043e07..000000000 --- a/org.eclipse.ice.reactor/src/org/eclipse/ice/reactor/pwr/RodClusterAssembly.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactor.pwr; - -import org.eclipse.ice.reactor.HDF5LWRTagType; -import org.eclipse.ice.reactor.ILWRComponentVisitor; - -/** - *

- * The RodClusterAssembly class is a PWRAssembly associated with a particular - * FuelAssembly object. - *

- * - * @author Scott Forest Hull II - */ -public class RodClusterAssembly extends PWRAssembly { - - public RodClusterAssembly(int size) { - // Call super constructor - super(size); - - // Set default names and sizes - this.name = "RodClusterAssembly"; - this.description = "RodClusterAssembly's Description"; - this.id = 1; - - // Setup the LWRComponent to the correct type - this.HDF5LWRTag = HDF5LWRTagType.ROD_CLUSTER_ASSEMBLY; - - } - - /** - *

- * A parameterized Constructor. - *

- * - * @param name - *

- * The name of this RodClusterAssembly. - *

- * @param size - *

- * The size of either dimension of this RodClusterAssembly. - *

- */ - public RodClusterAssembly(String name, int size) { - // Call this constructor - this(size); - - // Check name - this.setName(name); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.pwr.PWRAssembly#equals(java.lang.Object) - */ - @Override - public boolean equals(Object otherObject) { - - // Call super, since no attributes here - - return super.equals(otherObject); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.pwr.PWRAssembly#hashCode() - */ - @Override - public int hashCode() { - - // Call super, since no attributes here - return super.hashCode(); - - } - - /** - *

- * Deep copies the contents of the object. - *

- * - * @param otherObject - *

- * The object to be copied. - *

- */ - public void copy(RodClusterAssembly otherObject) { - - // Call super, since no attributes here - super.copy(otherObject); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.pwr.PWRAssembly#clone() - */ - @Override - public Object clone() { - - // Local Declarations - RodClusterAssembly assembly = new RodClusterAssembly(0); - - // copy contents - assembly.copy(this); - - // Return newly instantiated object - return assembly; - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.reactor.LWRComponent#accept(org.eclipse.ice.reactor.ILWRComponentVisitor) - */ - @Override - public void accept(ILWRComponentVisitor visitor) { - visitor.visit(this); - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer.test/.classpath b/org.eclipse.ice.reactorAnalyzer.test/.classpath deleted file mode 100644 index ad32c83a7..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.reactorAnalyzer.test/.gitignore b/org.eclipse.ice.reactorAnalyzer.test/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.reactorAnalyzer.test/.project b/org.eclipse.ice.reactorAnalyzer.test/.project deleted file mode 100644 index ea4ebbbe1..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.ice.reactorAnalyzer.test - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.reactorAnalyzer.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.reactorAnalyzer.test/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index e272120de..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Sep 12 09:39:00 EDT 2012 -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/org.eclipse.ice.reactorAnalyzer.test/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.reactorAnalyzer.test/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index e9882c669..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Wed Sep 12 09:39:00 EDT 2012 -eclipse.preferences.version=1 -resolve.requirebundle=false -pluginProject.extensions=false diff --git a/org.eclipse.ice.reactorAnalyzer.test/META-INF/MANIFEST.MF b/org.eclipse.ice.reactorAnalyzer.test/META-INF/MANIFEST.MF deleted file mode 100644 index 71ca4f54d..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/META-INF/MANIFEST.MF +++ /dev/null @@ -1,10 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: ReactorAnalyzerTest -Bundle-SymbolicName: org.eclipse.ice.reactorAnalyzer.test -Bundle-Version: 2.1.8 -Fragment-Host: org.eclipse.ice.reactorAnalyzer;bundle-version="2.0.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: org.junit;bundle-version="4.8.2" -Import-Package: org.eclipse.ice.datastructures.ICEObject -Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.reactorAnalyzer.test/about.html b/org.eclipse.ice.reactorAnalyzer.test/about.html deleted file mode 100644 index b47b18406..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

July 1, 2014

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer.test/build.properties b/org.eclipse.ice.reactorAnalyzer.test/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/org.eclipse.ice.reactorAnalyzer.test/pom.xml b/org.eclipse.ice.reactorAnalyzer.test/pom.xml deleted file mode 100644 index d29128e56..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.reactorAnalyzer.test - eclipse-test-plugin - - true - - diff --git a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/FakeAnalysisAsset.java b/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/FakeAnalysisAsset.java deleted file mode 100644 index 8ccfc729c..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/FakeAnalysisAsset.java +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer.test; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Properties; - -import org.eclipse.ice.analysistool.AnalysisAssetType; -import org.eclipse.ice.analysistool.IAnalysisAsset; -import org.eclipse.ice.datastructures.form.Entry; - -/** - *

- * A fake implementation of IAnalysisAsset that does not require any external - * capabilities to run. It is used to test the ReactorAnalyzerBuilder and the - * ReactorAnalyzer in a lightweight fashion. - *

- * - * @author Jay Jay Billings - */ -public class FakeAnalysisAsset implements IAnalysisAsset { - /** - *

- * True if the properties of the asset were updated, false otherwise. - *

- * - */ - private boolean propertiesUpdated; - - /** - *

- * This operation resets the FakeAnalysisAsset to its initial state. - *

- * - */ - public void reset() { - // TODO Auto-generated method stub - - } - - /** - *

- * True if the properties of this asset were updated, false otherwise. - *

- * - * @return

- * True if the properties were updated, false otherwise. - *

- */ - public boolean propertiesUpdated() { - // TODO Auto-generated method stub - return false; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisAsset#getName() - */ - @Override - public String getName() { - // TODO Auto-generated method stub - return null; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisAsset#getType() - */ - @Override - public AnalysisAssetType getType() { - // TODO Auto-generated method stub - return null; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisAsset#getProperty(String key) - */ - @Override - public String getProperty(String key) { - // TODO Auto-generated method stub - return null; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisAsset#setProperty(String key, String value) - */ - @Override - public boolean setProperty(String key, String value) { - // TODO Auto-generated method stub - return false; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisAsset#resetProperties() - */ - @Override - public void resetProperties() { - // TODO Auto-generated method stub - - } - - /** - * (non-Javadoc) - * - * @see IAnalysisAsset#getProperties() - */ - @Override - public Properties getProperties() { - // TODO Auto-generated method stub - return null; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisAsset#getURI() - */ - @Override - public URI getURI() { - // TODO Auto-generated method stub - return null; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisAsset#getPropertiesAsEntryList() - */ - @Override - public ArrayList getPropertiesAsEntryList() { - // TODO Auto-generated method stub - return null; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/FakeAnalysisDocument.java b/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/FakeAnalysisDocument.java deleted file mode 100644 index 4cc0fcca7..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/FakeAnalysisDocument.java +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer.test; - -import java.net.URI; -import java.util.ArrayList; - -import org.eclipse.ice.analysistool.IAnalysisAsset; -import org.eclipse.ice.analysistool.IAnalysisDocument; -import org.eclipse.ice.analysistool.IDataProvider; - -/** - *

- * A fake implementation of IAnalysisDocument that does not require any external - * capabilities to run. It is used to test the ReactorAnalyzerBuilder and the - * ReactorAnalyzer in a lightweight fashion. - *

- * - * @author Jay Jay Billings - */ -public class FakeAnalysisDocument implements IAnalysisDocument { - /** - *

- * True if assets were created for a client, false otherwise. - *

- * - */ - private boolean assetsCreated; - /** - *

- * The asset that is returned by this document for testing. - *

- * - */ - private FakeAnalysisAsset asset; - - /** - *

- * This operation resets the FakeAnalysisDocument to its initial state. - *

- * - */ - public void reset() { - - // Reset attributes - asset = null; - assetsCreated = false; - - return; - - } - - /** - *

- * This operation returns true if assets were created by the - * FakeAnalysisDocument and false otherwise. - *

- * - * @return

- * True if assets were created, false otherwise. - *

- */ - public boolean assetsCreated() { - return assetsCreated; - } - - /** - *

- * This operation returns the last FakeAnalysisAsset created by this - * document so that it can be checked in the test. - *

- * - * @return

- * The asset used by this FakeAnalysisDocument to fake out the - * ReactorAnalyzer. - *

- */ - public FakeAnalysisAsset getAsset() { - return asset; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#loadData(URI data) - */ - @Override - public boolean loadData(URI data) { - - return true; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#getData() - */ - @Override - public URI getData() { - return null; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#getAvailableAssets() - */ - @Override - public ArrayList getAvailableAssets() { - - // Local Declarations - ArrayList assetTypes = new ArrayList(); - - // Setup up some fake analysis types - assetTypes.add("Analyze deflector grid performance"); - assetTypes.add("Plot warp core plasma temperate vs. time"); - assetTypes.add("Show holo-emitter buffer contents"); - - return assetTypes; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#getSelectedAssets() - */ - @Override - public ArrayList getSelectedAssets() { - // TODO Auto-generated method stub - return null; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#setSelectedAssets(ArrayList assets) - */ - @Override - public void setSelectedAssets(ArrayList assets) { - - return; - - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#createSelectedAssets() - */ - @Override - public void createSelectedAssets() { - - return; - - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#getTotalSlices() - */ - @Override - public int getTotalSlices() { - return 0; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#getSliceIdentifier(int sliceNumber) - */ - @Override - public String getSliceIdentifier(int sliceNumber) { - return String.valueOf(sliceNumber); - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#getAssetsAtSlice(int sliceNumber) - */ - @Override - public ArrayList getAssetsAtSlice(int sliceNumber) { - - // Local Declaration - ArrayList assets = new ArrayList(); - - // Create the document if necessary - if (asset == null) { - asset = new FakeAnalysisAsset(); - } - // Setup the list - assets.add(asset); - - return assets; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisDocument#getAllAssets() - */ - @Override - public ArrayList getAllAssets() { - - // Local Declaration - ArrayList assets = new ArrayList(); - - // Create the document if necessary - if (asset == null) { - asset = new FakeAnalysisAsset(); - } - // Setup the list - assets.add(asset); - - return assets; - } - - @Override - public boolean loadData(IDataProvider data) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean loadReferenceData(URI data) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean loadReferenceData(IDataProvider data) { - // TODO Auto-generated method stub - return false; - } - - @Override - public URI getReferenceData() { - // TODO Auto-generated method stub - return null; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/FakeAnalysisTool.java b/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/FakeAnalysisTool.java deleted file mode 100644 index ec813c744..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/FakeAnalysisTool.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer.test; - -import java.net.URI; - -import org.eclipse.ice.analysistool.IAnalysisDocument; -import org.eclipse.ice.analysistool.IAnalysisTool; -import org.eclipse.ice.analysistool.IDataProvider; - -/** - *

- * A fake implementation of IAnalysisTool that does not require any external - * capabilities to run. It is used to test the ReactorAnalyzerBuilder and the - * ReactorAnalyzer in a lightweight fashion. - *

- * - * @author Jay Jay Billings - */ -public class FakeAnalysisTool implements IAnalysisTool { - /** - *

- * True if the document was created, false otherwise. - *

- * - */ - private boolean documentCreated; - /** - *

- * A reference to the FakeAnalysisDocument that is fed to clients by this - * FakeAnalysisTool. - *

- * - */ - private FakeAnalysisDocument analysisDoc; - - /** - *

- * This operation resets the FakeAnalysisTool to its initial state. - *

- * - */ - public void reset() { - - // Perform a factory reset. ;) - analysisDoc = null; - documentCreated = false; - - } - - /** - *

- * True if the IAnalysisDocument was retrieved, false otherwise. - *

- * - * @return - */ - public boolean documentRetrieved() { - return documentCreated; - } - - /** - *

- * This operation returns the FakeAnalysisDocument that was delivered by the - * FakeAnalysisTool. - *

- * - * @return

- * The FakeAnalysisDocument used to fake out the ReactorAnalyzer. - *

- */ - public FakeAnalysisDocument getDocument() { - - return analysisDoc; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisTool#close() - */ - @Override - public Boolean close() { - // TODO Auto-generated method stub - return true; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisTool#getName() - */ - @Override - public String getName() { - return "Fake Analysis Tool"; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisTool#getVersion() - */ - @Override - public String getVersion() { - return "1.0.0"; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisTool#createDocument(URI data) - */ - @Override - public IAnalysisDocument createDocument(URI data) { - - // Create the document if necessary - if (analysisDoc == null) { - analysisDoc = new FakeAnalysisDocument(); - } - - return analysisDoc; - } - - /** - * (non-Javadoc) - * - * @see IAnalysisTool#isReady() - */ - @Override - public boolean isReady() { - return true; - } - - @Override - public IAnalysisDocument createDocument(IDataProvider data) { - // TODO Auto-generated method stub - return null; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/ReactorAnalyzerBuilderTester.java b/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/ReactorAnalyzerBuilderTester.java deleted file mode 100644 index 1640f51aa..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/ReactorAnalyzerBuilderTester.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ice.item.Item; -import org.eclipse.ice.item.ItemType; -import org.eclipse.ice.reactorAnalyzer.ReactorAnalyzer; -import org.eclipse.ice.reactorAnalyzer.ReactorAnalyzerBuilder; -import org.junit.Test; - -/** - * - * @author Jay Jay Billings - */ -public class ReactorAnalyzerBuilderTester { - /** - *

- * The instance of the ReactorAnalyzerBuilder that will be tested. - *

- * - */ - private ReactorAnalyzerBuilder reactorAnalyzerBuilder; - - /** - *

- * The fake implementation of IAnalysisTool that is used to trick the - * ReactorAnalyzerBuilder into building without loading heavyweight - * components. - *

- * - */ - private FakeAnalysisTool fakeAnalysisTool; - - /** - *

- * This operation checks that the ReactorAnalyzerBuilder will create and - * return a fully initialized ReactorAnalyzer if and only if an analysis - * tools has been set. It also checks the name and type of the builder. - *

- * - */ - @Test - public void checkBuilding() { - - // Local Declarations - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - URI defaultProjectLocation = null; - IProject project = null; - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator - + "reactorAnalyzerBuilderTesterWorkspace"; - String filename = null; - fakeAnalysisTool = new FakeAnalysisTool(); - - // Setup the project workspace - try { - // Get the project handle - project = workspaceRoot - .getProject("reactorAnalyzerBuilderTesterWorkspace"); - // If the project does not exist, create it - if (!project.exists()) { - // Set the location as ${workspace_loc}/ItemTesterWorkspace - defaultProjectLocation = (new File(userDir)).toURI(); - // Create the project description - IProjectDescription desc = ResourcesPlugin.getWorkspace() - .newProjectDescription( - "reactorAnalyzerBuilderTesterWorkspace"); - // Set the location of the project - desc.setLocationURI(defaultProjectLocation); - // Create the project - project.create(desc, null); - } - // Open the project if it is not already open - if (project.exists() && !project.isOpen()) { - project.open(null); - } - } catch (CoreException e) { - // Catch for creating the project - e.printStackTrace(); - fail(); - } - - // Instantiate the builder - reactorAnalyzerBuilder = new ReactorAnalyzerBuilder(); - - // Check the name - the static value, the getter and the comparison of - // the two - assertEquals("Reactor Analyzer", reactorAnalyzerBuilder.name); - assertEquals("Reactor Analyzer", reactorAnalyzerBuilder.getItemName()); - assertEquals(reactorAnalyzerBuilder.name, - reactorAnalyzerBuilder.getItemName()); - - // Check the type - the static value, the getter and the comparison of - // the two - assertEquals(ItemType.AnalysisSession, reactorAnalyzerBuilder.type); - assertEquals(ItemType.AnalysisSession, - reactorAnalyzerBuilder.getItemType()); - assertEquals(reactorAnalyzerBuilder.type, - reactorAnalyzerBuilder.getItemType()); - - // Set a FakeAnalysisTool as an analysis tool and make sure construction - // works properly - reactorAnalyzerBuilder.addAnalysisTool(fakeAnalysisTool); - Item analyzer = reactorAnalyzerBuilder.build(project); - assertNotNull(analyzer); - assertTrue(analyzer instanceof ReactorAnalyzer); - assertEquals("Reactor Analyzer", analyzer.getName()); - assertEquals(ItemType.AnalysisSession, analyzer.getItemType()); - assertEquals(reactorAnalyzerBuilder.getItemName(), - analyzer.getItemBuilderName()); - - return; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/ReactorAnalyzerTester.java b/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/ReactorAnalyzerTester.java deleted file mode 100644 index d4677c706..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/ReactorAnalyzerTester.java +++ /dev/null @@ -1,481 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.util.ArrayList; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ice.analysistool.IAnalysisTool; -import org.eclipse.ice.datastructures.form.DataComponent; -import org.eclipse.ice.datastructures.form.Entry; -import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.form.FormStatus; -import org.eclipse.ice.datastructures.form.MasterDetailsComponent; -import org.eclipse.ice.datastructures.form.ResourceComponent; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.ice.reactorAnalyzer.ReactorAnalyzer; -import org.eclipse.ice.reactorAnalyzer.ReactorAnalyzerBuilder; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -/** - *

- * This class is responsible for testing the ReactorAnalyzer. - *

- *

- * This is a complicated series of tests, but the coverage is still relatively - * high. The tester creates and accesses a project, checks the ReactorAnalyzer's - * Form, tries to invoke a review, processing and resubmits for a second review. - *

- *

- * In general it is a very bad idea to string together separate tests. However, - * because of the amount of work involved in arriving at any particular point in - * the Item workflow, the tests in this class build on the results of the - * previous tests. - *

- * - * @author Jay Jay Billings - */ -public class ReactorAnalyzerTester { - // FIXME These tests need to be updated. However, the ReactorAnalyzer will - // be undergoing a LOT of changes soon. - - /** - *

- * The instance of ReactorAnalyzer that will be tested. - *

- * - */ - private static ReactorAnalyzer reactorAnalyzer; - - /** - *

- * The fake implementation of IAnalysisTool that is used to trick the - * ReactorAnalyzer without loading heavyweight components. - *

- * - */ - private static FakeAnalysisTool fakeAnalysisTool; - /** - *

- * The fake implementation of IAnalysisDocument that is used to trick the - * ReactorAnalyzer without loading heavyweight components. - *

- * - */ - private static FakeAnalysisDocument fakeAnalysisDocument; - /** - *

- * The fake implementation of IAnalysisAsset that is used to trick the - * ReactorAnalyzer without loading heavyweight components. - *

- * - */ - private static FakeAnalysisAsset fakeAnalysisAsset; - - /** - *

- * The Eclipse Resources Project Space used for the tests. - *

- * - */ - private static IProject projectSpace; - - /** - *

- * This operations sets up the workspace for an instantiates a - * ReactorAnalyzer for testing. - *

- * - */ - @BeforeClass - public static void BeforeClass() { - - // Local Declarations - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - URI defaultProjectLocation = null; - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + "reactorAnalyzerTesterWorkspace"; - - // Initialize fake analysis tool - fakeAnalysisTool = new FakeAnalysisTool(); - - // Set null values for the other fakes so that they must be updated - fakeAnalysisDocument = null; - fakeAnalysisAsset = null; - - // Setup the project workspace - try { - // Get the project handle - projectSpace = workspaceRoot - .getProject("reactorAnalyzerTesterWorkspace"); - // If the project does not exist, create it - if (!projectSpace.exists()) { - // Set the location as ${workspace_loc}/ItemTesterWorkspace - defaultProjectLocation = (new File(userDir)).toURI(); - // Create the project description - IProjectDescription desc = ResourcesPlugin - .getWorkspace() - .newProjectDescription("reactorAnalyzerTesterWorkspace"); - // Set the location of the project - desc.setLocationURI(defaultProjectLocation); - // Create the project - projectSpace.create(desc, null); - } - // Open the project if it is not already open - if (projectSpace.exists() && !projectSpace.isOpen()) { - projectSpace.open(null); - } - } catch (CoreException e) { - // Catch for creating the project - e.printStackTrace(); - fail(); - } - - return; - - } - - /** - *

- * This operation checks the construction of the ReactorAnalyzer to ensure - * that its Form was created according to the specification on the class. - *

- * - */ - @Test - public void checkConstruction() { - - // Make the ReactorAnalyzer - reactorAnalyzer = new ReactorAnalyzer(projectSpace); - // Set the name - reactorAnalyzer.setName(ReactorAnalyzerBuilder.name); - // Set the analysis tools - ArrayList tools = new ArrayList(); - tools.add(fakeAnalysisTool); - reactorAnalyzer.setAnalysisTools(tools); - - // Get the Form - Form form = reactorAnalyzer.getForm(); - - // Check the form's components - assertNotNull(form); - assertNotNull(form.getComponents()); - assertEquals(4, form.getComponents().size()); - - // The Components of the ReactorAnalyzer's Form are very specifically - // identified in the ReactorAnalyzer documentation. Check the - // DataComponent that identifies the data files. - assertTrue(form.getComponent(1) instanceof DataComponent); - DataComponent dataComponent = (DataComponent) form.getComponent(1); - assertEquals(dataComponent.getId(), 1); - assertEquals(dataComponent.getName(), "Data Sources"); - - // Also make sure that there are available data sources to select - Entry dataSources = dataComponent.retrieveEntry("Input Data"); - assertNotNull(dataSources); - assertEquals("Input Data", dataSources.getName()); - assertEquals(1, dataSources.getId()); - assertTrue(dataSources.getAllowedValues().contains("globe.silo")); - - // Check the reference data sources - Entry referenceSources = dataComponent.retrieveEntry("Reference Data"); - assertNotNull(referenceSources); - assertEquals("Reference Data", referenceSources.getName()); - assertEquals(2, referenceSources.getId()); - assertTrue(referenceSources.getAllowedValues().contains("globe.silo")); - - // Now check the ResourceComponent - assertTrue(form.getComponent(2) instanceof ResourceComponent); - ResourceComponent resourceComponent = (ResourceComponent) form - .getComponent(2); - assertEquals(resourceComponent.getId(), 2); - assertEquals(resourceComponent.getName(), "Analysis Artifacts"); - // The resource component should have no resources yet - assertEquals(resourceComponent.getResources().size(), 0); - - // Check for the MasterDetailsComponent. - assertTrue(form.getComponent(3) instanceof MasterDetailsComponent); - MasterDetailsComponent masterDetailsComponent = (MasterDetailsComponent) form - .getComponent(3); - assertEquals(masterDetailsComponent.getId(), 3); - assertEquals(masterDetailsComponent.getName(), "Analysis Configuration"); - - // At this point, there should be no masters in the component because no - // data sources has been configured with which to populate the - // component. - assertEquals(null, masterDetailsComponent.getAllowedMasterValues()); - - return; - - } - - /** - *

- * This operation selects a data source on the Form, submits it and confirms - * that the MasterDetailsComponent has been updated with selected asset - * types. Finally, it chooses some assets to create, submits the Form and - * checks that ReactorAnalyzer.getStatus().equals(FormStatus.ReadyToProcess) - * is true. - *

- * - */ - @Ignore - @Test - public void checkDataSourceReview() { - - // Make the ReactorAnalyzer - reactorAnalyzer = new ReactorAnalyzer(projectSpace); - // Set the name - reactorAnalyzer.setName(ReactorAnalyzerBuilder.name); - // Set the analysis tools - ArrayList tools = new ArrayList(); - tools.add(fakeAnalysisTool); - reactorAnalyzer.setAnalysisTools(tools); - - // Configure the form - Form form = configureAnalyzerForm(); - - // Submit the Form and check the status - FormStatus status = reactorAnalyzer.submitForm(form); - assertEquals(FormStatus.ReadyToProcess, status); - - return; - - } - - private Form configureAnalyzerForm() { - - // Get the Form - Form form = reactorAnalyzer.getForm(); - - // Check the MasterDetailsComponent to make sure that some selections - // are available - MasterDetailsComponent masterDetailsComponent = (MasterDetailsComponent) form - .getComponent(3); - - // Get the global data component - DataComponent sourceData = (DataComponent) form.getComponent(1); - - // Make a selection - sourceData.retrieveEntry("Input Data").setValue("globe.silo"); - - // Resubmit the Form - reactorAnalyzer.submitForm(form); - - // Retrieve the MasterDetailsComponent since it should have been - // re-created to initialize the values. - masterDetailsComponent = (MasterDetailsComponent) form.getComponent(3); - - // Add a master to the MasterDetailsComponent. - int masterId = masterDetailsComponent.addMaster(); - ArrayList masterValues = masterDetailsComponent - .getAllowedMasterValues(); - assertNotNull(masterValues); - assertTrue(masterValues.size() > 0); - - // Edit the details of the MasterDetailsComponent to make a selection - masterDetailsComponent.setMasterInstanceValue(masterId, - masterValues.get(0)); - - return form; - } - - /** - *

- * This operation directs the ReactorAnalyzer to create the selected assets. - *

- * - */ - @Ignore - @Test - public void checkProcessing() { - - // Make the ReactorAnalyzer - reactorAnalyzer = new ReactorAnalyzer(projectSpace); - // Set the name - reactorAnalyzer.setName(ReactorAnalyzerBuilder.name); - // Set the analysis tools - ArrayList tools = new ArrayList(); - tools.add(fakeAnalysisTool); - reactorAnalyzer.setAnalysisTools(tools); - - // Configure the Form - Form form = configureAnalyzerForm(); - - // Submit it - reactorAnalyzer.submitForm(form); - - // Since the Form has already been submitted, check the status and make - // sure it is ready to process. - assertEquals(FormStatus.ReadyToProcess, reactorAnalyzer.getStatus()); - - // Direct the ReactorAnalyzer to process the Form - FormStatus status = reactorAnalyzer - .process("Generate Analysis Artifacts"); - assertEquals(FormStatus.Processing, reactorAnalyzer.getStatus()); - - // Wait until the Item is done and make sure the process is - // FormStatus.Processed. - while (reactorAnalyzer.getStatus().equals(FormStatus.Processing)) { - // Wait a little bit - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - assertEquals(FormStatus.Processed, reactorAnalyzer.getStatus()); - - // Check the ResourceComponent - form = reactorAnalyzer.getForm(); - ResourceComponent resourceComp = (ResourceComponent) form - .getComponent(2); - assertNotNull(resourceComp); - - // Get the MasterDetailsComponent component from the form - MasterDetailsComponent analysisConfigComp = (MasterDetailsComponent) form - .getComponent(3); - - // Get the list of resources from the ResourceComponent - ArrayList resources = resourceComp.getResources(); - - // Check the resource list - assertNotNull(resources); - assertTrue(resources.size() > 0); - assertEquals(analysisConfigComp.numberOfMasters(), resources.size()); - - // Loop over each resource - for (int i = 0; i < resources.size(); i++) { - - // Get a resource - ICEResource resource = resources.get(i); - - // Test its properties - assertEquals(resource.getId(), i); - } - - // Try directing the Item to process with an unacceptable action name - assertEquals(FormStatus.InfoError, - reactorAnalyzer.process("Beam me up.")); - - return; - - } - - /** - *

- * This operation checks the ability of the ReactorAnalyzer to update the - * properties of an asset when its properties are changed. - *

- * - */ - public void checkProperties() { - // TODO Auto-generated method stub - - } - - /** - *

- * This operation checks the ability of the ReactorAnalyzer to change data - * sources when so directed by a client. - *

- * - */ - @Ignore - @Test - public void checkResubmit() { - - // Make the ReactorAnalyzer - reactorAnalyzer = new ReactorAnalyzer(projectSpace); - // Set the name - reactorAnalyzer.setName(ReactorAnalyzerBuilder.name); - // Set the analysis tools - ArrayList tools = new ArrayList(); - tools.add(fakeAnalysisTool); - reactorAnalyzer.setAnalysisTools(tools); - - // Get the Form - Form form = reactorAnalyzer.getForm(); - - // Check the MasterDetailsComponent to make sure that some selections - // are available - MasterDetailsComponent masterDetailsComponent = (MasterDetailsComponent) form - .getComponent(3); - - // Get the global data component - DataComponent sourceData = (DataComponent) form.getComponent(1); - - // Make a selection - sourceData.retrieveEntry("Input Data").setValue("globe.silo"); - - // Resubmit the Form - reactorAnalyzer.submitForm(form); - - // Retrieve the new form - form = reactorAnalyzer.getForm(); - - // Retrieve the MasterDetailsComponent since it should have been - // re-created to initialize the values. - masterDetailsComponent = (MasterDetailsComponent) form.getComponent(3); - ArrayList masterValues = masterDetailsComponent - .getAllowedMasterValues(); - assertNotNull(masterValues); - assertTrue(masterValues.size() > 0); - - // Add a master to the MasterDetailsComponent. - int masterId = masterDetailsComponent.addMaster(); - - // Edit the details of the MasterDetailsComponent to make a selection - masterDetailsComponent.setMasterInstanceValue(masterId, - masterValues.get(0)); - - // Check that a selection was made - assertEquals(masterDetailsComponent.numberOfMasters(), 1); - - // Make a selection - sourceData = (DataComponent) form.getComponent(1); - sourceData.retrieveEntry("Input Data").setValue("AMPData.silo"); - - // Resubmit the form - reactorAnalyzer.submitForm(form); - - // Retrieve the new form - form = reactorAnalyzer.getForm(); - - // Retrieve the MasterDetailsComponent since it should have been - // re-created to initialize the values. - masterDetailsComponent = (MasterDetailsComponent) form.getComponent(3); - masterValues = masterDetailsComponent.getAllowedMasterValues(); - assertTrue(masterValues.size() > 0); - - // Check that the selection was cleared - assertEquals(0, masterDetailsComponent.numberOfMasters()); - - return; - - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/ReactorReaderFactoryTester.java b/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/ReactorReaderFactoryTester.java deleted file mode 100644 index f1c4fbe10..000000000 --- a/org.eclipse.ice.reactorAnalyzer.test/src/org/eclipse/ice/reactorAnalyzer/test/ReactorReaderFactoryTester.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer.test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; - -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.reactor.LWRComponentWriter; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.eclipse.ice.reactor.sfr.base.SFReactorIOHandler; -import org.eclipse.ice.reactor.sfr.core.SFReactor; -import org.eclipse.ice.reactorAnalyzer.ReactorReaderFactory; -import org.junit.Test; - -public class ReactorReaderFactoryTester { - - @Test - public void checkReading() { - - // Initialize a factory. - ReactorReaderFactory factory = new ReactorReaderFactory(); - - // Set up some URIs in the test folder. - String separator = System.getProperty("file.separator"); - String directory = System.getProperty("user.home") + separator - + "ICETests" + separator + "reactorReaderTesterWorkspace"; - URI badURI = new File(directory + separator + "doesNotExist.h5").toURI(); - - // Bad URIs shouldn't work. - assertNull(factory.readReactor(null)); - assertNull(factory.readReactor(badURI)); - - // Test valid URIs. - IReactorComponent reactor; - IReactorComponent loadedReactor; - LWRComponentWriter lwrWriter = new LWRComponentWriter(); - SFReactorIOHandler sfrWriter = new SFReactorIOHandler(); - File file; - URI uri; - - /* ---- Test LWR functionality. ---- */ - // Generate and write a simple reactor. - reactor = new PressurizedWaterReactor(4); - file = new File(directory + "simpleLWR.h5"); - uri = file.toURI(); - lwrWriter.write((PressurizedWaterReactor) reactor, uri); - - // Use the factory to read the reactor. - loadedReactor = factory.readReactor(uri); - - // Verify that they are equivalent. - assertTrue(reactor.equals(loadedReactor)); - - // Delete the file that was just created. - try { - file.delete(); - } catch (Exception e) { - System.err - .println("ReactorReaderFactoryTester error: Could not delete file \"" - + file.getAbsolutePath() + "\"."); - fail(); - } - /* --------------------------------- */ - - /* ---- Test SFR functionality. ---- */ - // Generate and write a simple reactor. - reactor = new SFReactor(4); - file = new File(directory + "simpleSFR.h5"); - uri = file.toURI(); - sfrWriter.writeHDF5(uri, (SFReactor) reactor); - - // Use the factory to read the reactor. - loadedReactor = factory.readReactor(uri); - - // Verify that they are equivalent. - assertTrue(reactor.equals(loadedReactor)); - - // Delete the file that was just created. - try { - file.delete(); - } catch (Exception e) { - System.err - .println("ReactorReaderFactoryTester error: Could not delete file \"" - + file.getAbsolutePath() + "\"."); - fail(); - } - /* --------------------------------- */ - - return; - } - - @Test - public void checkCopying() { - - // Initialize a factory. - ReactorReaderFactory factory = new ReactorReaderFactory(); - - // We need a source and destination. - IReactorComponent source = null; - IReactorComponent destination = null; - - /* ---- Can't copy if either are null. ---- */ - assertFalse(factory.copyReactor(source, destination)); - assertNull(source); - assertNull(destination); - - source = new PressurizedWaterReactor(1); - destination = null; - assertFalse(factory.copyReactor(source, destination)); - assertNotNull(source); - assertNull(destination); - - source = null; - destination = new PressurizedWaterReactor(2); - assertFalse(factory.copyReactor(source, destination)); - assertNull(source); - assertNotNull(destination); - /* ---------------------------------------- */ - - /* ---- Can't copy if they are different types. --- */ - source = new PressurizedWaterReactor(3); - destination = new SFReactor(4); - - assertFalse(factory.copyReactor(source, destination)); - assertTrue(source instanceof PressurizedWaterReactor); - assertTrue(destination instanceof SFReactor); - /* ------------------------------------------------ */ - - /* ---- Can copy if they are the same type. ---- */ - // Test PWRs. - source = new PressurizedWaterReactor(1); - source.setName("Spike Spiegel"); - source.setDescription("Just a wandering cowboy."); - - destination = new PressurizedWaterReactor(2); - destination.setName("Faye Valentine"); - destination.setDescription("Already a fairy."); - - assertFalse(source.equals(destination)); - assertTrue(factory.copyReactor(source, destination)); - assertTrue(source.equals(destination)); - - // Test SFRs. - source = new SFReactor(3); - source.setName("Jet Black"); - source.setDescription("The Black Dog."); - - destination = new SFReactor(4); - destination.setName("Ed"); - destination.setDescription("Hacker extraordinaire."); - - assertFalse(source.equals(destination)); - assertTrue(factory.copyReactor(source, destination)); - assertTrue(source.equals(destination)); - /* --------------------------------------------- */ - - return; - } -} diff --git a/org.eclipse.ice.reactorAnalyzer/.classpath b/org.eclipse.ice.reactorAnalyzer/.classpath deleted file mode 100644 index ad32c83a7..000000000 --- a/org.eclipse.ice.reactorAnalyzer/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.reactorAnalyzer/.gitignore b/org.eclipse.ice.reactorAnalyzer/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.reactorAnalyzer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.reactorAnalyzer/.project b/org.eclipse.ice.reactorAnalyzer/.project deleted file mode 100644 index 3c9cbacc1..000000000 --- a/org.eclipse.ice.reactorAnalyzer/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - org.eclipse.ice.reactorAnalyzer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.reactorAnalyzer/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.reactorAnalyzer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 337c974fd..000000000 --- a/org.eclipse.ice.reactorAnalyzer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Sep 12 08:53:58 EDT 2012 -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/org.eclipse.ice.reactorAnalyzer/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.reactorAnalyzer/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index b5bc40574..000000000 --- a/org.eclipse.ice.reactorAnalyzer/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Wed Sep 12 08:53:58 EDT 2012 -eclipse.preferences.version=1 -resolve.requirebundle=false -pluginProject.extensions=false diff --git a/org.eclipse.ice.reactorAnalyzer/META-INF/MANIFEST.MF b/org.eclipse.ice.reactorAnalyzer/META-INF/MANIFEST.MF deleted file mode 100644 index b0eacd06d..000000000 --- a/org.eclipse.ice.reactorAnalyzer/META-INF/MANIFEST.MF +++ /dev/null @@ -1,39 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: ReactorAnalyzer -Bundle-SymbolicName: org.eclipse.ice.reactorAnalyzer;singleton:=true -Bundle-Version: 2.1.8 -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Import-Package: ncsa.hdf.hdf5lib, - ncsa.hdf.hdf5lib.callbacks, - ncsa.hdf.hdf5lib.exceptions, - ncsa.hdf.hdf5lib.structs, - ncsa.hdf.hdflib, - ncsa.hdf.object, - ncsa.hdf.object.fits, - ncsa.hdf.object.h4, - ncsa.hdf.object.h5, - ncsa.hdf.object.nc2, - org.eclipse.core.resources, - org.eclipse.ice.analysistool, - org.eclipse.ice.datastructures.ICEObject, - org.eclipse.ice.datastructures.componentVisitor, - org.eclipse.ice.datastructures.form, - org.eclipse.ice.datastructures.form.geometry, - org.eclipse.ice.datastructures.form.painfullySimpleForm, - org.eclipse.ice.datastructures.resource, - org.eclipse.ice.item, - org.eclipse.ice.reactor.sfr.base, - org.eclipse.ice.reactor.sfr.core, - org.eclipse.ice.reactor.sfr.core.assembly, - org.eclipse.ice.viz.service.datastructures, - org.eclipse.ice.viz.service.mesh.datastructures, - org.slf4j;version="1.7.2" -Require-Bundle: org.eclipse.core.resources;bundle-version="3.7.101", - org.eclipse.core.runtime;bundle-version="3.7.0", - org.eclipse.ice.datastructures, - org.eclipse.ice.reactor;bundle-version="2.0.0" -Service-Component: OSGi-INF/reactorAnalyzerComponent.xml -Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.ice.reactorAnalyzer -Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.reactorAnalyzer/OSGi-INF/reactorAnalyzerComponent.xml b/org.eclipse.ice.reactorAnalyzer/OSGi-INF/reactorAnalyzerComponent.xml deleted file mode 100644 index 4cbea08c9..000000000 --- a/org.eclipse.ice.reactorAnalyzer/OSGi-INF/reactorAnalyzerComponent.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/org.eclipse.ice.reactorAnalyzer/about.html b/org.eclipse.ice.reactorAnalyzer/about.html deleted file mode 100644 index b47b18406..000000000 --- a/org.eclipse.ice.reactorAnalyzer/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

July 1, 2014

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer/build.properties b/org.eclipse.ice.reactorAnalyzer/build.properties deleted file mode 100644 index 093c9dabc..000000000 --- a/org.eclipse.ice.reactorAnalyzer/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -bin.includes = META-INF/,\ - .,\ - OSGi-INF/reactorAnalyzerComponent.xml,\ - plugin.xml -output.. = bin/ -source.. = src/ diff --git a/org.eclipse.ice.reactorAnalyzer/plugin.xml b/org.eclipse.ice.reactorAnalyzer/plugin.xml deleted file mode 100644 index 2cf7d87f6..000000000 --- a/org.eclipse.ice.reactorAnalyzer/plugin.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/org.eclipse.ice.reactorAnalyzer/pom.xml b/org.eclipse.ice.reactorAnalyzer/pom.xml deleted file mode 100644 index a3c5ad934..000000000 --- a/org.eclipse.ice.reactorAnalyzer/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.reactorAnalyzer - eclipse-plugin - \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorAnalyzer.java b/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorAnalyzer.java deleted file mode 100644 index 80953610f..000000000 --- a/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorAnalyzer.java +++ /dev/null @@ -1,958 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicReference; - -import javax.xml.bind.annotation.XmlRootElement; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ice.analysistool.IAnalysisAsset; -import org.eclipse.ice.analysistool.IAnalysisDocument; -import org.eclipse.ice.analysistool.IAnalysisTool; -import org.eclipse.ice.analysistool.IData; -import org.eclipse.ice.analysistool.IDataProvider; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.form.AllowedValueType; -import org.eclipse.ice.datastructures.form.DataComponent; -import org.eclipse.ice.datastructures.form.Entry; -import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.form.FormStatus; -import org.eclipse.ice.datastructures.form.MasterDetailsComponent; -import org.eclipse.ice.datastructures.form.MasterDetailsPair; -import org.eclipse.ice.datastructures.form.ResourceComponent; -import org.eclipse.ice.datastructures.resource.ICEResource; -import org.eclipse.ice.item.Item; -import org.eclipse.ice.item.ItemType; -import org.eclipse.ice.reactor.AssemblyType; -import org.eclipse.ice.reactor.LWRData; -import org.eclipse.ice.reactor.LWRDataProvider; -import org.eclipse.ice.reactor.pwr.FuelAssembly; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; - -/** - *

- * The ReactorAnalyzer class is the primary class in ICE for analyzing data - * produced as part of a reactor simulation. - *

- *

- * The Form for this Item contains a
- *
- * Data Component ("Data Sources" with id=1), a
- * ResourceComponent ("Analysis Artifacts" with id = 2), and a
- * MasterDetailsComponent ("Analysis Configuration" with id = 3).
- *
- * The MasterDetailsComponent is used to select the types of analyses that - * should be performed and set their properties. (It is a little more like - * picking the types of artifacts that should be created, but close enough.) - *

- *

- * The "Data Sources" component contains two Entries named "Input Data" with - * id=1 and "Reference Data" with id = 2. - *

- *

- * The ResourceComponent is initially empty, but directing the ReactorAnalyzer - * to generate artifacts populates the ResourceComponent with those artifacts. - * The ResourceComponent is monitored for changes and the artifacts are updated - * on the fly. The ResourceComponent is named "Analysis Artifacts" and has id=2. - *

- * - * @author Jay Jay Billings - */ -@XmlRootElement(name = "ReactorAnalyzer") -public class ReactorAnalyzer extends Item implements Runnable { - - /** - *

- * The set of IAnalysisTools available to the ReactorAnalyzer. If this list - * does not contain any tools, the ReactorAnalyzer can not perform any - * analysis operations. - *

- * - */ - private ArrayList analysisTools; - /** - *

- * A reference to the IAnalysisDocuments used by the ReactorAnalyzer. - *

- * - */ - private ArrayList analysisDocuments; - /** - *

- * An AtomicReference to the status to keep the thread from messing things - * up. - *

- * - */ - private AtomicReference concurrentStatus; - /** - *

- * An AtomicReference to the Form used for processing on the thread. - *

- * - */ - private AtomicReference
concurrentForm; - - /** - *

- * The set of file extensions supported by the ReactorAnalyzer. - *

- * - */ - private ArrayList extensions; - - /** - * The component id for the DataComponent of input and reference sources. - */ - private static final int dataSourcesId = 1; - - /** - * The component id for the IReactorComponent component that holds analysis - * artifacts - */ - public static final int inputReactorComponentId = 1; - - /** - * The component id for the LWRComponent component that holds analysis - * artifacts - */ - public static final int referenceReactorComponentId = 2; - - /** - * The component ID for the ReactorComposite that will contain the input and - * reference reactor components. The composite will store the input and - * reference reactor components and associated them with - * {@link #inputReactorComponentId} and {@link #resourceCompId}, - * respectively. - */ - public static final int reactorCompositeId = 4; - - /** - * The component id for the resource component that holds analysis artifacts - */ - private static final int resourceCompId = 2; - - /** - * The component id for the master details component that holds the analysis - * configuration - */ - private static final int analysisMDCompId = 3; - - /** - * A reference to the current input IReactorComponent. This may be out of - * sync with that in the ReactorComposite. If so, the KDD analysis tool will - * need to be updated. This is done when the form updates in - * {@link #reviewEntries(Form)}, which calls - * {@link #checkDataSource(String)}. - */ - private IReactorComponent inputReactorComponent = null; - - /** - * A reference to the current reference IReactorComponent. This may be out - * of sync with that in the ReactorComposite. If so, the KDD analysis tool - * will need to be updated. This is done when the form updates in - * {@link #reviewEntries(Form)}, which calls - * {@link #checkReferenceSource(String)}. - */ - private IReactorComponent referenceReactorComponent = null; - - /** - *

- * The constructor. - *

- * - * @param projectSpace - *

- * The Eclipse project used by the ReactorAnalyzer. - *

- */ - public ReactorAnalyzer(IProject projectSpace) { - - // Call super's constructor - super(projectSpace); - - // Initialize the status atomic - concurrentStatus = new AtomicReference(); - FormStatus formStatus = FormStatus.InfoError; - concurrentStatus.set(formStatus); - // Initialize the form atomic - concurrentForm = new AtomicReference(); - - return; - - } - - /** - *

- * An alternative nullary constructor used primarily for serialization. The - * setProject() operation must be called if this constructor is used! - *

- * - */ - public ReactorAnalyzer() { - - // Punt to the other constructor. - this(null); - - } - - /** - *

- * This operation sets the IAnalysisTools that are available to the - * ReactorAnalyzer. - *

- * - * @param tools - *

- * The set of IAnalysisTools. - *

- */ - public void setAnalysisTools(ArrayList tools) { - - // Only overwrite the tools if - if (tools != null) { - analysisTools = tools; - } - - } - - /** - *

- * This operation overrides the default setupForm() operation on Item and - * creates a Form for the ReactorAnalyzer according to the specification on - * the class. - *

- * - */ - @Override - protected void setupForm() { - - // Set the name - setName("Reactor Analyzer"); - // Set the Item type - itemType = ItemType.AnalysisSession; - // Set description - setDescription("Review and analyze data from simluations."); - - // No special Form for this, just a regular one - form = new Form(); - - // Setup the lists for analysis pieces - analysisTools = new ArrayList(); - analysisDocuments = new ArrayList(); - - // Setup the action list - allowedActions.clear(); - allowedActions.add("Generate Analysis Artifacts"); - - // Create the DataComponent that holds Data Sources - DataComponent dataSourceComp = new DataComponent(); - dataSourceComp.setName("Data Sources"); - dataSourceComp.setId(dataSourcesId); - dataSourceComp.setDescription("Select one of the available data " - + "sources from the list so that it can be analyzed."); - - // Create the Entry of input data sources - final ArrayList inputSources = getDataSources(); - Entry dataSourcesEntry = new Entry() { - // Override setup to contain the allowed files from the project - // space - @Override - public void setup() { - // Set the particulars - this.objectName = "Input Data"; - this.uniqueId = 1; - this.objectDescription = "The available input files."; - // Set the data sources list - allowedValueType = AllowedValueType.Discrete; - allowedValues = inputSources; - } - }; - // Create the Entry of reference input sources - Entry referenceSourcesEntry = new Entry() { - // Override setup to contain the allowed files from the project - // space - @Override - public void setup() { - // Set the particulars - this.objectName = "Reference Data"; - this.uniqueId = 2; - this.objectDescription = "The available reference files to " - + "which the selected input is compared."; - // Set the data sources list - allowedValueType = AllowedValueType.Discrete; - allowedValues.add("None"); - allowedValues.addAll(inputSources); - } - }; - // Add the Entries - dataSourceComp.addEntry(dataSourcesEntry); - dataSourceComp.addEntry(referenceSourcesEntry); - // Add the component to the Form - form.addComponent(dataSourceComp); - - // Create the ResourceComponent that holds the analysis assets - ResourceComponent assetsComp = new ResourceComponent(); - assetsComp.setName("Analysis Artifacts"); - assetsComp.setId(resourceCompId); - assetsComp.setDescription("This page shows all of the analysis " - + "artifacts that were generated from the output file."); - // Add the assets components to the Form - form.addComponent(assetsComp); - - // Add a ReactorComposite to the form. This Composite will contain the - // input and reference reactor components and will key them on final IDs - // rather than setting the component's IDs directly. - ReactorComposite reactorComposite = new ReactorComposite(); - reactorComposite.setName("Reactor Components"); - reactorComposite.setId(reactorCompositeId); - reactorComposite.setDescription("A group of reactor components " - + "containing the input and reference reactor."); - form.addComponent(reactorComposite); - - // Configure the LWRComponent that shows a view of the Reactor if an ICE - // Reactor file is loaded - PressurizedWaterReactor inputReactor = new PressurizedWaterReactor(15); - inputReactor.setName("Input"); - inputReactor.setId(inputReactorComponentId); - inputReactor.setDescription("The reactor being analyzed."); - // Add the reactor to the Form - reactorComposite.setComponent(inputReactorComponentId, inputReactor); - - // Configure the LWRComponent that shows a view of the Reactor if an ICE - // Reactor file is loaded - PressurizedWaterReactor refReactor = new PressurizedWaterReactor(15); - refReactor.setName("Reference"); - refReactor.setId(referenceReactorComponentId); - refReactor - .setDescription("A reference for the reactor being analyzed."); - // Add the reactor to the Form - reactorComposite.setComponent(referenceReactorComponentId, refReactor); - - // Configure the master details block - configureMasterDetailsBlock(); - - return; - - } - - /** - *

- * This operation overrides Item.reviewEntries() to customize the review - * process for the ReactorAnalyzer. It is primarily concerned with changes - * to the data source that should be analyzed and changes to the properties - * of the analysis artifacts. It delegates most of its work to the check*() - * set of operations. - *

- * - * @param preparedForm - *

- * The Form input from a client. - *

- * @return

- * The status. - *

- */ - @Override - protected FormStatus reviewEntries(Form preparedForm) { - - // Local Declarations - FormStatus reviewStatus = FormStatus.InfoError; - boolean checkStatus = false; - - try { - - // Check the input and reference data. - checkStatus = checkDataSource(null); - checkStatus &= checkReferenceSource(null); - - // Update the Form and status if the checks succeeded. - if (checkStatus) { - // Set Form - form = preparedForm; - // Set the return status to ready - reviewStatus = FormStatus.ReadyToProcess; - } - } catch (Exception e) { - // Catch any of the exceptions that are thrown the above operations. - logger.error(getClass().getName() + " Exception!",e); - } - - return reviewStatus; - } - - /** - *

- * This operation checks the data source on the Form to determine if it has - * been set or changed from the previous value. If the value has changed - * (either case), then the MasterDetailsComponent is reconfigured to contain - * the proper list of available analysis types for the new data source. - *

- * - * @param source - *

- * The name of the data source to compare to the last one. - *

- * @return

- * True if the operation was successful, false if not. - *

- * @throws RuntimeException - */ - protected boolean checkDataSource(String source) throws RuntimeException { - - // Get the input reactor from the ReactorComposite. - ReactorComposite composite = (ReactorComposite) form - .getComponent(reactorCompositeId); - IReactorComponent inputReactor = composite - .getReactorComponent(inputReactorComponentId); - - // If it's valid and if it has changed, we need to update the KDD with - // the new IDataProvider. - if (inputReactor != null && inputReactor != inputReactorComponent) { - inputReactorComponent = inputReactor; - - // FIXME - We should probably change the search to look for - // an ID instead of a String. - // Get documents for the new data source - for (IAnalysisTool tool : analysisTools) { - if ("Knowledge Discovery and Data Mining ICE Analysis Tool" - .equals(tool.getName()) - && inputReactor instanceof IDataProvider) { - analysisDocuments - .add(tool - .createDocument(getKDDIDataProvider((IDataProvider) inputReactor))); - } - } - - // Reconfigure the master details component - configureMasterDetailsBlock(); - } - - return true; - } - - /** - *

- * This operation checks the properties of analysis artifacts, which are - * ICEResources, in the ResourceComponent. If they have changed from the - * properties that are currently stored for the IAnalysisAsset, then the - * properties are updated on the asset and the asset itself is updated. - *

- * - * @param resources - *

- * The list of ICEResources that represent the analysis assets - * whose properties should be checked. - *

- * @return

- * True if the check succeeded and properties were successfully, - * false otherwise. - *

- * @throws RuntimeException - */ - protected boolean checkArtifactProperties(ArrayList resources) - throws RuntimeException { - - return true; - - } - - /** - *

- * This operation updates global parameters for the assets. - *

- * - */ - protected void updateGlobalParametersMap() { - // TODO Auto-generated method stub - - } - - /** - *

- * This operation configures the MasterDetailsComponent that is used by the - * ReactorAnalyzer to expose analysis asset types and the properties - * available for each type. It is updated each time the data source is - * changed. - *

- * - * @throws RuntimeException - */ - protected void configureMasterDetailsBlock() throws RuntimeException { - - // Local Declarations - int pairId = 0; - ArrayList templatePairs = null; - MasterDetailsComponent oldComp = null; - - // Setup a list to store master-details pairs - templatePairs = new ArrayList(); - - // Get ahold of the master details component from the Form if it already - // exists - if (form.getComponent(analysisMDCompId) != null) { - oldComp = (MasterDetailsComponent) form - .getComponent(analysisMDCompId); - } - - // Create the MasterDetailsComponent that is used to hold the available - // analysis types - MasterDetailsComponent analysisConfigComp = new MasterDetailsComponent(); - analysisConfigComp.setName("Analysis Configuration"); - analysisConfigComp.setId(analysisMDCompId); - analysisConfigComp - .setDescription("Select analysis artifacts to be created " - + "from the data and examine properties for each analysis type."); - - // If there are analysis documents, configure the master values and - // details blocks - if (!(analysisDocuments.isEmpty())) { - // Create an empty data component as a place holder for now. - // Eventually each IAnalysisDocument will publish information and - // options that will be provided in this data component/details - // block. - DataComponent detailsBlock = new DataComponent(); - detailsBlock.setId(4); - detailsBlock.setName("Global Analysis Options"); - detailsBlock - .setDescription("The following options are available to " - + "configure the selected analysis operation at a global level. " - + "If no options are shown below, then this analysis has no " - + "published options in ICE."); - // Loop over all of the available analysis documents to gather their - // allowed asset types and descriptive information - for (IAnalysisDocument doc : analysisDocuments) { - if (doc != null) { - // Loop over all of the allowed asset types for this - // document - for (String assetName : doc.getAvailableAssets()) { - // Create a master-details pair - MasterDetailsPair pair = new MasterDetailsPair(); - // Add the generic details block - pair.setDetails(detailsBlock); - // Add the asset type as the master value - pair.setMaster(assetName); - // Set the pair id - pair.setId(pairId); - // Increment the id for the next pair - pairId++; - // Add the pair to the template list - templatePairs.add(pair); - } - } - } - } - - // Set the MasterDetailsComponent template. It may be empty, but the - // component needs it regardless. - analysisConfigComp.setTemplates(templatePairs); - - // Add the component to the Form if it doesn't already exist. If it does - // exist, just copy the data over so that any references are maintained. - if (oldComp != null) { - oldComp.copy(analysisConfigComp); - } else { - form.addComponent(analysisConfigComp); - } - - } - - /** - *

- * This operation overrides the operation on the Item base class to generate - * analysis artifacts. The only valid action name is - * "Generate Analysis Artifacts." - *

- * - * @param actionName - *

- * The name of the action. In the case of the Reactor Analyzer, - * the only valid value is currently - * "Generate Analysis Artifacts." - *

- * @return

- * The status of the processing attempt. - *

- */ - @Override - public FormStatus process(String actionName) { - - // Check the action name and status - if ((actionName != null && "Generate Analysis Artifacts" - .equals(actionName)) - && (status.equals(FormStatus.ReadyToProcess) || status - .equals(FormStatus.Processed))) { - // Set the status - status = FormStatus.Processing; - // Set the references - concurrentStatus.set(status); - concurrentForm.set(form); - // Start the processing thread - Thread analysisThread = new Thread(this); - analysisThread.start(); - } else { - return FormStatus.InfoError; - } - - return status; - } - - /** - *

- * This operation checks the status of the ReactorAnalyzer and returns true - * if it can be processed safely. - *

- * - * @return

- * True if the ReactorAnalyzer is in either the ReadyToProcess or - * Processed states, false otherwise. - *

- */ - private boolean checkProcessingStatus() { - return false; - } - - /** - *

- * This operation creates a list of data sources based on the contents of - * the workspace. At the moment, it only finds .silo files. - *

- * - * @return

- * The list of file names of the available data sources. - *

- */ - private ArrayList getDataSources() { - - // Local Declarations - ArrayList dataSources = new ArrayList(); - - if (extensions == null) { - // Setup the allowed file extensions - extensions = new ArrayList(); - extensions.add("silo"); - extensions.add("e"); - extensions.add("h5"); - } - - // Only load the list if nothing goes nuts - if (project != null) { - try { - // Look at all the files in the project - for (IResource resource : project.members()) { - // Get the extension - String extension = "badExtension"; - extension = resource.getFileExtension(); - // Look for silo files - if (extension != null && extensions.contains(extension)) { - // Add the file to the list - dataSources.add(resource.getProjectRelativePath() - .toOSString()); - } - } - } catch (CoreException e) { - // Complain - logger.error(getClass().getName() + " Exception!",e); - } - } - - return dataSources; - } - - /** - *

- * This operation functions as Item.getStatus(), but is overridden to handle - * concurrency within the ReactorAnalyzer. - *

- * - * @return - */ - @Override - public FormStatus getStatus() { - - // Pass to super.getStatus() if the thread isn't involved - if (status != FormStatus.Processing) { - return super.getStatus(); - } else { - status = concurrentStatus.get(); - return status; - } - - } - - /** - *

- * Given a general IDataProvider, attempt to construct an IDataProvider - * required by the KDD Analysis Tool. If unsuccessful, return null. - *

- * - * @param generalProvider - * @return - */ - private IDataProvider getKDDIDataProvider(IDataProvider generalProvider) { - - // FIXME - Temporary solution to keep Java from complaining when we have - // an SFReactor. - if (!(generalProvider instanceof PressurizedWaterReactor)) { - return new LWRDataProvider(); - } - // I can expect this to be a PressurizedWaterReactor... - PressurizedWaterReactor reactor = (PressurizedWaterReactor) generalProvider; - - // Local Declarations - int totalNAssemblies = 0, nRows = 0, nCols = 0, nAxial = 49; - int nAssemblies = 0; - FuelAssembly assembly = null; - ArrayList dataElements = new ArrayList(); - LWRDataProvider provider = new LWRDataProvider(); - LWRData temp = null; - - // Get the total number of possible assemblies, - // each could be null, but this is the size of the - // fuel assembly grid - totalNAssemblies = reactor.getSize(); - - // Loop over all the possible fuel assembly locations - for (int i = 0; i < totalNAssemblies; i++) { - for (int j = 0; j < totalNAssemblies; j++) { - // Get the assembly at location i,j - assembly = (FuelAssembly) reactor.getAssemblyByLocation( - AssemblyType.Fuel, i, j); - // It could be null, so make sure its not - if (assembly != null) { - // We've found a valid assembly, - // so increment the counter. - nAssemblies++; - - // This assembly's get size should - // be the number of rows and columns - nRows = assembly.getSize(); - nCols = assembly.getSize(); - - // Loop over the possible pin rows and columns - for (int k = 0; k < nRows; k++) { - for (int l = 0; l < nCols; l++) { - - // Get the LWRRod IDataProvider at the grid - // position k, l. Could be null if this is a - // control rod or something else - IDataProvider prov = assembly - .getLWRRodDataProviderAtLocation(k, l); - if (prov != null - && prov.getFeatureList().contains( - "Axial Pin Power")) { - // Since there was a rod here, take the Axial - // Pin Power - // data and add it to the list of elements - dataElements - .addAll(prov - .getDataAtCurrentTime("Axial Pin Power")); - // Get the number of axial levels, - // I am assuming its the same throughout - nAxial = prov.getDataAtCurrentTime( - "Axial Pin Power").size(); - } else { - // If we had no fuel rod at k,l then - // we should add an empty IData element - temp = new LWRData("Data"); - temp.setValue(0.0); - temp.setUncertainty(0.0); - // Add nAxial of them to simulate an empty - // fuel rod spot - for (int ii = 0; ii < nAxial; ii++) { - dataElements.add(temp); - } - - } - } - } - } else { - } - - } - } - - // Add all the IData elements to the - // IDataProvider we are returning - for (IData d : dataElements) { - temp = new LWRData("Data"); - temp.setValue(d.getValue()); - temp.setUncertainty(d.getUncertainty()); - provider.addData(temp, 0.0); - } - - // KDD needs to know the number of rows - temp = new LWRData("Number of Rows"); - temp.setValue(nRows); - provider.addData(temp, 0.0); - - // KDD needs to know the number of columns - temp = new LWRData("Number of Columns"); - temp.setValue(nRows); - provider.addData(temp, 0.0); - - // KDD needs to know the number of assemblies - temp = new LWRData("Number of Assemblies"); - temp.setValue(nAssemblies); - provider.addData(temp, 0.0); - - // Return the provider - - return provider; - } - - /** - *

- * This operation checks the reference data source on the Form to determine - * if it has been set or changed from the previous value. If the value has - * changed (either case), then the MasterDetailsComponent is reconfigured to - * contain the proper list of available analysis types for the new reference - * data source. - *

- * - * @param source - * @return - */ - protected boolean checkReferenceSource(String source) { - - // Get the reference reactor from the ReactorComposite. - ReactorComposite composite = (ReactorComposite) form - .getComponent(reactorCompositeId); - IReactorComponent referenceReactor = composite - .getReactorComponent(referenceReactorComponentId); - - // If it's valid and if it has changed, we need to update the KDD with - // the new IDataProvider. - if (referenceReactor != null - && referenceReactor != referenceReactorComponent) { - referenceReactorComponent = referenceReactor; - - // FIXME - We should probably change the search to look for - // an ID instead of a String. - // Get documents for the new data source - for (IAnalysisTool tool : analysisTools) { - if ("Knowledge Discovery and Data Mining ICE Analysis Tool" - .equals(tool.getName()) - && referenceReactor instanceof IDataProvider - && !(analysisDocuments.isEmpty()) - && analysisDocuments.get(0) != null) { - analysisDocuments - .get(0) - .loadReferenceData( - getKDDIDataProvider((IDataProvider) referenceReactor)); - } - } - - // Reconfigure the master details component - configureMasterDetailsBlock(); - } - - return true; - } - - /** - * (non-Javadoc) - * - * @see Runnable#run() - */ - @Override - public void run() { - - // Get the MasterDetailsComponent component from the concurrentForm - MasterDetailsComponent analysisConfigComp = (MasterDetailsComponent) concurrentForm - .get().getComponent(3); - - // Create an ArrayList to hold the selected assets - ArrayList selectedAssets = new ArrayList(); - - // Loop over all the MasterDetailsPairs - for (int i = 0; i < analysisConfigComp.numberOfMasters(); i++) { - - // Add the value to the selected assets list - selectedAssets.add(analysisConfigComp.getMasterAtIndex(i)); - - } - - // Get the first document in the analysisDocuments list - // since we will only have a KDDAnalysisDocument to access initially - IAnalysisDocument document = analysisDocuments.get(0); - - // Set the selected assets on the document - document.setSelectedAssets(selectedAssets); - - // Create the assets - document.createSelectedAssets(); - - // Get all of the selected assets - ArrayList assets = document.getAllAssets(); - - // Get the ResourceComponent from the concurrentForm - ResourceComponent resourceComponent = (ResourceComponent) concurrentForm - .get().getComponent(resourceCompId); - - // Check for any resources currently stored in the resourceComponent - if (!(resourceComponent.getResources().isEmpty())) { - - // Clear those resources - resourceComponent.clearResources(); - - } - - // Initialize a resource id counter - int resourceId = 0; - - // Loop over all assets in the asset array list - if (!assets.isEmpty()) { - for (IAnalysisAsset asset : assets) { - - // This is processed for every item in the ICE resource view. - - // Create a new ICEResource and assign values from the asset - ICEResource resource = new ICEResource(); - resource.setId(resourceId); - // Set the file contents for the resource - try { - resource.setContents(new File(asset.getURI().getPath())); - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (IOException e) { - logger.error(getClass().getName() + " Exception!",e); - } - resource.setPath(asset.getURI()); - resource.setName(asset.getName()); - - // Add the resource to the resourceComponent - resourceComponent.addResource(resource); - - // Increment the resourceId - resourceId++; - - } - } - // Set the status - concurrentStatus.set(FormStatus.Processed); - - // Assign the concurrentForm reference to form. - form = concurrentForm.get(); - - return; - - } - -} \ No newline at end of file diff --git a/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorAnalyzerBuilder.java b/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorAnalyzerBuilder.java deleted file mode 100644 index d2a603d5d..000000000 --- a/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorAnalyzerBuilder.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer; - -import java.util.ArrayList; - -import org.eclipse.ice.analysistool.IAnalysisTool; -import org.eclipse.core.resources.IProject; -import org.eclipse.ice.item.AbstractItemBuilder; -import org.eclipse.ice.item.Item; -import org.eclipse.ice.item.ItemType; - -/** - *

- * This class is the ItemBuilder for the ReactorAnalyzer. It constructs a - * ReactorAnalyzer when build() is called if and only if at least one - * IAnalysisTool is available to do the analysis work for the analyzer, - * otherwise it will return null when build() is called. - *

- *

- * The name and type of the Item created by this builder are set as final, - * static variables on this class. Just something I'm trying out for - * convenience... - *

- * - * @author Scott Forest Hull II - */ -public class ReactorAnalyzerBuilder extends AbstractItemBuilder { - /** - *

- * The set of IAnalysisTools available for the ReactorAnalyzer. - *

- * - */ - private ArrayList analysisTools; - - /** - *

- * The name of the ReactorAnalyzer. - *

- * - */ - public static final String name = "Reactor Analyzer"; - - /** - *

- * The type of the Item that this builder will create. - *

- * - */ - public static final ItemType type = ItemType.AnalysisSession; - - /** - *

- * The constructor. - *

- * - */ - public ReactorAnalyzerBuilder() { - - setName(name); - setType(type); - - // Allocate the list of tools - analysisTools = new ArrayList(); - - return; - - } - - /** - *

- * This operation adds an IAnalysisTool to the list of analysis tools that - * is available to the ReactorAnalyzer. - *

- * - * @param tool - *

- * The IAnalysisTool to add to the set. - *

- */ - public void addAnalysisTool(IAnalysisTool tool) { - - // Add the tool - if (tool != null) { - analysisTools.add(tool); - } - - return; - - } - - /** - *

- * This operation is called by the OSGI to close the associated - * IAnalysisTools. - *

- * - */ - public void stop() { - - logger.info("ReactorAnalyzerBuilder Message: " - + "Closing Analysis Tools!"); - for (int i = 0; i < this.analysisTools.size(); i++) { - this.analysisTools.get(i).close(); - } - } - - /** - * (non-Javadoc) - * @see org.eclipse.ice.item.AbstractItemBuilder#getInstance(org.eclipse.core.resources.IProject) - */ - @Override - public Item getInstance(IProject projectSpace) { - - // Local Declarations - ReactorAnalyzer analyzer = null; - - // Make the analyzer - analyzer = new ReactorAnalyzer(projectSpace); - - // Set the item builder name - analyzer.setItemBuilderName(this.getItemName()); - - // Set the name - analyzer.setName(name); - // Set the analysis tools - analyzer.setAnalysisTools(analysisTools); - - return analyzer; - - } - -} diff --git a/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorComposite.java b/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorComposite.java deleted file mode 100644 index a2e4e1b3d..000000000 --- a/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorComposite.java +++ /dev/null @@ -1,314 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer; - -import java.util.ArrayList; -import java.util.Map; -import java.util.TreeMap; - -import org.eclipse.ice.datastructures.ICEObject.Component; -import org.eclipse.ice.datastructures.ICEObject.Composite; -import org.eclipse.ice.datastructures.ICEObject.ICEObject; -import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor; -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.datastructures.componentVisitor.SelectiveComponentVisitor; - -/** - * This class is intended to contain {@link IReactorComponent}s by implementing - * the {@link Composite} interface. However, it associates child components by - * associating them with an ID, which is not necessarily the same as the - * component IDs. - * - * @author Jordan H. Deyton - * - */ -public class ReactorComposite extends ICEObject implements IReactorComponent, - Composite { - - // TODO Test this class. - - /** - * A List of IReactorComponents stored by this Composite. - */ - private final Map reactorComponents; - - /** - * The default constructor. Initializes an empty list of IReactorComponents. - */ - public ReactorComposite() { - reactorComponents = new TreeMap(); - } - - // ---- Implements IReactorComponent ---- // - /** - * Fires the default visit operation on the visitor. It should result in a - * call to {@link IComponentVisitor#visit(IReactorComponent)}. - * - * @param visitor - * The visitor. - */ - @Override - public void accept(IComponentVisitor visitor) { - if (visitor != null) { - visitor.visit(this); - } - } - - /** - * Overrides {@link ICEObject}'s behavior to pass the update to all child - * components. - */ - @Override - public void update(String updatedKey, String newValue) { - for (IReactorComponent component : reactorComponents.values()) { - component.update(updatedKey, newValue); - } - } - - // All other methods from IReactorComponent (a sub-interface of Component) - // have been implemented by ICEObject. - // -------------------------------------- // - - // ---- Implements Composite ---- // - /** - * If the child is an IReactorComponent, this method adds the child to this - * Composite. Any previously added IReactorComponent associated with the - * same ID as this child's ID will be removed. - * - * @param child - * The Component to add. - */ - @Override - public void addComponent(Component child) { - - // If the child is not null, visit it with a visitor that adds - // IReactorComponents to the map. - if (child != null) { - - // Get the ID of the new component and get the previous component - // associated with the ID. - final int id = child.getId(); - Component oldComponent = reactorComponents.get(id); - - // Visit the child and put it into the map if it's an - // IReactorComponent. - IComponentVisitor visitor = new SelectiveComponentVisitor() { - @Override - public void visit(IReactorComponent component) { - reactorComponents.put(id, component); - } - }; - child.accept(visitor); - - // Notify listeners of the change only if the value changed. - if (child != oldComponent) { - notifyListeners(); - } - } - - return; - } - - /** - * Adds an IReactorComponent to this Composite. If its ID is already taken, - * then the previous IReactorComponent associated with the ID is replaced - * and returned. Null values will not be added to this Composite. - * - * @param id - * The ID associated with the new IReactorComponent. - * @param child - * The IReactorComponent to add. - * @return The previous IReactorComponent associated with the ID, or null if - * one did not exist. - */ - public IReactorComponent setComponent(int id, IReactorComponent child) { - - IReactorComponent oldComponent = null; - - // Only add non-null reactor components. - if (child != null) { - oldComponent = reactorComponents.put(id, child); - - // Notify listeners of the change only if the value changed. - if (child != oldComponent) { - notifyListeners(); - } - } - - return oldComponent; - } - - /** - * Removes the IReactorComponent in this Composite that is associated with - * the specified ID. - */ - @Override - public void removeComponent(int childId) { - // Remove the component associated with the ID and notify listeners if - // it was removed. - if (reactorComponents.remove(childId) != null) { - notifyListeners(); - } - } - - /** - * Gets the IReactorComponent in this Composite that is associated with the - * specified ID. - */ - @Override - public Component getComponent(int childId) { - return reactorComponents.get(childId); - } - - /** - * Convenience method that returns the same component as - * {@link #getComponent(int)} but already cast as an IReactorComponent. - * - * @param childId - * The ID associated with the desired IReactorComponent. - * @return The IReactorComponent associated with the specified ID, or null - * if no such component exists. - */ - public IReactorComponent getReactorComponent(int childId) { - return reactorComponents.get(childId); - } - - /** - * Gets the number of IReactorComponents stored in this Composite. - * - * @return The number of IReactorComponents stored in this Composite. - */ - @Override - public int getNumberOfComponents() { - return reactorComponents.size(); - } - - /** - * Gets the list of Components stored in this Composite. - * - * @return The list of Components stored in this Composite. - */ - @Override - public ArrayList getComponents() { - return new ArrayList(reactorComponents.values()); - } - - /** - * Convenience method that returns the same list as {@link #getComponents()} - * but already cast as IReactorComponents. - * - * @return The Composite's current list of IReactorComponents. - */ - public ArrayList getReactorComponents() { - return new ArrayList(reactorComponents.values()); - } - - // ------------------------------ // - - /** - *

- * Compares the contents of objects and returns true if they are identical, - * otherwise returns false. - *

- * - * @param otherObject - * The other object to compare against. - * @return Returns true if the two objects are equal, otherwise false. - */ - @Override - public boolean equals(Object otherObject) { - - // By default, the objects are not equivalent. - boolean equals = false; - - // Check the reference. - if (this == otherObject) { - equals = true; - } - // Check the information stored in the other object. - else if (otherObject != null && otherObject instanceof ReactorComposite) { - - // We can now cast the other object. - ReactorComposite composite = (ReactorComposite) otherObject; - - // Compare the values between the two objects. - equals = (super.equals(otherObject) && reactorComponents - .equals(composite.reactorComponents)); - } - - return equals; - } - - /** - *

- * Returns the hashCode of the object. - *

- * - * @return The hash of the object. - */ - @Override - public int hashCode() { - - // Hash based on super's hashCode. - int hash = super.hashCode(); - - // Add local hashes. - hash += 31 * hash + reactorComponents.hashCode(); - - return hash; - } - - /** - *

- * Copies the contents of the object from another object. Components from - * the other Composite are not deep copied. - *

- * - * @param otherObject - * The object to be copied from. - */ - public void copy(ReactorComposite otherObject) { - - // Check the parameters. - if (otherObject == null) { - return; - } - - // Copy the local values. - reactorComponents.clear(); - reactorComponents.putAll(otherObject.reactorComponents); - - return; - } - - /** - *

- * Deep copies and returns a newly instantiated object. - *

- * - * @return The newly instantiated cloned object. - */ - @Override - public Object clone() { - - // Initialize a new object. - ReactorComposite object = new ReactorComposite(); - - // Copy the contents from this one. - object.copy(this); - - // Return the newly instantiated object. - return object; - } - -} diff --git a/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorReaderFactory.java b/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorReaderFactory.java deleted file mode 100644 index 04386f786..000000000 --- a/org.eclipse.ice.reactorAnalyzer/src/org/eclipse/ice/reactorAnalyzer/ReactorReaderFactory.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.reactorAnalyzer; - -import java.io.File; -import java.net.URI; -import java.util.HashMap; -import java.util.Map; - -import ncsa.hdf.hdf5lib.H5; -import ncsa.hdf.hdf5lib.HDF5Constants; -import ncsa.hdf.hdf5lib.exceptions.HDF5LibraryException; -import ncsa.hdf.hdf5lib.structs.H5O_info_t; - -import org.eclipse.ice.datastructures.componentVisitor.IReactorComponent; -import org.eclipse.ice.reactor.LWRComponentReader; -import org.eclipse.ice.reactor.pwr.PressurizedWaterReactor; -import org.eclipse.ice.reactor.sfr.base.SFReactorIOHandler; -import org.eclipse.ice.reactor.sfr.core.SFReactor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReactorReaderFactory { - - /** - * Logger for handling event messages and other information. - */ - private static final Logger logger = LoggerFactory - .getLogger(ReactorReaderFactory.class); - - // FIXME - In lieu of registering OSGi services, I'm simply calling the - // specific reactor classes and methods directly. - - private interface IReactorFactory { - public IReactorComponent read(URI uri); - - public void copy(IReactorComponent src, IReactorComponent dst); - } - - private Map reactorFactoryMap; - - public ReactorReaderFactory() { - - reactorFactoryMap = new HashMap(); - reactorFactoryMap.put(PressurizedWaterReactor.class, - new IReactorFactory() { - @Override - public IReactorComponent read(URI uri) { - return (PressurizedWaterReactor) new LWRComponentReader() - .read(uri); - } - - @Override - public void copy(IReactorComponent src, - IReactorComponent dst) { - ((PressurizedWaterReactor) dst) - .copy((PressurizedWaterReactor) src); - return; - } - }); - reactorFactoryMap.put(SFReactor.class, new IReactorFactory() { - @Override - public IReactorComponent read(URI uri) { - return new SFReactorIOHandler().readHDF5(uri); - } - - @Override - public void copy(IReactorComponent src, IReactorComponent dst) { - ((SFReactor) dst).copy((SFReactor) src); - return; - } - }); - - return; - } - - /** - * This method reads the data from a given file into an implementation of an - * IReactorComponent. It will return null if the file could not be read. - * - * @param source - * The URI of the source data file. - * @return An instance of an implementation of IReactorComponent, or - * null if the file could not be read. - */ - public IReactorComponent readReactor(URI source) { - - // Declare a component to return. - IReactorComponent component = null; - - // Open up the file to read what type of reactor is in the file. - if (source == null) { - return component; - } - - // Check the file associated with the URI. We need to be able to read - // from it. - File file = new File(source); - String path = file.getPath(); - if (!file.canRead()) { - System.err.println("ReactorReaderFactory error: File \"" + path - + "\" cannot be read."); - return component; - } - - // The name of the reactor group (the first group in the .h5 file). - Class type = null; - - try { - int H5P_DEFAULT = HDF5Constants.H5P_DEFAULT; - - // Open the H5 file with read-only access. - int fileId = H5.H5Fopen(path, HDF5Constants.H5F_ACC_RDONLY, - H5P_DEFAULT); - if (fileId < 0) { - throw new HDF5LibraryException("Error opening .h5 file \"" - + path + "\"."); - } - // Get the name of the first group. That should determine the type - // of reactor. - - // Constants used below. - int indexType = HDF5Constants.H5_INDEX_NAME; - int indexOrder = HDF5Constants.H5_ITER_INC; - - // Get the info for the first group in the file. - H5O_info_t info = H5.H5Oget_info_by_idx(fileId, "/", indexType, - indexOrder, 0, H5P_DEFAULT); - - // See if the object exists and is an HDF5 Group. - if (info == null || info.type != HDF5Constants.H5O_TYPE_GROUP) { - throw new HDF5LibraryException( - "Expected a reactor Group in file \"" + path + "\"."); - } - // Get the name and add it to the List if possible. - String name = H5.H5Lget_name_by_idx(fileId, "/", indexType, - indexOrder, 0, H5P_DEFAULT); - if (name == null) { - throw new HDF5LibraryException( - "Invalid name of first Group in file \"" + path + "\"."); - } - // For the moment, SFReactor files have the name of the first Group - // set to SFReactor. PWReactor files have an HDF5LWRTag Attribute. - if ("SFReactor".equals(name)) { - type = SFReactor.class; - } else { - /* ---- Try to open the HDF5LWRTag Attribute. ---- */ - if (H5.H5Aexists_by_name(fileId, "/" + name, "HDF5LWRTag", - H5P_DEFAULT)) { - - // Open the Attribute. - int attributeId = H5.H5Aopen_by_name(fileId, "/" + name, - "HDF5LWRTag", H5P_DEFAULT, H5P_DEFAULT); - if (attributeId < 0) { - throw new HDF5LibraryException( - "Could not open HDF5LWRTag for first Group in file \"" - + path + "\"."); - } - // Get the Datatype for the Attribute. - int datatypeId = H5.H5Aget_type(attributeId); - if (datatypeId < 0) { - throw new HDF5LibraryException( - "Could not get Datatype of HDF5LWRTag for first Group in file \"" - + path + "\"."); - } - // Get the size of the String from the datatype. - int size = H5.H5Tget_size(datatypeId); - if (size <= 0) { - throw new HDF5LibraryException( - "Could not get size of Datatype of HDF5LWRTag for first Group in file \"" - + path + "\"."); - } - // Initialize the buffer. - byte[] buffer = new byte[size]; - - // Read the attribute. - if (H5.H5Aread(attributeId, datatypeId, buffer) < 0) { - throw new HDF5LibraryException( - "Could not read HDF5LWRTag for first Group in file \"" - + path + "\"."); - } - // Close the Datatype. - if (H5.H5Tclose(datatypeId) < 0) { - throw new HDF5LibraryException( - "Could not close Datatype of HDF5LWRTag for first Group in file \"" - + path + "\"."); - } - // Close the Attribute. - if (H5.H5Aclose(attributeId) < 0) { - throw new HDF5LibraryException( - "Could not close HDF5LWRTag for first Group in file \"" - + path + "\"."); - } - // Convert the buffer to a String and see if it matches the - // expected value for a PWReactor. - if ("PWReactor".equals(new String(buffer))) { - type = PressurizedWaterReactor.class; - } - /* ----------------------------------------------- */ - } - } - // Close the H5file. - if (H5.H5Fclose(fileId) < 0) { - throw new HDF5LibraryException("Error closing .h5 file \"" - + path + "\"."); - } - } catch (HDF5LibraryException e) { - logger.error(getClass().getName() + " Exception!",e); - } catch (NullPointerException e) { - logger.error(getClass().getName() + " Exception!",e); - } - - // Look up the factory for the type and, if possible, use the factory to - // read in the component. - IReactorFactory factory = reactorFactoryMap.get(type); - if (factory != null) { - component = factory.read(source); - } - return component; - } - - /** - * Copies the information from a source IReactorComponent instance to - * another IReactorComponent. - * - * @param source - * The source IReactorComponent to be copied from. - * @param destination - * The destination IReactorComponent to be copied to. - */ - public boolean copyReactor(IReactorComponent source, - IReactorComponent destination) { - - boolean copied = false; - - // Check the parameters for null and make sure their class types are the - // same. - if (source != null && destination != null - && source.getClass().equals(destination.getClass())) { - - // Get the factory that knows how to copy the IReactorComponent - // implementation. - IReactorFactory factory = reactorFactoryMap.get(destination - .getClass()); - - // If the factory is valid, then try to copy the source data into - // the destination. - if (factory != null) { - factory.copy(source, destination); - copied = true; - } - } - - return copied; - } -} \ No newline at end of file diff --git a/org.eclipse.ice.reflectivity.ui/src/org/eclipse/ice/reflectivity/ui/ReflectivityPage.java b/org.eclipse.ice.reflectivity.ui/src/org/eclipse/ice/reflectivity/ui/ReflectivityPage.java index df6fcbe1e..c325e522f 100644 --- a/org.eclipse.ice.reflectivity.ui/src/org/eclipse/ice/reflectivity/ui/ReflectivityPage.java +++ b/org.eclipse.ice.reflectivity.ui/src/org/eclipse/ice/reflectivity/ui/ReflectivityPage.java @@ -17,7 +17,6 @@ import org.eclipse.ice.client.widgets.ElementSourceDialog; import org.eclipse.ice.client.widgets.ICEResourcePage; -import org.eclipse.ice.client.widgets.ICEResourceView; import org.eclipse.ice.client.widgets.ListComponentNattable; import org.eclipse.ice.datastructures.ICEObject.ListComponent; import org.eclipse.ice.datastructures.form.DataComponent; @@ -49,7 +48,6 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.internal.Workbench; import org.eclipse.ui.views.properties.IPropertySheetPage; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; diff --git a/org.eclipse.ice.reflectivity/src/org/eclipse/ice/reflectivity/ReflectivityModel.java b/org.eclipse.ice.reflectivity/src/org/eclipse/ice/reflectivity/ReflectivityModel.java index 486e5fc1a..24d8b0b25 100644 --- a/org.eclipse.ice.reflectivity/src/org/eclipse/ice/reflectivity/ReflectivityModel.java +++ b/org.eclipse.ice.reflectivity/src/org/eclipse/ice/reflectivity/ReflectivityModel.java @@ -31,9 +31,6 @@ import org.eclipse.ice.datastructures.form.Material; import org.eclipse.ice.datastructures.form.ResourceComponent; import org.eclipse.ice.datastructures.resource.VizResource; -import org.eclipse.ice.io.csv.CSVReader; -import org.eclipse.ice.io.csv.SpaceDelimitedReader; -import org.eclipse.ice.io.serializable.IOService; import org.eclipse.ice.item.model.Model; import org.eclipse.ice.materials.IMaterialsDatabase; import org.eclipse.ice.materials.MaterialWritableTableFormat; diff --git a/org.eclipse.ice.repository/ice.product b/org.eclipse.ice.repository/ice.product index 1881c1cb4..e9993e53f 100644 --- a/org.eclipse.ice.repository/ice.product +++ b/org.eclipse.ice.repository/ice.product @@ -135,42 +135,42 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -233,6 +233,28 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U + + + + + + + + + + + + + + + + + + + + + + @@ -274,7 +296,6 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U - @@ -283,7 +304,6 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U - diff --git a/org.eclipse.ice.sassena.test/.classpath b/org.eclipse.ice.sassena.test/.classpath deleted file mode 100644 index 098194ca4..000000000 --- a/org.eclipse.ice.sassena.test/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.sassena.test/.gitignore b/org.eclipse.ice.sassena.test/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.sassena.test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.sassena.test/.project b/org.eclipse.ice.sassena.test/.project deleted file mode 100644 index 4964c6655..000000000 --- a/org.eclipse.ice.sassena.test/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.ice.sassena.test - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.sassena.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.sassena.test/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f42de363a..000000000 --- a/org.eclipse.ice.sassena.test/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/org.eclipse.ice.sassena.test/META-INF/MANIFEST.MF b/org.eclipse.ice.sassena.test/META-INF/MANIFEST.MF deleted file mode 100644 index 0fa65406d..000000000 --- a/org.eclipse.ice.sassena.test/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Tests -Bundle-SymbolicName: org.eclipse.ice.sassena.test -Bundle-Version: 2.1.8 -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: org.junit;bundle-version="4.11.0", - org.eclipse.ice.sassena;bundle-version="2.0.0", - org.eclipse.core.resources;bundle-version="3.8.101", - org.eclipse.core.runtime;bundle-version="3.9.100", - org.eclipse.ice.datastructures -Import-Package: org.eclipse.ice.datastructures.form, - org.eclipse.ice.datastructures.form.emf, - org.eclipse.ice.item -Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.sassena.test/build.properties b/org.eclipse.ice.sassena.test/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/org.eclipse.ice.sassena.test/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/org.eclipse.ice.sassena.test/pom.xml b/org.eclipse.ice.sassena.test/pom.xml deleted file mode 100644 index cc3c006d8..000000000 --- a/org.eclipse.ice.sassena.test/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.sassena.test - eclipse-test-plugin - - true - - diff --git a/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaCoherentModelBuilderTester.java b/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaCoherentModelBuilderTester.java deleted file mode 100644 index bc0311f84..000000000 --- a/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaCoherentModelBuilderTester.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2013, 2014 UT-Battelle, LLC. -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Eclipse Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/epl-v10.html -* -* Contributors: -* Initial API and implementation and/or initial documentation - Jay Jay Billings, -* Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, -* Claire Saunders, Matthew Wang, Anna Wojtowicz -*******************************************************************************/ -package org.eclipse.ice.sassena.tests; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.ice.item.ItemType; -import org.eclipse.ice.sassena.SassenaCoherentModel; -import org.eclipse.ice.sassena.SassenaCoherentModelBuilder; -import org.junit.Test; - -/** - *

- * This class tests the SassenaCoherentModelBuilder. - *

- */ -public class SassenaCoherentModelBuilderTester { - /** - *

- * This operation checks the CaebatModelBuilder.getItemName(). - *

- * - */ - @Test - public void checkGetItemName() { - - - // Local declarations - SassenaCoherentModelBuilder sassenaBuilder = new SassenaCoherentModelBuilder(); - - // Check the Item name - assertEquals("Sassena Coherent Model", sassenaBuilder.getItemName()); - - - - } - - /** - *

- * This operation checks the SassenaCoherentModelBuilder.build(). This should check - * to see if a form is created, but it should not check the contents of that - * form. That is checked in a lower level tester. - *

- */ - @Test - public void checkBuild() { - - - // Local declarations - SassenaCoherentModelBuilder sassenaBuilder = new SassenaCoherentModelBuilder(); - SassenaCoherentModel sassenaModel = null; - - // Builder can be passed a null project. - sassenaModel = (SassenaCoherentModel) sassenaBuilder.build(null); - - // Check that the item builder name is set - assertEquals(sassenaBuilder.getItemName(), - sassenaModel.getItemBuilderName()); - - // Just make sure the Form is created. Its contents will be checked later. - assertNotNull(sassenaModel.getForm()); - - - } - - /** - *

- * This operation checks the SassenaIncohrerentModelBuilder.getItemType(). - *

- */ - @Test - public void checkGetItemType() { - - - // Local declarations - SassenaCoherentModelBuilder sassenaBuilder = new SassenaCoherentModelBuilder(); - - // Check the Item name - assertEquals(ItemType.Model, sassenaBuilder.getItemType()); - - - } -} diff --git a/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaCoherentModelTester.java b/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaCoherentModelTester.java deleted file mode 100644 index 765c2b2c7..000000000 --- a/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaCoherentModelTester.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.sassena.tests; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Paths; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.form.FormStatus; -import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.sassena.SassenaCoherentModel; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class tests the operations on SassenaCoherentModel. This class is also - * responsible for building the model files designed to be used in the Sassena - * Model for production mode. - *

- */ -public class SassenaCoherentModelTester { - - /** - * The project space used to create the workspace for the tests. - */ - private static IProject projectSpace; - - /** - *

- * This operation sets up the workspace. - *

- * - */ - @BeforeClass - public static void beforeTests() { - - // Local Declarations - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - URI defaultProjectLocation = null; - IProject project = null; - String projectName = "sassenaData"; - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + projectName; - - // Setup the project - try { - // Get the project handle - project = workspaceRoot.getProject(projectName); - // If the project does not exist, create it - if (!project.exists()) { - // Set the location as - // ${workspace_loc}/CAEBATModelTesterWorkspace - defaultProjectLocation = (new File(userDir)).toURI(); - // Create the project description - IProjectDescription desc = ResourcesPlugin.getWorkspace() - .newProjectDescription(projectName); - // Set the location of the project - desc.setLocationURI(defaultProjectLocation); - // Create the project - project.create(desc, null); - } - // Open the project if it is not already open - if (project.exists() && !project.isOpen()) { - project.open(null); - } - // Refresh the workspace - project.refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (CoreException e) { - // Catch exception for creating the project - e.printStackTrace(); - fail(); - } - - // Set the global project reference. - projectSpace = project; - - return; - } - - /** - *

- * This operation checks SassenaCoherentModel.setupForm operation. - *

- */ - @Test - public void checkSetupForm() { - - - // Local declarations - SassenaCoherentModel sassenaModel; - Form form = new Form(); - - // The project space can be null for this operation and it will still - // work. - sassenaModel = new SassenaCoherentModel(projectSpace); - - // Check contents - see that there are 5 components - form = sassenaModel.getForm(); - assertNotNull(form.getComponents()); - assertEquals(1, form.getComponents().size()); - - return; - - } - - /** - *

- * This operation checks BatMLModel.process operation. - *

- */ - @Test - public void checkProcess() { - - - // Local Declarations - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + "sassenaData"; - String filePath = userDir + separator - + "sassenaInc.xml"; - - SassenaCoherentModel sassena; - Form form = new Form(); - - // The projectspace has to be set for this to work. - sassena = new SassenaCoherentModel(projectSpace); - - // Check default contents - form = sassena.getForm(); - assertNotNull(form.getComponents()); - assertEquals(1, form.getComponents().size()); - - // Check the name and description of the item and allowedActions - assertEquals("Sassena Coherent Model Builder", sassena.getName()); - assertEquals("This item builds models based on a Sassena Coherent schema.", - sassena.getDescription()); - - // Since there are entries and DataComponents, lets run the test! - // Now try to pass it the wrong information into the process - // operation on BatMLModel - assertEquals(FormStatus.InfoError, - sassena.process("I AM A VAGUE, INAPPROPRIATE PROCESS!")); - - // This portion will try to get the operation to write the information - // to xml file - assertEquals(FormStatus.Processed, - sassena.process("Write to XML")); - - // Check to see if the file is created an exists. It will create a file - // in relation to the Id of the item. - assertTrue(Files.exists(Paths.get(filePath))); - - - } - - @Test - public void checkLoadInput() { - SassenaCoherentModel sassena = new SassenaCoherentModel(projectSpace); - sassena.loadInput("sassenaCoh.xml"); - EMFComponent component = (EMFComponent) sassena.getForm().getComponent(1); - assertNotNull(component); - assertNotNull(component.getEMFTreeComposite()); - assertTrue("DocumentRoot".equals(component.getEMFTreeComposite().getName())); - } -} diff --git a/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaIncoherentModelBuilderTester.java b/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaIncoherentModelBuilderTester.java deleted file mode 100644 index 26d458e11..000000000 --- a/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaIncoherentModelBuilderTester.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2013, 2014 UT-Battelle, LLC. -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Eclipse Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/epl-v10.html -* -* Contributors: -* Initial API and implementation and/or initial documentation - Jay Jay Billings, -* Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, -* Claire Saunders, Matthew Wang, Anna Wojtowicz -*******************************************************************************/ -package org.eclipse.ice.sassena.tests; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.ice.item.ItemType; -import org.eclipse.ice.sassena.SassenaIncoherentModel; -import org.eclipse.ice.sassena.SassenaIncoherentModelBuilder; -import org.junit.Test; - -/** - *

- * This class tests the SassenaIncoherentModelBuilder. - *

- */ -public class SassenaIncoherentModelBuilderTester { - /** - *

- * This operation checks the CaebatModelBuilder.getItemName(). - *

- * - */ - @Test - public void checkGetItemName() { - - - // Local declarations - SassenaIncoherentModelBuilder sassenaBuilder = new SassenaIncoherentModelBuilder(); - - // Check the Item name - assertEquals("Sassena Incoherent Model", sassenaBuilder.getItemName()); - - - } - - /** - *

- * This operation checks the SassenaIncoherentModelBuilder.build(). This should check - * to see if a form is created, but it should not check the contents of that - * form. That is checked in a lower level tester. - *

- */ - @Test - public void checkBuild() { - - - // Local declarations - SassenaIncoherentModelBuilder sassenaBuilder = new SassenaIncoherentModelBuilder(); - SassenaIncoherentModel sassenaModel = null; - - // Builder can be passed a null project. - sassenaModel = (SassenaIncoherentModel) sassenaBuilder.build(null); - - // Check that the item builder name is set - assertEquals(sassenaBuilder.getItemName(), - sassenaModel.getItemBuilderName()); - - // Just make sure the Form is created. Its contents will be checked later. - assertNotNull(sassenaModel.getForm()); - - - } - - /** - *

- * This operation checks the SassenaIncohrerentModelBuilder.getItemType(). - *

- */ - @Test - public void checkGetItemType() { - - - // Local declarations - SassenaIncoherentModelBuilder sassenaBuilder = new SassenaIncoherentModelBuilder(); - - // Check the Item name - assertEquals(ItemType.Model, sassenaBuilder.getItemType()); - - - } -} diff --git a/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaIncoherentModelTester.java b/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaIncoherentModelTester.java deleted file mode 100644 index 70397e6eb..000000000 --- a/org.eclipse.ice.sassena.test/src/org/eclipse/ice/sassena/tests/SassenaIncoherentModelTester.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.sassena.tests; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Paths; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.form.FormStatus; -import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.sassena.SassenaIncoherentModel; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - *

- * This class tests the operations on SassenaIncoherent. This class is also - * responsible for building the model files designed to be used in the Sassena - * Model for production mode. - *

- */ -public class SassenaIncoherentModelTester { - - /** - * The project space used to create the workspace for the tests. - */ - private static IProject projectSpace; - - /** - *

- * This operation sets up the workspace. - *

- * - */ - @BeforeClass - public static void beforeTests() { - - // Local Declarations - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - URI defaultProjectLocation = null; - IProject project = null; - String projectName = "sassenaData"; - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + projectName; - - // Setup the project - try { - // Get the project handle - project = workspaceRoot.getProject(projectName); - // If the project does not exist, create it - if (!project.exists()) { - // Set the location as - // ${workspace_loc}/CAEBATModelTesterWorkspace - defaultProjectLocation = (new File(userDir)).toURI(); - // Create the project description - IProjectDescription desc = ResourcesPlugin.getWorkspace() - .newProjectDescription(projectName); - // Set the location of the project - desc.setLocationURI(defaultProjectLocation); - // Create the project - project.create(desc, null); - } - // Open the project if it is not already open - if (project.exists() && !project.isOpen()) { - project.open(null); - } - // Refresh the workspace - project.refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (CoreException e) { - // Catch exception for creating the project - e.printStackTrace(); - fail(); - } - - // Set the global project reference. - projectSpace = project; - - return; - } - - /** - *

- * This operation checks SassenaIncoherentModel.setupForm operation. - *

- */ - @Test - public void checkSetupForm() { - - - // Local declarations - SassenaIncoherentModel sassenaModel; - Form form = new Form(); - - // The project space can be null for this operation and it will still - // work. - sassenaModel = new SassenaIncoherentModel(projectSpace); - - // Check contents - see that there are 5 components - form = sassenaModel.getForm(); - assertNotNull(form.getComponents()); - assertEquals(1, form.getComponents().size()); - - return; - - } - - /** - *

- * This operation checks BatMLModel.process operation. - *

- */ - @Test - public void checkProcess() { - - - // Local Declarations - String separator = System.getProperty("file.separator"); - String userDir = System.getProperty("user.home") + separator - + "ICETests" + separator + "sassenaData"; - String filePath = userDir + separator + "sassenaInc.xml"; - - SassenaIncoherentModel sassena; - Form form = new Form(); - - // The projectspace has to be set for this to work. - sassena = new SassenaIncoherentModel(projectSpace); - - // Check default contents - form = sassena.getForm(); - assertNotNull(form.getComponents()); - assertEquals(1, form.getComponents().size()); - - // Check the name and description of the item and allowedActions - assertEquals("Sassena Incoherent Model Builder", sassena.getName()); - assertEquals( - "This item builds models based on a Sassena Incoherent schema.", - sassena.getDescription()); - - // Since there are entries and DataComponents, lets run the test! - // Now try to pass it the wrong information into the process - // operation on BatMLModel - assertEquals(FormStatus.InfoError, - sassena.process("I AM A VAGUE, INAPPROPRIATE PROCESS!")); - - // This portion will try to get the operation to write the information - // to xml file - assertEquals(FormStatus.Processed, sassena.process("Write to XML")); - - // Check to see if the file is created an exists. It will create a file - // in relation to the Id of the item. - assertTrue(Files.exists(Paths.get(filePath))); - - - } - - @Test - public void checkLoadInput() { - SassenaIncoherentModel sassena = new SassenaIncoherentModel(projectSpace); - sassena.loadInput("sassenaInc.xml"); - EMFComponent component = (EMFComponent) sassena.getForm().getComponent(1); - assertNotNull(component); - assertNotNull(component.getEMFTreeComposite()); - assertTrue("DocumentRoot".equals(component.getEMFTreeComposite().getName())); - } -} diff --git a/org.eclipse.ice.sassena/.classpath b/org.eclipse.ice.sassena/.classpath deleted file mode 100644 index 098194ca4..000000000 --- a/org.eclipse.ice.sassena/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.sassena/.gitignore b/org.eclipse.ice.sassena/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.sassena/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.sassena/.project b/org.eclipse.ice.sassena/.project deleted file mode 100644 index 0b8ec014e..000000000 --- a/org.eclipse.ice.sassena/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - org.eclipse.ice.sassena - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.sassena/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.sassena/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f42de363a..000000000 --- a/org.eclipse.ice.sassena/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/org.eclipse.ice.sassena/META-INF/MANIFEST.MF b/org.eclipse.ice.sassena/META-INF/MANIFEST.MF deleted file mode 100644 index 0b3ae4d6e..000000000 --- a/org.eclipse.ice.sassena/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Sassena -Bundle-SymbolicName: org.eclipse.ice.sassena;singleton:=true -Bundle-Version: 2.1.8 -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Service-Component: OSGI-INF/*.xml -Import-Package: org.eclipse.ice.item, - org.slf4j;version="1.7.2" -Require-Bundle: org.eclipse.core.resources;bundle-version="3.8.101", - org.eclipse.core.runtime;bundle-version="3.9.100", - org.eclipse.ice.datastructures, - org.eclipse.core.filesystem;bundle-version="1.4.0" -Export-Package: org.eclipse.ice.sassena -Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.sassena/OSGI-INF/cohXsdcomponent.xml b/org.eclipse.ice.sassena/OSGI-INF/cohXsdcomponent.xml deleted file mode 100644 index 05bfd40d1..000000000 --- a/org.eclipse.ice.sassena/OSGI-INF/cohXsdcomponent.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.sassena/OSGI-INF/incXsdcomponent.xml b/org.eclipse.ice.sassena/OSGI-INF/incXsdcomponent.xml deleted file mode 100644 index 73178d826..000000000 --- a/org.eclipse.ice.sassena/OSGI-INF/incXsdcomponent.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.sassena/build.properties b/org.eclipse.ice.sassena/build.properties deleted file mode 100644 index e5b9c57bb..000000000 --- a/org.eclipse.ice.sassena/build.properties +++ /dev/null @@ -1,9 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/,\ - pom.xml,\ - .classpath,\ - .project,\ - plugin.xml diff --git a/org.eclipse.ice.sassena/plugin.xml b/org.eclipse.ice.sassena/plugin.xml deleted file mode 100644 index 8960f0a36..000000000 --- a/org.eclipse.ice.sassena/plugin.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - diff --git a/org.eclipse.ice.sassena/pom.xml b/org.eclipse.ice.sassena/pom.xml deleted file mode 100644 index 9d1387e00..000000000 --- a/org.eclipse.ice.sassena/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.sassena - eclipse-plugin - \ No newline at end of file diff --git a/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaCoherentModel.java b/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaCoherentModel.java deleted file mode 100644 index 42196962f..000000000 --- a/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaCoherentModel.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.sassena; - -import java.io.File; - -import javax.xml.bind.annotation.XmlRootElement; - -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.form.FormStatus; -import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.item.Item; -import org.eclipse.ice.item.ItemType; - -/** - * The SassenaCoherentModel extends the Item to provide a model generator for the - * Sassena Coherent input files. It uses an EMFComponent to map the Sassena schema to an - * Eclipse Modeling Framework Ecore model, which is then translated to an ICE - * TreeComposite to be visualized and edited by the user. - * - * @author Alex McCaskey - */ -@XmlRootElement(name = "SassenaCoherentModel") -public class SassenaCoherentModel extends Item { - - /** - * Reference to the main Sassena schema file. - */ - private static File xsdFile; - - /** - * The constructor. - * - */ - public SassenaCoherentModel() { - this(null); - } - - /** - * The constructor with a project space in which files should be - * manipulated. - * - * @param projectSpace - * The Eclipse project where files should be stored and from - * which they should be retrieved. - */ - public SassenaCoherentModel(IProject projectSpace) { - - // Call super - super(projectSpace); - - } - - /** - * This method sets up the SassenaCoherentModel Item's Form reference, specifically, - * it searches for the correct XML schema and creates an EMFComponent and - * adds it to the Form. - * - */ - @Override - protected void setupForm() { - - // Create the Form - EMFComponent emfComp = null; - form = new Form(); - form.setName("Sassena Coherent Model Builder"); - - // It could be the case that we've already created the EMFComponent, - // if so just skip this creation stuff - // if (!initialized) { - if (project != null && project.isAccessible()) { - - // Refresh the project space - try { - project.refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (CoreException e) { - logger.error(getClass().getName() + " Exception!",e); - } - - // Get the sassena folder and the correct XML schema - IFolder sassenaFolder = project.getFolder("sassena"); - IFile xsdIFile = sassenaFolder.getFile("sassenaCoh.xsd"); - - // If valid, create the Java file instance needed by - // the EMFComponent - if (xsdIFile.exists()) { - try { - xsdFile = EFS.getStore(xsdIFile.getLocationURI()) - .toLocalFile(0, new NullProgressMonitor()); - } catch (CoreException e) { - logger.error(getClass().getName() + " Exception!",e); - } - - // Create the EMFComponent - if (xsdFile != null) { - emfComp = new EMFComponent(xsdFile); - emfComp.setName("Sassena Coherent Model Editor"); - emfComp.setId(1); - } - - } else { - System.err - .println("Sassena Model Error. Cannot find requisite " - + "sassenaCoh.xsd schema file. No Sassena Coherent tree will be constructed."); - } - } - // } - - // If we've been successful, add it to the Form. - if (emfComp != null) { - form.addComponent(emfComp); - } - - return; - } - - /** - * This operation is used to setup the name and description of the model. - * - */ - @Override - protected void setupItemInfo() { - - // Local Declarations - String desc = "This item builds models based on a Sassena Coherent schema."; - - // Describe the Item - setName("Sassena Coherent Model Builder"); - setDescription(desc); - itemType = ItemType.Model; - - // Setup the action list. Remove key-value pair support. - // allowedActions.remove(taggedExportActionString); - allowedActions.add("Write to XML"); - - return; - } - - /** - * This method overrides Item.process to provide a process - * action that writes the EMFComponent to an XML file. - */ - @Override - public FormStatus process(String actionName) { - - // Local Declarations - FormStatus retStatus = FormStatus.InfoError; - EMFComponent emfComp = (EMFComponent) form.getComponent(1); - - // Make sure we've got the correct action - if (emfComp != null && actionName.equals("Write to XML")) { - // Get the file name - String fileName = xsdFile.getName().replaceAll(".xsd", ".xml"); - - // Create the IFile reference - IFile iFile = project.getFile(fileName); - try { - // Save the File - if (emfComp.save(EFS.getStore(iFile.getLocationURI()) - .toLocalFile(0, new NullProgressMonitor()))) { - retStatus = FormStatus.Processed; - } else { - retStatus = FormStatus.InfoError; - } - } catch (CoreException e) { - logger.error(getClass().getName() + " Exception!",e); - retStatus = FormStatus.InfoError; - } - } - - return retStatus; - } - - /** - * This method loads an existing XML file as an EMFComponent. - * - * @param input - * The name of the input input file, including the file extension - */ - @Override - public void loadInput(String input) { - - // Local Declarations - EMFComponent emfComp = (EMFComponent) form.getComponent(1); - String path = project.getFolder("sassena").getLocation().toOSString() - + System.getProperty("file.separator") + input; - if (emfComp != null) { - if (!emfComp.load(new File(path))) { - System.err.println("Invalid file passed to SassenaCoherentModel.loadInput"); - } - } - - return; - } - -} diff --git a/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaCoherentModelBuilder.java b/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaCoherentModelBuilder.java deleted file mode 100644 index dc7f360b9..000000000 --- a/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaCoherentModelBuilder.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.sassena; - -import org.eclipse.core.resources.IProject; -import org.eclipse.ice.item.AbstractItemBuilder; -import org.eclipse.ice.item.Item; -import org.eclipse.ice.item.ItemType; - -/** - * This class builds the SassenaCoherentModel. It inherits its operations from - * ItemBuilder. - * - * @author Alex McCaskey - */ -public class SassenaCoherentModelBuilder extends AbstractItemBuilder { - - /** - * The Constructor - */ - public SassenaCoherentModelBuilder() { - setName("Sassena Coherent Model"); - setType(ItemType.Model); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.item.AbstractItemBuilder#getInstance(org.eclipse.core.resources.IProject) - */ - @Override - public Item getInstance(IProject projectSpace) { - SassenaCoherentModel sassenaCoh = new SassenaCoherentModel(projectSpace); - sassenaCoh.setItemBuilderName(getItemName()); - return sassenaCoh; - } - -} diff --git a/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaIncoherentModel.java b/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaIncoherentModel.java deleted file mode 100644 index fa3c53c5d..000000000 --- a/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaIncoherentModel.java +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.sassena; - -import java.io.File; - -import javax.xml.bind.annotation.XmlRootElement; - -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.ice.datastructures.form.Form; -import org.eclipse.ice.datastructures.form.FormStatus; -import org.eclipse.ice.datastructures.form.emf.EMFComponent; -import org.eclipse.ice.item.Item; -import org.eclipse.ice.item.ItemType; - -/** - * The SassenaIncoherentModel extends the Item to provide a model generator for the - * Sassena Incohrent input files. It uses an EMFComponent to map the Sassena schema to an - * Eclipse Modeling Framework Ecore model, which is then translated to an ICE - * TreeComposite to be visualized and editted by the user. - * - * @author Alex McCaskey - */ -@XmlRootElement(name = "SassenaIncoherentModel") -public class SassenaIncoherentModel extends Item { - - /** - * Reference to the main Sassena Incoherent schema file. - */ - private static File xsdFile; - - /** - * The constructor. - * - */ - public SassenaIncoherentModel() { - this(null); - } - - /** - * The constructor with a project space in which files should be - * manipulated. - * - * @param projectSpace - * The Eclipse project where files should be stored and from - * which they should be retrieved. - */ - public SassenaIncoherentModel(IProject projectSpace) { - - // Call super - super(projectSpace); - - } - - /** - * This method sets up the SassenaIncoherentModel Item's Form reference, specifically, - * it searches for the correct XML schema and creates an EMFComponent and - * adds it to the Form. - * - */ - @Override - protected void setupForm() { - - // Create the Form - EMFComponent emfComp = null; - form = new Form(); - form.setName("Sassena Incoherent Model Builder"); - - // It could be the case that we've already created the EMFComponent, - // if so just skip this creation stuff - if (project != null && project.isAccessible()) { - - // Refresh the project space - try { - project.refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (CoreException e) { - logger.error(getClass().getName() + " Exception!",e); - } - - // Get the batml folder and the correct XML schema - IFolder sassenaFolder = project.getFolder("sassena"); - IFile xsdIFile = sassenaFolder.getFile("sassenaInc.xsd"); - - // If valid, create the Java file instance needed by - // the EMFComponent - if (xsdIFile.exists()) { - try { - xsdFile = EFS.getStore(xsdIFile.getLocationURI()) - .toLocalFile(0, new NullProgressMonitor()); - } catch (CoreException e) { - logger.error(getClass().getName() + " Exception!",e); - } - - // Create the EMFComponent - if (xsdFile != null) { - emfComp = new EMFComponent(xsdFile); - emfComp.setName("Sassena Incoherent Model Editor"); - emfComp.setId(1); - } - - } else { - System.err - .println("Sassena Incoherent Model Error. Cannot find requisite " - + "sassenaInc.xsd schema file. No Sassena Incoherent tree will be constructed."); - } - } - - // If we've been successful, add it to the Form. - if (emfComp != null) { - form.addComponent(emfComp); - } - - return; - } - - /** - * This operation is used to setup the name and description of the model. - * - */ - @Override - protected void setupItemInfo() { - - // Local Declarations - String desc = "This item builds models based on a Sassena Incoherent schema."; - - // Describe the Item - setName("Sassena Incoherent Model Builder"); - setDescription(desc); - itemType = ItemType.Model; - - // Setup the action list. Remove key-value pair support. - // allowedActions.remove(taggedExportActionString); - allowedActions.add("Write to XML"); - - return; - } - - /** - * This method overrides Item.process to provide a process - * action that writes the EMFComponent to an XML file. - */ - @Override - public FormStatus process(String actionName) { - - // Local Declarations - FormStatus retStatus = FormStatus.InfoError; - EMFComponent emfComp = (EMFComponent) form.getComponent(1); - - // Make sure we've got the correct action - if (emfComp != null && actionName.equals("Write to XML")) { - // Get the file name - String fileName = xsdFile.getName().replaceAll(".xsd", ".xml"); - - // Create the IFile reference - IFile iFile = project.getFile(fileName); - try { - // Save the File - if (emfComp.save(EFS.getStore(iFile.getLocationURI()) - .toLocalFile(0, new NullProgressMonitor()))) { - retStatus = FormStatus.Processed; - } else { - retStatus = FormStatus.InfoError; - } - } catch (CoreException e) { - logger.error(getClass().getName() + " Exception!",e); - retStatus = FormStatus.InfoError; - } - } - - return retStatus; - } - - /** - * This method loads an existing XML file as an EMFComponent. - * - * @param input - * The name of the input input file, including the file extension - */ - @Override - public void loadInput(String input) { - - // Local Declarations - EMFComponent emfComp = (EMFComponent) form.getComponent(1); - String path = project.getFolder("sassena").getLocation().toOSString() - + System.getProperty("file.separator") + input; - if (emfComp != null) { - if (!emfComp.load(new File(path))) { - System.err.println("Invalid file passed to SassenaCoherentModel.loadInput"); - } - } - return; - } - -} diff --git a/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaIncoherentModelBuilder.java b/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaIncoherentModelBuilder.java deleted file mode 100644 index 691c347bf..000000000 --- a/org.eclipse.ice.sassena/src/org/eclipse/ice/sassena/SassenaIncoherentModelBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.sassena; - -import org.eclipse.core.resources.IProject; -import org.eclipse.ice.item.AbstractItemBuilder; -import org.eclipse.ice.item.Item; -import org.eclipse.ice.item.ItemType; - -/** - * This class builds the Sassena Incoherent Model Builder. It inherits its - * operations from ItemBuilder. - * - * @author Scott Forest Hull II - */ -public class SassenaIncoherentModelBuilder extends AbstractItemBuilder { - - /** - * The Constructor - */ - public SassenaIncoherentModelBuilder() { - setName("Sassena Incoherent Model"); - setType(ItemType.Model); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ice.item.AbstractItemBuilder#getInstance(org.eclipse.core.resources.IProject) - */ - @Override - public Item getInstance(IProject projectSpace) { - SassenaIncoherentModel sassena = new SassenaIncoherentModel( - projectSpace); - sassena.setItemBuilderName(getItemName()); - return sassena; - } - -} diff --git a/org.eclipse.ice.tablecomponenttester/META-INF/MANIFEST.MF b/org.eclipse.ice.tablecomponenttester/META-INF/MANIFEST.MF index a1621eea9..b20362edf 100644 --- a/org.eclipse.ice.tablecomponenttester/META-INF/MANIFEST.MF +++ b/org.eclipse.ice.tablecomponenttester/META-INF/MANIFEST.MF @@ -7,13 +7,11 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: org.eclipse.core.resources;bundle-version="3.7.100", org.eclipse.core.runtime;bundle-version="3.7.0", org.eclipse.ice.datastructures, - org.eclipse.ice.reactor;bundle-version="2.0.0", org.eclipse.ice.analysistool;bundle-version="2.0.0" Service-Component: OSGi-INF/component.xml Import-Package: org.eclipse.ice.datastructures.ICEObject, org.eclipse.ice.datastructures.componentVisitor, org.eclipse.ice.datastructures.form, org.eclipse.ice.datastructures.resource, - org.eclipse.ice.item, - org.eclipse.ice.reactor + org.eclipse.ice.item Bundle-Vendor: Oak Ridge National Laboratory diff --git a/org.eclipse.ice.tablecomponenttester/src/org/eclipse/ice/tablecomponenttester/TableComponentTester.java b/org.eclipse.ice.tablecomponenttester/src/org/eclipse/ice/tablecomponenttester/TableComponentTester.java index a32744403..c267d4f4d 100644 --- a/org.eclipse.ice.tablecomponenttester/src/org/eclipse/ice/tablecomponenttester/TableComponentTester.java +++ b/org.eclipse.ice.tablecomponenttester/src/org/eclipse/ice/tablecomponenttester/TableComponentTester.java @@ -41,8 +41,6 @@ import org.eclipse.ice.datastructures.form.geometry.ICEGeometry; import org.eclipse.ice.datastructures.resource.ICEResource; import org.eclipse.ice.item.Item; -import org.eclipse.ice.reactor.LWRComponent; -import org.eclipse.ice.reactor.LWRComponentReader; import org.osgi.framework.Bundle; @XmlRootElement(name = "TableComponentTester") @@ -333,29 +331,6 @@ public void setup() { // Add the TreeComposite to the Form form.addComponent(parent); - // Find the ReactorEditor test file - get the bundle first - Bundle bundle = Platform - .getBundle("org.eclipse.ice.tablecomponenttester"); - String separator = System.getProperty("file.separator"); - Path testDataPath = new Path("data" + separator + "test_new.h5"); - URL testDataURL = FileLocator.find(bundle, testDataPath, null); - LWRComponentReader reader = new LWRComponentReader(); - LWRComponent lwrComponent; - try { - URI dataFileURI = FileLocator.toFileURL(testDataURL).toURI(); - System.out.println(dataFileURI); - lwrComponent = (LWRComponent) reader.read(dataFileURI); - lwrComponent.setId(999); - // Add the LWRComponent to the form - form.addComponent(lwrComponent); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return; } } diff --git a/org.eclipse.ice.ui.swtbot.test/src/org/eclipse/ice/ui/swtbot/test/FakeMaterialsDatabase.java b/org.eclipse.ice.ui.swtbot.test/src/org/eclipse/ice/ui/swtbot/test/FakeMaterialsDatabase.java index 6bc370d3d..5ab144bfb 100644 --- a/org.eclipse.ice.ui.swtbot.test/src/org/eclipse/ice/ui/swtbot/test/FakeMaterialsDatabase.java +++ b/org.eclipse.ice.ui.swtbot.test/src/org/eclipse/ice/ui/swtbot/test/FakeMaterialsDatabase.java @@ -14,17 +14,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Hashtable; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; import org.eclipse.ice.datastructures.form.Material; import org.eclipse.ice.materials.MaterialWritableTableFormat; import org.eclipse.ice.materials.XMLMaterialsDatabase; -import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.gui.TableFormat; /** diff --git a/org.eclipse.ice.vibe/src/org/eclipse/ice/vibe/kvPair/VibeKVPair.java b/org.eclipse.ice.vibe/src/org/eclipse/ice/vibe/kvPair/VibeKVPair.java index fee34829b..4efca60a1 100644 --- a/org.eclipse.ice.vibe/src/org/eclipse/ice/vibe/kvPair/VibeKVPair.java +++ b/org.eclipse.ice.vibe/src/org/eclipse/ice/vibe/kvPair/VibeKVPair.java @@ -26,7 +26,9 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; + import javax.xml.bind.annotation.XmlRootElement; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; diff --git a/org.eclipse.ice.vibe/src/org/eclipse/ice/vibe/kvPair/VibeKVPairBuilder.java b/org.eclipse.ice.vibe/src/org/eclipse/ice/vibe/kvPair/VibeKVPairBuilder.java index 995d1becb..1757a8d30 100644 --- a/org.eclipse.ice.vibe/src/org/eclipse/ice/vibe/kvPair/VibeKVPairBuilder.java +++ b/org.eclipse.ice.vibe/src/org/eclipse/ice/vibe/kvPair/VibeKVPairBuilder.java @@ -13,8 +13,8 @@ package org.eclipse.ice.vibe.kvPair; import org.eclipse.core.resources.IProject; -import org.eclipse.ice.item.Item; import org.eclipse.ice.item.AbstractItemBuilder; +import org.eclipse.ice.item.Item; import org.eclipse.ice.item.ItemType; /** diff --git a/org.eclipse.ice.viz.service.geometry.test/src/org/eclipse/ice/viz/service/geometry/shapes/test/AbstractShapeTester.java b/org.eclipse.ice.viz.service.geometry.test/src/org/eclipse/ice/viz/service/geometry/shapes/test/AbstractShapeTester.java index fd4d00e8a..9ceac70e1 100644 --- a/org.eclipse.ice.viz.service.geometry.test/src/org/eclipse/ice/viz/service/geometry/shapes/test/AbstractShapeTester.java +++ b/org.eclipse.ice.viz.service.geometry.test/src/org/eclipse/ice/viz/service/geometry/shapes/test/AbstractShapeTester.java @@ -12,7 +12,12 @@ *******************************************************************************/ package org.eclipse.ice.viz.service.geometry.shapes.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.eclipse.ice.viz.service.geometry.shapes.Transformation; import org.junit.Test; diff --git a/org.eclipse.ice.viz.service.geometry/src/org/eclipse/ice/viz/service/geometry/shapes/AbstractShape.java b/org.eclipse.ice.viz.service.geometry/src/org/eclipse/ice/viz/service/geometry/shapes/AbstractShape.java index dd621a207..eb08f0d35 100644 --- a/org.eclipse.ice.viz.service.geometry/src/org/eclipse/ice/viz/service/geometry/shapes/AbstractShape.java +++ b/org.eclipse.ice.viz.service.geometry/src/org/eclipse/ice/viz/service/geometry/shapes/AbstractShape.java @@ -20,8 +20,8 @@ import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlTransient; -import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject; import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateableListener; +import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject; /** *

diff --git a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/EdgeControllerTester.java b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/EdgeControllerTester.java index a83fe5340..e3fb8d729 100644 --- a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/EdgeControllerTester.java +++ b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/EdgeControllerTester.java @@ -21,15 +21,12 @@ import org.eclipse.ice.viz.service.jme3.mesh.AbstractMeshController; import org.eclipse.ice.viz.service.jme3.mesh.EdgeController; -import org.eclipse.ice.viz.service.jme3.mesh.EdgeView; import org.eclipse.ice.viz.service.jme3.mesh.test.EdgeControllerTester.TestEdgeController.TestPropertyHandler; import org.eclipse.ice.viz.service.mesh.datastructures.Edge; import org.eclipse.ice.viz.service.mesh.datastructures.Vertex; -import org.junit.Ignore; import org.junit.Test; import com.jme3.material.Material; -import com.jme3.scene.shape.Line; /** *

diff --git a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/JME3MeshCanvasTester.java b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/JME3MeshCanvasTester.java index 569abb502..ba5e6f635 100644 --- a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/JME3MeshCanvasTester.java +++ b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/JME3MeshCanvasTester.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.ice.viz.service.jme3.mesh.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import java.util.List; diff --git a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/JME3MeshVizServiceTester.java b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/JME3MeshVizServiceTester.java index 4e04ebb67..1db2854f2 100644 --- a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/JME3MeshVizServiceTester.java +++ b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/JME3MeshVizServiceTester.java @@ -10,7 +10,9 @@ *******************************************************************************/ package org.eclipse.ice.viz.service.jme3.mesh.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject; import org.eclipse.ice.viz.service.jme3.mesh.JME3MeshCanvas; diff --git a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/MeshViewLauncher.java b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/MeshViewLauncher.java index 949e21a13..40169efc6 100644 --- a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/MeshViewLauncher.java +++ b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/MeshViewLauncher.java @@ -13,6 +13,7 @@ import org.eclipse.ice.viz.service.datastructures.VizActionTree; import org.eclipse.ice.viz.service.jme3.application.MasterApplication; +import org.eclipse.ice.viz.service.jme3.application.ViewAppState; import org.eclipse.ice.viz.service.jme3.mesh.IMeshSelectionListener; import org.eclipse.ice.viz.service.jme3.mesh.MeshAppState; import org.eclipse.ice.viz.service.jme3.mesh.MeshAppStateMode; diff --git a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/VertexControllerTester.java b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/VertexControllerTester.java index 4553f3b3e..98443c01c 100644 --- a/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/VertexControllerTester.java +++ b/org.eclipse.ice.viz.service.jme3.test/src/org/eclipse/ice/viz/service/jme3/mesh/test/VertexControllerTester.java @@ -22,7 +22,6 @@ import org.eclipse.ice.viz.service.jme3.mesh.StateType; import org.eclipse.ice.viz.service.jme3.mesh.VertexController; import org.eclipse.ice.viz.service.mesh.datastructures.Vertex; -import org.junit.Ignore; import org.junit.Test; import com.jme3.material.Material; diff --git a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/application/CompositeAppState.java b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/application/CompositeAppState.java index 3d043b1a4..c44e11321 100644 --- a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/application/CompositeAppState.java +++ b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/application/CompositeAppState.java @@ -15,8 +15,6 @@ import java.util.ArrayList; import java.util.List; -import org.eclipse.ice.viz.service.jme3.application.SimpleAppState; - import com.jme3.app.Application; import com.jme3.app.state.AppStateManager; diff --git a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/geometry/JME3GeometryCanvas.java b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/geometry/JME3GeometryCanvas.java index d64ebc8df..8d2961d4f 100644 --- a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/geometry/JME3GeometryCanvas.java +++ b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/geometry/JME3GeometryCanvas.java @@ -22,6 +22,19 @@ import java.util.Vector; import org.eclipse.ice.viz.service.IVizCanvas; +import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable; +import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateableListener; +import org.eclipse.ice.viz.service.geometry.shapes.ComplexShape; +import org.eclipse.ice.viz.service.geometry.shapes.Geometry; +import org.eclipse.ice.viz.service.geometry.shapes.IShape; +import org.eclipse.ice.viz.service.geometry.shapes.IShapeVisitor; +import org.eclipse.ice.viz.service.geometry.shapes.OperatorType; +import org.eclipse.ice.viz.service.geometry.shapes.PrimitiveShape; +import org.eclipse.ice.viz.service.geometry.shapes.ShapeType; +import org.eclipse.ice.viz.service.geometry.shapes.Transformation; +import org.eclipse.ice.viz.service.geometry.shapes.Tube; +import org.eclipse.ice.viz.service.geometry.widgets.ShapeMaterial; +import org.eclipse.ice.viz.service.geometry.widgets.ShapeTransient; import org.eclipse.swt.SWT; import org.eclipse.swt.awt.SWT_AWT; import org.eclipse.swt.widgets.Composite; @@ -51,20 +64,6 @@ import com.jme3.system.AppSettings; import com.jme3.system.JmeCanvasContext; -import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable; -import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateableListener; -import org.eclipse.ice.viz.service.geometry.shapes.ComplexShape; -import org.eclipse.ice.viz.service.geometry.shapes.Geometry; -import org.eclipse.ice.viz.service.geometry.shapes.IShape; -import org.eclipse.ice.viz.service.geometry.shapes.IShapeVisitor; -import org.eclipse.ice.viz.service.geometry.shapes.OperatorType; -import org.eclipse.ice.viz.service.geometry.shapes.PrimitiveShape; -import org.eclipse.ice.viz.service.geometry.shapes.ShapeType; -import org.eclipse.ice.viz.service.geometry.shapes.Transformation; -import org.eclipse.ice.viz.service.geometry.shapes.Tube; -import org.eclipse.ice.viz.service.geometry.widgets.ShapeMaterial; -import org.eclipse.ice.viz.service.geometry.widgets.ShapeTransient; - /** *

* The JME3 entry point for rendering the geometry editor viewport diff --git a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/geometry/JME3GeometryVizService.java b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/geometry/JME3GeometryVizService.java index c9327505a..d42f7c725 100644 --- a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/geometry/JME3GeometryVizService.java +++ b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/geometry/JME3GeometryVizService.java @@ -12,7 +12,6 @@ package org.eclipse.ice.viz.service.jme3.geometry; import java.util.HashSet; -import java.util.Map; import java.util.Set; import org.eclipse.ice.viz.service.AbstractVizService; diff --git a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/JME3MeshCanvas.java b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/JME3MeshCanvas.java index ae652e37c..0de92e44d 100644 --- a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/JME3MeshCanvas.java +++ b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/JME3MeshCanvas.java @@ -16,9 +16,9 @@ import java.util.Map; import java.util.concurrent.Callable; +import org.eclipse.ice.viz.service.IVizCanvas; import org.eclipse.ice.viz.service.jme3.application.MasterApplication; import org.eclipse.ice.viz.service.jme3.internal.MasterApplicationHolder; -import org.eclipse.ice.viz.service.IVizCanvas; import org.eclipse.ice.viz.service.mesh.datastructures.VizMeshComponent; import org.eclipse.swt.widgets.Composite; import org.slf4j.Logger; diff --git a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/JME3MeshVizService.java b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/JME3MeshVizService.java index c6d8ec714..979147f12 100644 --- a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/JME3MeshVizService.java +++ b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/JME3MeshVizService.java @@ -12,15 +12,12 @@ *******************************************************************************/ package org.eclipse.ice.viz.service.jme3.mesh; -import java.net.URI; import java.util.HashSet; import java.util.Set; import org.eclipse.ice.viz.service.AbstractVizService; -import org.eclipse.ice.viz.service.IPlot; import org.eclipse.ice.viz.service.IVizCanvas; import org.eclipse.ice.viz.service.datastructures.VizObject.IVizObject; -import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject; import org.eclipse.ice.viz.service.mesh.datastructures.VizMeshComponent; /** diff --git a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/MeshAppState.java b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/MeshAppState.java index 0e7291c45..f332939ad 100644 --- a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/MeshAppState.java +++ b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/MeshAppState.java @@ -22,11 +22,11 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantReadWriteLock; +import org.eclipse.ice.viz.service.jme3.application.CustomChaseCamera; import org.eclipse.ice.viz.service.jme3.application.EmbeddedView; +import org.eclipse.ice.viz.service.jme3.application.ICameraListener; import org.eclipse.ice.viz.service.jme3.application.MasterApplication; import org.eclipse.ice.viz.service.jme3.application.SimpleAppState; -import org.eclipse.ice.viz.service.jme3.application.CustomChaseCamera; -import org.eclipse.ice.viz.service.jme3.application.ICameraListener; import org.eclipse.ice.viz.service.jme3.application.ViewAppState; import org.eclipse.ice.viz.service.jme3.mesh.MeshAppStateModeFactory.Mode; import org.eclipse.ice.viz.service.jme3.widgets.InputControl; diff --git a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/MeshAppStateMode.java b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/MeshAppStateMode.java index e641fde28..c35280aa1 100644 --- a/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/MeshAppStateMode.java +++ b/org.eclipse.ice.viz.service.jme3/src/org/eclipse/ice/viz/service/jme3/mesh/MeshAppStateMode.java @@ -12,9 +12,9 @@ package org.eclipse.ice.viz.service.jme3.mesh; -import org.eclipse.ice.viz.service.jme3.application.SimpleAppState; import org.eclipse.ice.viz.service.jme3.application.CustomChaseCamera; import org.eclipse.ice.viz.service.jme3.application.ICameraListener; +import org.eclipse.ice.viz.service.jme3.application.SimpleAppState; import org.eclipse.ice.viz.service.jme3.widgets.InputControl; import com.jme3.input.InputManager; diff --git a/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/BoundaryConditionSection.java b/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/BoundaryConditionSection.java index 02cd4dc26..9e7ee0221 100644 --- a/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/BoundaryConditionSection.java +++ b/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/BoundaryConditionSection.java @@ -47,6 +47,7 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; +import org.eclipse.ui.views.properties.tabbed.ISection; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; /** diff --git a/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/GeneralInfoSection.java b/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/GeneralInfoSection.java index 7bc4e0f32..600009621 100644 --- a/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/GeneralInfoSection.java +++ b/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/GeneralInfoSection.java @@ -17,6 +17,7 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject; +import org.eclipse.ice.viz.service.mesh.datastructures.IMeshPart; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.SWT; diff --git a/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/TabDescriptorProvider.java b/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/TabDescriptorProvider.java index b46c93318..ad0125086 100644 --- a/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/TabDescriptorProvider.java +++ b/org.eclipse.ice.viz.service.mesh/src/org/eclipse/ice/viz/service/mesh/properties/TabDescriptorProvider.java @@ -19,6 +19,7 @@ import org.eclipse.ice.viz.service.mesh.datastructures.BezierEdge; import org.eclipse.ice.viz.service.mesh.datastructures.Edge; import org.eclipse.ice.viz.service.mesh.datastructures.Hex; +import org.eclipse.ice.viz.service.mesh.datastructures.IMeshPart; import org.eclipse.ice.viz.service.mesh.datastructures.IMeshPartVisitor; import org.eclipse.ice.viz.service.mesh.datastructures.Polygon; import org.eclipse.ice.viz.service.mesh.datastructures.PolynomialEdge; diff --git a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/connections/test/ConnectionPlotTester.java b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/connections/test/ConnectionPlotTester.java index 678549059..ea04fbfb1 100644 --- a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/connections/test/ConnectionPlotTester.java +++ b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/connections/test/ConnectionPlotTester.java @@ -11,7 +11,11 @@ *******************************************************************************/ package org.eclipse.ice.viz.service.connections.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.net.URI; import java.net.URISyntaxException; @@ -22,7 +26,6 @@ import org.eclipse.ice.viz.service.connections.IVizConnection; import org.eclipse.ice.viz.service.connections.VizConnection; import org.eclipse.swt.widgets.Composite; -import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/csv/test/CSVVizServiceTester.java b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/csv/test/CSVVizServiceTester.java index 3ba381c1e..32814b064 100644 --- a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/csv/test/CSVVizServiceTester.java +++ b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/csv/test/CSVVizServiceTester.java @@ -24,7 +24,6 @@ import org.eclipse.ice.viz.service.IPlot; import org.eclipse.ice.viz.service.IVizService; -import org.eclipse.ice.viz.service.csv.CSVPlot; import org.eclipse.ice.viz.service.csv.CSVProxyPlot; import org.eclipse.ice.viz.service.csv.CSVVizService; import org.junit.Test; diff --git a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/csv/test/PlotProviderTester.java b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/csv/test/PlotProviderTester.java index b0e186317..e6151fb33 100644 --- a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/csv/test/PlotProviderTester.java +++ b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/csv/test/PlotProviderTester.java @@ -15,7 +15,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.util.ArrayList; diff --git a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/internal/test/VizServiceFactoryHolderTester.java b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/internal/test/VizServiceFactoryHolderTester.java index a4a7b113e..c255b6020 100644 --- a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/internal/test/VizServiceFactoryHolderTester.java +++ b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/internal/test/VizServiceFactoryHolderTester.java @@ -11,9 +11,10 @@ *******************************************************************************/ package org.eclipse.ice.viz.service.internal.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; -import org.eclipse.ice.viz.service.BasicVizServiceFactory; import org.eclipse.ice.viz.service.IVizService; import org.eclipse.ice.viz.service.IVizServiceFactory; import org.eclipse.ice.viz.service.internal.VizServiceFactoryHolder; diff --git a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/CSVVizServiceTester.java b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/CSVVizServiceTester.java index 3d8b99a05..76e5d6ab9 100644 --- a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/CSVVizServiceTester.java +++ b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/CSVVizServiceTester.java @@ -24,7 +24,6 @@ import org.eclipse.ice.viz.service.IPlot; import org.eclipse.ice.viz.service.IVizService; -import org.eclipse.ice.viz.service.csv.CSVPlot; import org.eclipse.ice.viz.service.csv.CSVProxyPlot; import org.eclipse.ice.viz.service.csv.CSVVizService; import org.junit.Test; diff --git a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/FakePlot.java b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/FakePlot.java index 1a5e8fe64..d1697859d 100644 --- a/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/FakePlot.java +++ b/org.eclipse.ice.viz.service.test/src/org/eclipse/ice/viz/service/test/FakePlot.java @@ -17,10 +17,10 @@ import java.util.List; import java.util.Map; -import org.eclipse.ice.viz.service.widgets.PlotGridComposite; import org.eclipse.ice.viz.service.IPlot; import org.eclipse.ice.viz.service.ISeries; import org.eclipse.ice.viz.service.csv.CSVSeries; +import org.eclipse.ice.viz.service.widgets.PlotGridComposite; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; diff --git a/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItVizService.java b/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItVizService.java index ce98f068a..862ee3041 100644 --- a/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItVizService.java +++ b/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItVizService.java @@ -14,7 +14,6 @@ package org.eclipse.ice.viz.service.visit; import java.util.HashSet; -import java.util.Map; import java.util.Set; import org.eclipse.ice.viz.service.connections.ConnectionPlot; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/AbstractVizService.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/AbstractVizService.java index 1ebdc0301..f071e3dda 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/AbstractVizService.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/AbstractVizService.java @@ -17,7 +17,6 @@ import java.util.TreeSet; import org.eclipse.ice.viz.service.datastructures.VizObject.IVizObject; -import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject; import org.eclipse.ice.viz.service.preferences.CustomScopedPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/IVizService.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/IVizService.java index 9d245c27d..afae08d45 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/IVizService.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/IVizService.java @@ -13,11 +13,9 @@ package org.eclipse.ice.viz.service; import java.net.URI; -import java.util.Map; import java.util.Set; import org.eclipse.ice.viz.service.datastructures.VizObject.IVizObject; -import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject; /** * This is a pluggable service interface whereby visualization engines can diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/ConnectionPlot.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/ConnectionPlot.java index e04371890..8582350e4 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/ConnectionPlot.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/ConnectionPlot.java @@ -12,12 +12,12 @@ package org.eclipse.ice.viz.service.connections; import java.io.IOException; -import java.net.InetAddress; +import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; import org.eclipse.ice.viz.service.AbstractPlot; -import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable; +import org.eclipse.ice.viz.service.IPlot; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; import org.eclipse.swt.events.DisposeEvent; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/IConnectionAdapter.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/IConnectionAdapter.java index 330481377..4cd72e216 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/IConnectionAdapter.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/IConnectionAdapter.java @@ -13,6 +13,7 @@ import java.util.List; +import org.eclipse.ice.viz.service.connections.preferences.ConnectionTable; import org.eclipse.ice.viz.service.datastructures.VizEntry; import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/preferences/FileComboBoxCellEditor.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/preferences/FileComboBoxCellEditor.java index 341741896..c11dc1789 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/preferences/FileComboBoxCellEditor.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/preferences/FileComboBoxCellEditor.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.ice.viz.service.connections.preferences; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/preferences/PortEntryContentProvider.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/preferences/PortEntryContentProvider.java index 739eae9b3..de3188445 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/preferences/PortEntryContentProvider.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/connections/preferences/PortEntryContentProvider.java @@ -11,7 +11,7 @@ *******************************************************************************/ package org.eclipse.ice.viz.service.connections.preferences; -import java.util.ArrayList; +import java.util.ArrayList; import java.util.List; import org.eclipse.ice.viz.service.datastructures.BasicVizEntryContentProvider; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlot.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlot.java index d8c1d7c41..7698409b6 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlot.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlot.java @@ -19,7 +19,6 @@ import java.io.IOException; import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlotEditor.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlotEditor.java index 4ae4bcb52..fc3bb876a 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlotEditor.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVPlotEditor.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.Map; -import org.eclipse.swt.widgets.Composite; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.draw2d.LightweightSystem; import org.eclipse.ice.viz.service.ISeries; @@ -47,6 +46,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Slider; import org.eclipse.swt.widgets.Text; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVVizService.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVVizService.java index afce632b9..5c97144c1 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVVizService.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/csv/CSVVizService.java @@ -21,7 +21,6 @@ import org.eclipse.ice.viz.service.IPlot; import org.eclipse.ice.viz.service.IVizCanvas; import org.eclipse.ice.viz.service.datastructures.VizObject.IVizObject; -import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject; /** * This class implements the IVizService interface to provide CSV plotting tools diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/IVizObject.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/IVizObject.java index a448134a5..51acb474e 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/IVizObject.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/IVizObject.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.ice.viz.service.datastructures.VizObject; +import com.sun.corba.se.spi.ior.Identifiable; + /** *

* VizObject is the base class for all common, shared data structures in Viz diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/VizListComponent.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/VizListComponent.java index d226444c8..70a66bec9 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/VizListComponent.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/VizListComponent.java @@ -22,6 +22,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.sun.corba.se.spi.ior.Identifiable; + import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.TransformedList; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/VizObject.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/VizObject.java index 92b16730d..60b3ae676 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/VizObject.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/VizObject/VizObject.java @@ -21,6 +21,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.sun.corba.se.spi.ior.Identifiable; + /** *

* VizObject is the base class for all common, shared data structures in Viz diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/resource/IResource.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/resource/IResource.java index bfcf8a8fd..95cffabbb 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/resource/IResource.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/resource/IResource.java @@ -17,8 +17,6 @@ import java.net.URI; import java.util.ArrayList; -import javax.xml.bind.annotation.XmlTransient; - import org.eclipse.ice.viz.service.datastructures.VizEntry; import org.eclipse.ice.viz.service.datastructures.VizObject.IVizObject; diff --git a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/resource/VisualizationResource.java b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/resource/VisualizationResource.java index 0544413d5..42bd74c2f 100644 --- a/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/resource/VisualizationResource.java +++ b/org.eclipse.ice.viz.service/src/org/eclipse/ice/viz/service/datastructures/resource/VisualizationResource.java @@ -25,7 +25,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; diff --git a/org.eclipse.ice.viz.test/src/org/eclipse/ice/viz/test/PlotEntryContentProviderTester.java b/org.eclipse.ice.viz.test/src/org/eclipse/ice/viz/test/PlotEntryContentProviderTester.java index 1d0bf0c30..28c023002 100644 --- a/org.eclipse.ice.viz.test/src/org/eclipse/ice/viz/test/PlotEntryContentProviderTester.java +++ b/org.eclipse.ice.viz.test/src/org/eclipse/ice/viz/test/PlotEntryContentProviderTester.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.ice.viz.test; -import static org.junit.Assert.*; +import static org.junit.Assert.fail; import org.junit.Ignore; import org.junit.Test; diff --git a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/AddRemoteFileAction.java b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/AddRemoteFileAction.java index 0b87be3fc..33766afd1 100644 --- a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/AddRemoteFileAction.java +++ b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/AddRemoteFileAction.java @@ -12,10 +12,6 @@ *******************************************************************************/ package org.eclipse.ice.viz; -import gov.lbnl.visit.swt.VisItRemoteFileDialog; -import gov.lbnl.visit.swt.VisItSwtConnection; -import gov.lbnl.visit.swt.VisItSwtWidget; - import java.io.File; import java.io.IOException; @@ -31,6 +27,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import gov.lbnl.visit.swt.VisItRemoteFileDialog; +import gov.lbnl.visit.swt.VisItSwtConnection; +import gov.lbnl.visit.swt.VisItSwtWidget; + /** * This Action presents a {@link VisItRemoteFileDialog} to select files from a * remote file system and add them to the {@link VizFileViewer}. diff --git a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/VizFileViewer.java b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/VizFileViewer.java index d88eba8a2..171171944 100644 --- a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/VizFileViewer.java +++ b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/VizFileViewer.java @@ -14,9 +14,9 @@ import java.io.File; import java.io.IOException; +import java.net.URI; import java.util.ArrayList; import java.util.Iterator; -import java.net.URI; import org.eclipse.ice.viz.service.PlotEditor; import org.eclipse.ice.viz.service.PlotEditorInput; diff --git a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/AddVisitPlotAction.java b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/AddVisitPlotAction.java index 785300c72..9c40a1f5d 100644 --- a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/AddVisitPlotAction.java +++ b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/AddVisitPlotAction.java @@ -22,12 +22,12 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.ice.viz.PlotEntryContentProvider; +import org.eclipse.ice.viz.VizFileViewer; import org.eclipse.ice.viz.service.datastructures.IVizEntryContentProvider; import org.eclipse.ice.viz.service.datastructures.VizEntry; import org.eclipse.ice.viz.service.datastructures.resource.IResource; import org.eclipse.ice.viz.service.datastructures.resource.IVizResource; import org.eclipse.ice.viz.service.widgets.TreeSelectionDialogProvider; -import org.eclipse.ice.viz.VizFileViewer; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; diff --git a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/LaunchPythonScriptDialogAction.java b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/LaunchPythonScriptDialogAction.java index 18661dd52..dd46fd82a 100644 --- a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/LaunchPythonScriptDialogAction.java +++ b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/LaunchPythonScriptDialogAction.java @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.ice.viz.visit; -import gov.lbnl.visit.swt.VisItSwtWidget; - import java.net.URL; import org.eclipse.core.runtime.FileLocator; @@ -28,6 +26,8 @@ import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; +import gov.lbnl.visit.swt.VisItSwtWidget; + /** * */ diff --git a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/LaunchVisitWizardPage.java b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/LaunchVisitWizardPage.java index 3e9309e67..f09307347 100644 --- a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/LaunchVisitWizardPage.java +++ b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/LaunchVisitWizardPage.java @@ -12,9 +12,6 @@ *******************************************************************************/ package org.eclipse.ice.viz.visit; -import gov.lbnl.visit.swt.VisItSwtConnection; -import gov.lbnl.visit.swt.VisItSwtConnectionManager; - import java.io.IOException; import java.net.Socket; import java.util.List; @@ -40,6 +37,9 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import gov.lbnl.visit.swt.VisItSwtConnection; +import gov.lbnl.visit.swt.VisItSwtConnectionManager; + /** * This class extends WizardPage to create the Wizard content to allow the user * to establish a VisIt client connection. This connection may be via a local or diff --git a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitEditor.java b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitEditor.java index 7a2cd13ba..d6a153ea0 100644 --- a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitEditor.java +++ b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitEditor.java @@ -12,10 +12,6 @@ *******************************************************************************/ package org.eclipse.ice.viz.visit; -import gov.lbnl.visit.swt.VisItSwtConnection; -import gov.lbnl.visit.swt.VisItSwtConnectionManager; -import gov.lbnl.visit.swt.VisItSwtWidget; - import java.util.HashMap; import org.eclipse.core.runtime.IProgressMonitor; @@ -39,6 +35,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import gov.lbnl.visit.swt.VisItSwtConnection; +import gov.lbnl.visit.swt.VisItSwtConnectionManager; +import gov.lbnl.visit.swt.VisItSwtWidget; + /** * This is an editor for interacting with the VisIt SWT Widget. It is opened by * the associated visualization views in org.eclipse.ice.viz. diff --git a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitMouseManager.java b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitMouseManager.java index 4683ae16b..9ef860c98 100644 --- a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitMouseManager.java +++ b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitMouseManager.java @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.ice.viz.visit; -import gov.lbnl.visit.swt.VisItSwtWidget; - import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicBoolean; @@ -24,6 +22,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import gov.lbnl.visit.swt.VisItSwtWidget; + /** * This class is used for managing a daemon thread for processing mouse input. * Mouse locations are continuously passed to instances of this class via a diff --git a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitPlotViewer.java b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitPlotViewer.java index fa37f44a2..8f603eb52 100644 --- a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitPlotViewer.java +++ b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitPlotViewer.java @@ -12,9 +12,6 @@ *******************************************************************************/ package org.eclipse.ice.viz.visit; -import gov.lbnl.visit.swt.VisItSwtWidget; -import gov.lbnl.visit.swt.widgets.TimeSliderWidget; - import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -61,6 +58,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import gov.lbnl.visit.swt.VisItSwtWidget; +import gov.lbnl.visit.swt.widgets.TimeSliderWidget; + /** * This class extends the ViewPart class and provides a view in the * Visualization Perspective to look at the plots that are currently available. diff --git a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitPythonDialog.java b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitPythonDialog.java index 1979fb831..8f6795882 100644 --- a/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitPythonDialog.java +++ b/org.eclipse.ice.viz/src/org/eclipse/ice/viz/visit/VisitPythonDialog.java @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.ice.viz.visit; -import gov.lbnl.visit.swt.VisItSwtWidget; - import java.io.BufferedReader; import java.io.FileReader; import java.util.List; @@ -46,6 +44,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import gov.lbnl.visit.swt.VisItSwtWidget; import visit.java.client.AttributeSubject; import visit.java.client.AttributeSubject.AttributeSubjectCallback; diff --git a/org.eclipse.ice.xolotl/.classpath b/org.eclipse.ice.xolotl/.classpath deleted file mode 100644 index 098194ca4..000000000 --- a/org.eclipse.ice.xolotl/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.xolotl/.gitignore b/org.eclipse.ice.xolotl/.gitignore deleted file mode 100644 index 934e0e06f..000000000 --- a/org.eclipse.ice.xolotl/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/target diff --git a/org.eclipse.ice.xolotl/.project b/org.eclipse.ice.xolotl/.project deleted file mode 100644 index 0c8694a25..000000000 --- a/org.eclipse.ice.xolotl/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - org.eclipse.ice.xolotl - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.eclipse.ice.xolotl/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ice.xolotl/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 14d39a9d8..000000000 --- a/org.eclipse.ice.xolotl/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.objectteams.otdt.compiler.option.pure_java=enabled diff --git a/org.eclipse.ice.xolotl/.settings/org.eclipse.pde.core.prefs b/org.eclipse.ice.xolotl/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index f29e940a0..000000000 --- a/org.eclipse.ice.xolotl/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -pluginProject.extensions=false -resolve.requirebundle=false diff --git a/org.eclipse.ice.xolotl/META-INF/MANIFEST.MF b/org.eclipse.ice.xolotl/META-INF/MANIFEST.MF deleted file mode 100644 index bf95b347e..000000000 --- a/org.eclipse.ice.xolotl/META-INF/MANIFEST.MF +++ /dev/null @@ -1,12 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Xolotl -Bundle-SymbolicName: org.eclipse.ice.xolotl;singleton:=true -Bundle-Version: 2.1.8 -Bundle-Vendor: Oak Ridge National Laboratory -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: org.eclipse.ice.datastructures, - org.eclipse.core.resources;bundle-version="3.8.101" -Import-Package: org.eclipse.ice.item, - org.eclipse.ice.item.jobLauncher -Service-Component: OSGI-INF/XolotlLauncher.xml diff --git a/org.eclipse.ice.xolotl/OSGI-INF/XolotlLauncher.xml b/org.eclipse.ice.xolotl/OSGI-INF/XolotlLauncher.xml deleted file mode 100644 index 4c35183cf..000000000 --- a/org.eclipse.ice.xolotl/OSGI-INF/XolotlLauncher.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.eclipse.ice.xolotl/build.properties b/org.eclipse.ice.xolotl/build.properties deleted file mode 100644 index 1e42778df..000000000 --- a/org.eclipse.ice.xolotl/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/XolotlLauncher.xml,\ - plugin.xml -source.. = src/ diff --git a/org.eclipse.ice.xolotl/plugin.xml b/org.eclipse.ice.xolotl/plugin.xml deleted file mode 100644 index 37a9b754a..000000000 --- a/org.eclipse.ice.xolotl/plugin.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/org.eclipse.ice.xolotl/pom.xml b/org.eclipse.ice.xolotl/pom.xml deleted file mode 100644 index 0a7fd2434..000000000 --- a/org.eclipse.ice.xolotl/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - ICE - org.eclipse.ice.build - 2.1.8 - ../${pom-filename} - - ICE - org.eclipse.ice.xolotl - eclipse-plugin - \ No newline at end of file diff --git a/org.eclipse.ice.xolotl/src/org/eclipse/ice/xolotl/XolotlLauncher.java b/org.eclipse.ice.xolotl/src/org/eclipse/ice/xolotl/XolotlLauncher.java deleted file mode 100644 index 509915cb4..000000000 --- a/org.eclipse.ice.xolotl/src/org/eclipse/ice/xolotl/XolotlLauncher.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.xolotl; - -import javax.xml.bind.annotation.XmlRootElement; - -import org.eclipse.core.resources.IProject; -import org.eclipse.ice.item.jobLauncher.JobLauncher; - -/** - * A JobLauncher for Xolotl, a Plasma-Surface Interactions Simulator. - * - * @author Jay Jay Billings - * - */ -@XmlRootElement(name = "XolotlLauncher") -public class XolotlLauncher extends JobLauncher { - - /** - * The default constructor. - * - * @param project - * The Eclipse project space where this launchers files are - * stored. - */ - public XolotlLauncher(IProject project) { - super(project); - } - - /** - * Nullary constructor. - */ - public XolotlLauncher() { - this(null); - } - - /** - * This operation overrides the base class implementation of setupForm to - * configure the launcher's Form. - */ - @Override - public void setupForm() { - - // Setup the base JobLauncher form on the base class - super.setupForm(); - - // Create the command that will be launched and set the install - // directory - String cmd = "./xolotl params.txt"; - String installDir = "/lustre/atlas/proj-shared/fus049/" - + "xolotl-psi-trunk/release-build"; - String networkFileDescription = "The file that contains the " - + "network in HDF5 format."; - - // Configure the host - addHost("titan.ccs.ornl.gov", "linux", installDir); - setExecutable(XolotlLauncherBuilder.name, - "The Plasma-Surface Interactions Simulator", cmd); - // Turn MPI on since this is Titan after all! - enableMPI(1, 100000, 100); - - // Add the network file to the list of required inputs - addInputType("Network File (HDF5)", "networkFile", - networkFileDescription, ".h5"); - - return; - } - - /** - * This operation sets the name and description for this launcher. - */ - @Override - public void setupItemInfo() { - setDescription("The Plasma-Surface Interactions Simulator"); - setItemBuilderName(XolotlLauncherBuilder.name); - setName(XolotlLauncherBuilder.name); - } - -} diff --git a/org.eclipse.ice.xolotl/src/org/eclipse/ice/xolotl/XolotlLauncherBuilder.java b/org.eclipse.ice.xolotl/src/org/eclipse/ice/xolotl/XolotlLauncherBuilder.java deleted file mode 100644 index 67a8a3c04..000000000 --- a/org.eclipse.ice.xolotl/src/org/eclipse/ice/xolotl/XolotlLauncherBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2014 UT-Battelle, LLC. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Initial API and implementation and/or initial documentation - Jay Jay Billings, - * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, - * Claire Saunders, Matthew Wang, Anna Wojtowicz - *******************************************************************************/ -package org.eclipse.ice.xolotl; - -import org.eclipse.core.resources.IProject; -import org.eclipse.ice.item.AbstractItemBuilder; -import org.eclipse.ice.item.Item; -import org.eclipse.ice.item.ItemType; - -/** - * The ItemBuilder that provides the XolotlLauncher to the framework. - * @author Jay Jay Billings - * - */ -public class XolotlLauncherBuilder extends AbstractItemBuilder { - - // The name - public static final String name = "Xolotl Launcher"; - - // The type - public static final ItemType type = ItemType.Simulation; - - /** - * The Constructor - */ - public XolotlLauncherBuilder() { - setName(name); - setType(type); - } - - /* (non-Javadoc) - * @see org.eclipse.ice.item.ItemBuilder#build(org.eclipse.core.resources.IProject) - */ - @Override - public Item getInstance(IProject projectSpace) { - - XolotlLauncher launcher = new XolotlLauncher(projectSpace); - return launcher; - } - -} diff --git a/pom.xml b/pom.xml index c296b61af..a55fbdc08 100644 --- a/pom.xml +++ b/pom.xml @@ -75,14 +75,6 @@ org.eclipse.ice.client.widgets org.eclipse.ice.client.widgets.moose org.eclipse.ice.client.widgets.moose.test - org.eclipse.ice.client.widgets.reactoreditor - org.eclipse.ice.client.widgets.reactoreditor.test - org.eclipse.ice.client.widgets.reactoreditor.grid - org.eclipse.ice.client.widgets.reactoreditor.grid.test - org.eclipse.ice.client.widgets.reactoreditor.lwr - org.eclipse.ice.client.widgets.reactoreditor.lwr.test - org.eclipse.ice.client.widgets.reactoreditor.sfr - org.eclipse.ice.client.widgets.reactoreditor.sfr.test org.eclipse.ice.client.widgets.rcp org.eclipse.ice.client.widgets.test org.eclipse.ice.client.widgets.test.utils @@ -101,15 +93,8 @@ org.eclipse.ice.io org.eclipse.ice.io.test org.eclipse.ice.analysistool - org.eclipse.ice.reactor - org.eclipse.ice.reactor.test - org.eclipse.ice.reactor.sfr - org.eclipse.ice.reactor.sfr.test org.eclipse.ice.reactor.plant org.eclipse.ice.reactor.plant.test - org.eclipse.ice.reactor.perspective - org.eclipse.ice.reactorAnalyzer - org.eclipse.ice.reactorAnalyzer.test org.eclipse.ice.vibe org.eclipse.ice.vibe.test org.eclipse.ice.kdd @@ -136,14 +121,11 @@ org.eclipse.ice.viz.service.paraview org.eclipse.ice.viz.service.paraview.web org.eclipse.ice.viz.service.paraview.test - org.eclipse.ice.xolotl org.eclipse.ice.materials org.eclipse.ice.materials.test org.eclipse.ice.materials.ui org.eclipse.ice.caebat.batml org.eclipse.ice.caebat.batml.test - org.eclipse.ice.sassena - org.eclipse.ice.sassena.test org.eclipse.ice.reflectivity org.eclipse.ice.reflectivity.test org.eclipse.ice.reflectivity.ui