diff options
author | Matthew Davis | 2011-07-15 17:34:33 +0000 |
---|---|---|
committer | Matthew Davis | 2011-07-15 17:34:33 +0000 |
commit | 73306caa502102922e85be110d0e6d2c0d8f43e6 (patch) | |
tree | f8e0e1c9fc86e71a96a4c0ba100cbb54aceb4faf /population | |
parent | 07b9f2ad57f9339720e778bc02d22818a0081299 (diff) | |
download | org.eclipse.stem.data-73306caa502102922e85be110d0e6d2c0d8f43e6.tar.gz org.eclipse.stem.data-73306caa502102922e85be110d0e6d2c0d8f43e6.tar.xz org.eclipse.stem.data-73306caa502102922e85be110d0e6d2c0d8f43e6.zip |
repository restructure
git-svn-id: http://dev.eclipse.org/svnroot/technology/org.eclipse.stem/trunk/data@2192 92a21009-5b66-0410-b83a-dc787c41c6e9
Diffstat (limited to 'population')
9 files changed, 458 insertions, 0 deletions
diff --git a/population/org.eclipse.stem.internal.data.geography.population/.classpath b/population/org.eclipse.stem.internal.data.geography.population/.classpath new file mode 100644 index 0000000..304e861 --- /dev/null +++ b/population/org.eclipse.stem.internal.data.geography.population/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/population/org.eclipse.stem.internal.data.geography.population/.project b/population/org.eclipse.stem.internal.data.geography.population/.project new file mode 100644 index 0000000..49f5d31 --- /dev/null +++ b/population/org.eclipse.stem.internal.data.geography.population/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.stem.internal.data.geography.population</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/population/org.eclipse.stem.internal.data.geography.population/.settings/org.eclipse.jdt.core.prefs b/population/org.eclipse.stem.internal.data.geography.population/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..01426fa --- /dev/null +++ b/population/org.eclipse.stem.internal.data.geography.population/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Tue Jan 27 12:14:09 EST 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/population/org.eclipse.stem.internal.data.geography.population/META-INF/MANIFEST.MF b/population/org.eclipse.stem.internal.data.geography.population/META-INF/MANIFEST.MF new file mode 100644 index 0000000..ff374fe --- /dev/null +++ b/population/org.eclipse.stem.internal.data.geography.population/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: STEM Internal Population Data +Bundle-SymbolicName: org.eclipse.stem.internal.data.geography.population +Bundle-Version: 1.2.0 +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: org.eclipse.stem.core, + org.eclipse.stem.definitions, + org.eclipse.stem.data.geography, + org.eclipse.stem.internal.data, + org.eclipse.stem.internal.data.geography, + org.eclipse.stem.data.geography.population.human +Bundle-Vendor: Eclipse.org diff --git a/population/org.eclipse.stem.internal.data.geography.population/build.properties b/population/org.eclipse.stem.internal.data.geography.population/build.properties new file mode 100644 index 0000000..34d2e4d --- /dev/null +++ b/population/org.eclipse.stem.internal.data.geography.population/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/population/org.eclipse.stem.internal.data.geography.population/src/org/eclipse/stem/internal/data/geography/population/PopulationDataGenerator.java b/population/org.eclipse.stem.internal.data.geography.population/src/org/eclipse/stem/internal/data/geography/population/PopulationDataGenerator.java new file mode 100644 index 0000000..25adb64 --- /dev/null +++ b/population/org.eclipse.stem.internal.data.geography.population/src/org/eclipse/stem/internal/data/geography/population/PopulationDataGenerator.java @@ -0,0 +1,36 @@ +package org.eclipse.stem.internal.data.geography.population; + +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +import java.io.File; + +import org.eclipse.stem.internal.data.DataGenerator; +import org.eclipse.stem.internal.data.geography.GeographyPluginFileGenerator; + +/** + * This class is the Main entry point to the generation of + * {@link org.eclipse.stem.core.graph.Graph}s and + * {@link org.eclipse.stem.core.model.Model}s that represent Geography. + * + */ +public class PopulationDataGenerator extends DataGenerator { + /** + * @param args + * the path to the root of the plugin where this class is + * defined. + */ + public static void main(String[] args) { + final PopulationDataGenerator dg = new PopulationDataGenerator(); + final GeographyPluginFileGenerator gpfg = new GeographyPluginFileGenerator(); + gpfg.generatePluginFiles(dg.processFiles(args),args[0] + File.separator + ROOT_SERIALIZED_FILES, false); } // main + +} // Main diff --git a/population/org.eclipse.stem.internal.data.geography.population/src/org/eclipse/stem/internal/data/geography/propertydata/PopulationPropertyData.java b/population/org.eclipse.stem.internal.data.geography.population/src/org/eclipse/stem/internal/data/geography/propertydata/PopulationPropertyData.java new file mode 100644 index 0000000..7cbf45f --- /dev/null +++ b/population/org.eclipse.stem.internal.data.geography.population/src/org/eclipse/stem/internal/data/geography/propertydata/PopulationPropertyData.java @@ -0,0 +1,62 @@ +// PopulationPropertyData.java +package org.eclipse.stem.internal.data.geography.propertydata; + +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +import org.eclipse.stem.definitions.nodes.GeographicFeature; +import org.eclipse.stem.data.geography.ISOKey; + +/** + * This class contains the data from a property that specifies the number of + * individuals in a region. + */ +public class PopulationPropertyData extends GeographicFeaturePropertyData { + + // People, mosquitoes, etc. + String individuals = ""; //$NON-NLS-1$ + + /** + * @param isoKey + * the unique ISO-3166 identifier for the + * {@link GeographicFeature}. + * @param individuals + * the number of individuals + */ + public PopulationPropertyData(final ISOKey isoKey, final String individuals) { + super(isoKey); + this.individuals = individuals; + } // AreaData + + /** + * @return the number of individuals. + */ + public final String getPopulation() { + return individuals; + } + + /** + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return isoKey.toString() + " = " + individuals; //$NON-NLS-1$ + } // toString + + /** + * @return the area the population resides in, or <code>null</code>. + */ + public String getArea() { + // TODO Auto-generated method stub + return null; + } + +} // PopulationPropertyData diff --git a/population/org.eclipse.stem.internal.data.geography.population/src/org/eclipse/stem/internal/data/geography/specifications/CountryPopulationLabelPropertyFileSpecification.java b/population/org.eclipse.stem.internal.data.geography.population/src/org/eclipse/stem/internal/data/geography/specifications/CountryPopulationLabelPropertyFileSpecification.java new file mode 100644 index 0000000..7cc4d9c --- /dev/null +++ b/population/org.eclipse.stem.internal.data.geography.population/src/org/eclipse/stem/internal/data/geography/specifications/CountryPopulationLabelPropertyFileSpecification.java @@ -0,0 +1,146 @@ +package org.eclipse.stem.internal.data.geography.specifications; + +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +import java.util.Properties; + +import org.eclipse.stem.core.graph.Graph; +import org.eclipse.stem.core.graph.Node; +import org.eclipse.stem.core.graph.NodeLabel; +import org.eclipse.stem.data.geography.ISOKey; +import org.eclipse.stem.definitions.labels.LabelsFactory; +import org.eclipse.stem.definitions.labels.PopulationLabel; +import org.eclipse.stem.definitions.labels.impl.PopulationLabelImpl; +import org.eclipse.stem.definitions.nodes.impl.RegionImpl; +import org.eclipse.stem.internal.data.geography.propertydata.PopulationPropertyData; +import org.eclipse.stem.internal.data.propertydata.PropertyData; + +/** + * This class represents a {@link Graph} containing {@link PopulationLabel}s of + * {@link Node}s specific to a country. + */ +public class CountryPopulationLabelPropertyFileSpecification extends + CountryLabelPropertyFileSpecification { + /** + * This is the name used to identify "population" labels. + */ + public static final String POPULATION_LABEL_NAME = "population"; //$NON-NLS-1$ + + /** + * This is the property in a data file that specifies an identifier for the + * population (e.g., "human") + */ + public static final String POPULATION_PROPERTY = "POPULATION"; //$NON-NLS-1$ + + /** + * This is the property in a data file that specifies the year the + * population data is valid for. + */ + private static final String YEAR_PROPERTY = "YEAR"; //$NON-NLS-1$ + + /** + * This is the identifier of the population. + * + * @see CountryPopulationLabelPropertyFileSpecification#POPULATION_PROPERTY + */ + private String populationIdentifier = null; + + /** + * The year the population data is valid for. + */ + private String year; + + /** + * Constructor + */ + public CountryPopulationLabelPropertyFileSpecification() { + super(POPULATION_LABEL_NAME); + } // CountryPopulationLabelPropertyFileSpecification + + @Override + protected PropertyData createPropertyDataInstanceFromProperty( + final String dataPropertyKey, final String propertyValue) { + return new PopulationPropertyData(new ISOKey(dataPropertyKey), + propertyValue); + } // createDataSetData + + /** + * @see org.eclipse.stem.internal.data.geography.specifications.CountryGraphPropertyFileSpecification#collectNonDataProperties(java.util.Properties) + */ + @Override + protected void collectNonDataProperties(final Properties dataSetProperties) { + super.collectNonDataProperties(dataSetProperties); + populationIdentifier = dataSetProperties + .getProperty(POPULATION_PROPERTY); + year = dataSetProperties.getProperty(YEAR_PROPERTY); + dataSetProperties.remove(POPULATION_PROPERTY); + dataSetProperties.remove(YEAR_PROPERTY); + } // initialize + + @Override + protected NodeLabel createLabel(final AdminLevel adminLevel, + final ISOKey isoKey, final PropertyData graphData) { + final PopulationPropertyData populationData = (PopulationPropertyData) graphData; + final String nodeKey = populationData.getISOKey().toString(); + + final PopulationLabel retValue = LabelsFactory.eINSTANCE + .createPopulationLabel(); + retValue.setURI(PopulationLabelImpl.createPopulationLabelURI(adminLevel + .intValue(), isoKey.toString(), populationIdentifier, year, + nodeKey)); + retValue.setValidYear(Integer.parseInt(year)); + retValue.setURIOfIdentifiableToBeLabeled(RegionImpl + .createRegionNodeURI(nodeKey)); + retValue.setPopulationIdentifier(populationIdentifier); + retValue.getCurrentPopulationValue().setCount( + Long.parseLong(populationData.getPopulation())); + + // Was an area specified for the population? + if (populationData.getArea() != null) { + // Yes + retValue.setPopulatedArea(Double.parseDouble(populationData + .getArea())); + } + + return retValue; + } // createLabel + + @Override + protected String getTargetPluginId() { + return org.eclipse.stem.data.geography.population.human.Activator.PLUGIN_ID; + } + + @Override + protected String getSerializationFileNameRoot() { + final StringBuilder sb = new StringBuilder(isoKey.toString()); + sb.append("_"); //$NON-NLS-1$ + sb.append(adminLevel.toString()); + sb.append("_"); //$NON-NLS-1$ + sb.append(getSerializationContentDescriptor()); + sb.append("_"); //$NON-NLS-1$ + sb.append(labelName.toLowerCase()); + return sb.toString(); + } // getSerializationFileNameRoot + + protected String getSerializationContentDescriptor() { + final StringBuilder sb = new StringBuilder(); + sb.append(populationIdentifier); + sb.append("_"); //$NON-NLS-1$ + sb.append(createValidDateRangeString( + SERIALIZATION_CONTENT_DESCRIPTOR_DATE_FORMATER, + SERIALIZATION_DATE_RANGE_FORMAT_1_DATE, + SERIALIZATION_DATE_RANGE_FORMAT_2_DATES, + SERIALIZATION_DATE_RANGE_FORMAT_1_DATE_YEAR)); + return sb.toString(); + } // getSerializationContentDescriptor + +} // CountryPopulationLabelPropertyFileSpecification
\ No newline at end of file diff --git a/population/org.eclipse.stem.internal.data.geography.population/update.xml b/population/org.eclipse.stem.internal.data.geography.population/update.xml new file mode 100644 index 0000000..1d10ca5 --- /dev/null +++ b/population/org.eclipse.stem.internal.data.geography.population/update.xml @@ -0,0 +1,154 @@ +<?xml version="1.0"?> +<!-- ====================================================================== + ANT script to build org.eclispe.ohf.stem.geography project + and the initial set of STEM scenarios. + This must be run after installing the STEM workspace and after changes + to code generated by EMF models. + + ====================================================================== --> +<project name="STEM Internal Human Population Data" default="update_all"> + <description> + Use the properties files to populate the org.eclipse.stem.data.population.human plugin + </description> + + <!-- P r o j e c t S p e c i f i c a t i o n s --> + + <!-- The name of the project --> + <property name="project.name" value="stem" /> + + + <!-- Are we running headless? --> + <condition property="runningHeadless"> + <isset property="buildDirectory" /> + </condition> + + <!-- The buildDirectory property is set in a headless build --> + <condition property="pluginRootDirectory" value="${buildDirectory}/plugins" else=".."> + <isset property="runningHeadless" /> + </condition> + + <!-- The baseLocation property is the location of the eclipse home installation --> + <!-- It is used to find eclipse plugins --> + <!-- It is set in a headless build, but not one started manually from Eclipse --> + <condition property="baseLocation" value="${eclipse.pdebuild.home}../.."> + <not> + <isset property="runningHeadless" /> + </not> + </condition> + + <!-- This is the location of the class files of the built plug-ins --> + <!-- If this is a manual build started from Eclipse then the directory --> + <!-- is "bin", if its a headless build then the directory is "@dot" --> + <!-- The property baseLocation is set in a headless build --> + <condition property="targetBin" value="@dot" else="bin"> + <isset property="runningHeadless" /> + </condition> + + + <!-- The prefix for fully qualified names --> + <property name="ID_ROOT" value="org.eclipse.stem" /> + + <!-- The name of the source plugin (i.e., the one that contains this file --> + <property name="source.plugin" value="${ID_ROOT}.internal.data.geography.population" /> + + <!-- The name of the target plugin --> + <property name="target.plugin" value="${ID_ROOT}.data.geography.population" /> + + <!-- The path to the root directory of the source plugin --> + <property name="path.sourceplugin" location="${pluginRootDirectory}/${source.plugin}" /> + + <!-- The path to the root directory of the plugin that will be augmented with generated content --> + <property name="path.targetplugin" location="${pluginRootDirectory}/${target.plugin}" /> + + <!-- The path to the root directory of the resource files --> + <property name="path.resource.files" value="${path.sourceplugin}/resources/data/country" /> + + <!-- The path to the root directory of the plugin that will be augmented with generated content--> + <property name="path.generated.files" value="${path.sourceplugin}/temp/data" /> + + <!-- The path to the root directory of population source code --> + <property name="path.geography.src" value="${path.targetplugin}/src/org/eclipse/stem/data/population" /> + + <!-- The name of the plugin.xml file that will be augmented with generated content--> + <property name="file.target.pluginxml" value="${path.targetplugin}/plugin.xml" /> + + <!-- The name of the plugin.properties file that will be augmented with generated content--> + <property name="file.target.pluginproperties" value="${path.targetplugin}/plugin.properties" /> + + <!-- The name of the plugin.xml file that that is the aggregation of the generated content--> + <property name="file.util.pluginxml" value="${path.sourceplugin}/temp/data/plugin.xml" /> + + <!-- The name of the plugin.properties file that is the aggregation of the generated content--> + <property name="file.util.pluginproperties" value="${path.sourceplugin}/temp/data/plugin.properties" /> + + <!-- The class path to use --> + <path id="classpath.runtime"> + <pathelement location="${path.sourceplugin}/${targetBin}" /> + <pathelement location="${pluginRootDirectory}/${ID_ROOT}.core/${targetBin}" /> + <pathelement location="${pluginRootDirectory}/${ID_ROOT}.definitions/${targetBin}" /> + <pathelement location="${pluginRootDirectory}/${ID_ROOT}.internal.data/${targetBin}" /> + <pathelement location="${pluginRootDirectory}/${ID_ROOT}.data.population/${targetBin}" /> + <fileset dir="${baseLocation}/plugins/"> + <include name="*emf*.jar" /> + </fileset> + <fileset dir="${pluginRootDirectory}/${ID_ROOT}.internal.data/lib/"> + <include name="*emf*.jar" /> + </fileset> + </path> + + <target name="update_all" depends="update_population" /> + + <!-- Update the geography plugin with the latest definitions --> + <target name="update_population" depends="create_candidates, update_population_plugin_xml, update_population_plugin_properties, update_population_generated_files" /> + + <target name="update_population_generated_files" depends="update_population_graphs" /> + + <target name="update_population_plugin_xml" depends="create_candidates"> + <copy tofile="${file.target.pluginxml}" file="${file.util.pluginxml}" overwrite="true" /> + </target> + + <target name="update_population_plugin_properties" depends="create_candidates"> + <copy tofile="${file.target.pluginproperties}" file="${file.util.pluginproperties}" overwrite="true" /> + </target> + + + <!-- Update the graph files in the population plugin --> + <target name="update_population_graphs" depends="create_candidates"> + <copy todir="${path.targetplugin}/resources/data/" overwrite="true"> + <fileset dir="${path.generated.files}"> + <include name="**/*.graph" /> + </fileset> + </copy> + </target> + + + + <!-- Create the graph files for countries and the plugin.xml and plugin.properties fragments --> + <target name="create_candidates" depends="clean"> + <!-- There is a problem here with specifying fork="true" maxmemory="768m". It causes an IOException on some machines --> + <java classname="${ID_ROOT}.internal.data.population.human.PopulationDataGenerator" fork="true" maxmemory="1024m"> + <classpath refid="classpath.runtime" /> + <arg value="${path.sourceplugin}" /> + <jvmarg value="-Xms1024m"/> + <jvmarg value="-Xmx1024m"/> + </java> + </target> + + <!-- clean out the .../temp/data directories --> + <!-- clean out the target directories --> + <target name="clean" depends="create_generated_files_dir"> + <delete includeEmptyDirs="true" quiet="true"> + <fileset dir="${path.sourceplugin}/temp/"> + <include name="**/*" /> + </fileset> + <fileset dir="${path.targetplugin}/resources/data/"> + <include name="country/**/*" /> + <include name="relationship/**/*" /> + </fileset> + </delete> + </target> + + <target name="create_generated_files_dir"> + <mkdir dir="${path.generated.files}" /> + </target> +</project> |