Ergo Developer Tutorial Eclipse RCP installation Eclipse RCP

  • Slides: 128
Download presentation
Ergo Developer Tutorial

Ergo Developer Tutorial

Eclipse RCP installation

Eclipse RCP installation

Eclipse RCP Installation Objective To learn how to install Eclipse Rich Client Platform (RCP)

Eclipse RCP Installation Objective To learn how to install Eclipse Rich Client Platform (RCP) Contents System Prerequisites Eclipse Download and Installation Updating Eclipse to latest release

System Prerequisites Operating System Linux (just about any version) Mac. OSX (10. 5 Leopard

System Prerequisites Operating System Linux (just about any version) Mac. OSX (10. 5 Leopard or higher) Windows (XP and higher) Java: Eclipse requires Oracle or IBM Java Need Java SDK Java 1. 7 or higher Java 1. 7 is the same as JDK 7. 0 The GNU Java Compiler (GCJ), which comes standard on Linux, will not work. Open. JDK, distributed with some Linux distributions, comes closer to working, but should not be used

Eclipse Packages The current version of Eclipse (4. 4) is also known as “Luna”

Eclipse Packages The current version of Eclipse (4. 4) is also known as “Luna” Eclipse is available in a number of different packages for different kinds of development http: //eclipse. org/downloads/ For Ergo, we recommend the Eclipse for RCP and RAP Developers

Exercise Download the “Eclipse for RCP and RAP Developers” package to your laptop 2.

Exercise Download the “Eclipse for RCP and RAP Developers” package to your laptop 2. If your machine is Linux or Mac OS X, untar the file 1. • On Mac OS X you can just double-click in the Finder If your machine is Windows, unzip the file 4. This creates an eclipse folder containing the executable as well as other support files and folders 3.

Starting Eclipse Linux From a terminal window, enter “<eclipse_installation_path>/eclipse &” Or, open the eclipse

Starting Eclipse Linux From a terminal window, enter “<eclipse_installation_path>/eclipse &” Or, open the eclipse folder Double-click on the eclipse executable Mac OS X From Finder, open the eclipse folder where you installed Double-click on the Eclipse application Or from a terminal window Windows Open the eclipse folder Double-click on the eclipse executable

Specifying a Workspace Eclipse prompts for a workspace location at startup time The workspace

Specifying a Workspace Eclipse prompts for a workspace location at startup time The workspace contains all user-defined data Projects and resources such as folders and files The default workspace location is fine for this tutorial

Eclipse Welcome Page Displayed when Eclipse is run for the first time Select “Go

Eclipse Welcome Page Displayed when Eclipse is run for the first time Select “Go to the Workbench”

Updating Eclipse RCP Eclipse releases two service packs per major release To check for

Updating Eclipse RCP Eclipse releases two service packs per major release To check for updates, select Help > Check for Updates… If there are updates installed, Restart eclipse after installing Ergo can be updated in a similar way

Additional Features for Ergo requires the Graphical Editing Framework (GEF) and Zest Visualization Toolkit

Additional Features for Ergo requires the Graphical Editing Framework (GEF) and Zest Visualization Toolkit SDKs that are not included in the RCP installation Go to Help > Install New Software… In the Work With: dropdown box, select the update site: Luna - http: //download. eclipse. org/releases/luna

Install GEF and Zest SDKs In the dialog box, expand Modeling and select Graphical

Install GEF and Zest SDKs In the dialog box, expand Modeling and select Graphical Editing Framework GEF SDK Graphical Editing Framework Zest Visualization Toolkit SDK Select Next, Eclipse calculates required plug-ins Select Next again. Accept the License agreement and Select Finish

Exercise 1. Launch Eclipse RCP and select the default workspace 2. Go to Help

Exercise 1. Launch Eclipse RCP and select the default workspace 2. Go to Help > Install New Software… and select GEF and Zest Framework SDKs 3. Install GEF and Zest SDKs 4. Restart Eclipse once the installation is completed

Eclipse RCP/Ergo Overview

Eclipse RCP/Ergo Overview

Eclipse RCP/Ergo Overview Objective To introduce the Eclipse RCP platform and Ergo Platform architecture

Eclipse RCP/Ergo Overview Objective To introduce the Eclipse RCP platform and Ergo Platform architecture Contents What is Eclipse RCP? What is Ergo?

The Eclipse Platform Integrated development environments(IDEs) for Java, C/C++, Fortran, etc Factor out the

The Eclipse Platform Integrated development environments(IDEs) for Java, C/C++, Fortran, etc Factor out the language independent parts (platform) Then, add in the language-specific pieces later (plug- ins) “The Eclipse platform itself is a sort of universal tool platform – it is an IDE for anything and nothing in particular. ” – Eclipse Platform Overview

What is Eclipse? Universal platform for integrating development tools Open, extensible architecture based on

What is Eclipse? Universal platform for integrating development tools Open, extensible architecture based on plugins Plug-ins are installed into Eclipse to add new behavior JDT is just a collection of plugins Plug-in Dev. Env (PDE) Java Dev Tools (JDT) Eclipse Platform Java VM

RCP Core

RCP Core

Eclipse Plug-in Architecture OSGi is a specification describing a modular approach for Java applications

Eclipse Plug-in Architecture OSGi is a specification describing a modular approach for Java applications Plug-in – smallest unit of Eclipse function Extension Point – named entity for collecting “contributions” Example: extension point for Ergo analysis Extension – a contribution Example: an Ergo analysis

Eclipse Plug-in Arch. (2) Each plug-in Contributes to 1 or more extension points Optionally

Eclipse Plug-in Arch. (2) Each plug-in Contributes to 1 or more extension points Optionally declares new extension points Depends on a set of other plug-ins Contains Java code libraries and other files May export Java-based APIs for downstream plug-ins Lives in its own plug-in subdirectory Details are defined in the plug-in manifest Manifest declares contributions Code implements contributions and provides API plugin. xml file in root of plug-in subdirectory

Eclipse Plug-in Arch. (3) Plugin example plug-in A plug-in B extension point P extension

Eclipse Plug-in Arch. (3) Plugin example plug-in A plug-in B extension point P extension interface I class C Plug-in A Declares extension point P Declares interface I to go with P Plug-in B Implements interface I with its own class C Contributes class C to extension point P Plug-in A instantiates C and calls its I methods

Core Technologies OSGI Provides plug-in based environment for Eclipse Permits lazy-loading of plug-ins Permits

Core Technologies OSGI Provides plug-in based environment for Eclipse Permits lazy-loading of plug-ins Permits multiple version of the same plugin/packages to co-exist Every Eclipse plug-in is an OSGi plug-in (or bundle) Every OSGi plug-in can be treated as a standard JAR outside of OSGi

Core Technologies (2) SWT – a platform independent widget toolkit that wraps native widgets

Core Technologies (2) SWT – a platform independent widget toolkit that wraps native widgets offering a native look and feel across platforms JFace – provides Model-View-Controller wrapping for SWT widgets (e. g. Tree. Viewer, Table. Viewer, etc) Model – consists of application data, business rules, logic and functions View – visual representation of the data (e. g. chart, diagram) Controller – mediates input converting commands for the model or view

Eclipse Basics The workbench contains the menus, toolbars, editors, and views that make up

Eclipse Basics The workbench contains the menus, toolbars, editors, and views that make up the main Eclipse Window The workbench represents the desktop development environment Contains a set of tools for resource management Provides a common way to navigate through the resources Multiple workbenches can be opened simultaneously Only one workbench per workspace View Editor View

Perspectives A Perspective is a visual container for a set of views/editors They are

Perspectives A Perspective is a visual container for a set of views/editors They are task oriented, i. e. they contain specific views for doing certain tasks Java Perspective – Java development C++ Perspective – C++ development

View A View is typically used to work on a set of data, might

View A View is typically used to work on a set of data, might be hierarchical Example: Eclipse package explorer, Ergo Scenarios view Views can be freely positioned in the User Interface

Components of RCP App. Main program – a RCP main application class implements IApplication,

Components of RCP App. Main program – a RCP main application class implements IApplication, synonymous to the main method for a standard Java application This class should be defined via extension point org. eclipse. core. runtime. application A Perspective – defines the layout of your application Declared via extension point org. eclipse. ui. perspective Workbench Advisor – controls the appearance of the application (menus, toolbars, perspectives, etc)

Ergo EQ Architecture Dynamic New Third-Party Analyses Compare, Contrast, Validate Auto-update Ergo-EQ GIS Workflow

Ergo EQ Architecture Dynamic New Third-Party Analyses Compare, Contrast, Validate Auto-update Ergo-EQ GIS Workflow Data Eclipse RCP Plug-ins, Provenance, Environment Plug-in Framework

Ergo-EQ Architecture (2)

Ergo-EQ Architecture (2)

Ergo Core Technologies Eclipse RCP Geotools Visualization Toolkit JFree. Chart Ktable Jasper Reports

Ergo Core Technologies Eclipse RCP Geotools Visualization Toolkit JFree. Chart Ktable Jasper Reports

More RCP Resources Eclipse RCP Tutorial • http: //www. vogella. com/tutorials/Eclipse. RCP/article. html Eclipse

More RCP Resources Eclipse RCP Tutorial • http: //www. vogella. com/tutorials/Eclipse. RCP/article. html Eclipse RCP Wiki • http: //wiki. eclipse. org/index. php/Rich_Client_Platfor m

Setup Ergo Development Environment

Setup Ergo Development Environment

Setup Ergo Development Environment Objective Checkout all required Ergo projects for development Content Step

Setup Ergo Development Environment Objective Checkout all required Ergo projects for development Content Step by step instructions to checkout each repository Adding projects to working sets Full instructions on Ergo wiki: https: //opensource. ncsa. illinois. edu/confluence/ display/ERGO/environment_setup_10

Ergo Repositories One Git repositories make up Ergo and Ergo- EQ with package names

Ergo Repositories One Git repositories make up Ergo and Ergo- EQ with package names specific to core, earthquake, gis, etc ergo

Checkout Ergo Repository In Eclipse, go to File > Import > Git > Projects

Checkout Ergo Repository In Eclipse, go to File > Import > Git > Projects from Git Click Next Select Clone URI and Click Next Copy and Paste into the URI field: ssh: //git@opensource. ncsa. illinoi s. edu: 7999/ergo. git For u/p, enter your opensource credentials, click Next

Checkout Ergo Repository (2) Select master, develop-v 1, develop-v 2 Click Next

Checkout Ergo Repository (2) Select master, develop-v 1, develop-v 2 Click Next

Checkout Ergo Repository (3) Assuming the default “workspace”, we recommend creating a git directory

Checkout Ergo Repository (3) Assuming the default “workspace”, we recommend creating a git directory in the workspace and then checking out the repository to that directory (e. g. eclipse_workspace/git/ ergo) Click Next

Checkout Ergo Repository (4) Select Import existing projects Click Next

Checkout Ergo Repository (4) Select Import existing projects Click Next

Checkout Ergo Repository (5) Select all projects Uncheck the box Search for nested projects

Checkout Ergo Repository (5) Select all projects Uncheck the box Search for nested projects Check Add project to working sets See next slide. . .

Checkout Ergo Repository (6) To add the checked out files to a working set:

Checkout Ergo Repository (6) To add the checked out files to a working set: Click Select Click New Select Java Click Next Where it says “Working set name” enter ergo-core Click Finish Check the box that says ergo-core Click OK See Next Slide

Checkout Ergo Repository (7) Your Import Projects dialog should look similar to this Click

Checkout Ergo Repository (7) Your Import Projects dialog should look similar to this Click Finish Projects will be checked out into workspace/git/ergo and added to the working set ergo-core

Show Working Sets Use dropdown menu to organize projects by Working Sets

Show Working Sets Use dropdown menu to organize projects by Working Sets

Exercise 1. Checkout ergo git repository into working set ergo-core 2. In Package Explorer,

Exercise 1. Checkout ergo git repository into working set ergo-core 2. In Package Explorer, select to show Working Sets

Launch Ergo-EQ Find project edu. illinois. ncsa. ergo. eq. rcp Double click on the

Launch Ergo-EQ Find project edu. illinois. ncsa. ergo. eq. rcp Double click on the file ergo-eq. product Under Testing click on Launch an Eclipse application If you see a dialog with the message “errors exist in org. geotools”, click Proceed

Analysis framework

Analysis framework

Analysis Framework Objective Create a new Ergo Analysis Content Create the analysis description file

Analysis Framework Objective Create a new Ergo Analysis Content Create the analysis description file (User Interface) Create the Analysis Task Register Analysis with new. Analyses extension point Register Task with ogre. Tasks extension point Launch Ergo-EQ with new analysis

Step 1. Analysis Description File XML file specifying the inputs, outputs, and parameters for

Step 1. Analysis Description File XML file specifying the inputs, outputs, and parameters for the new analysis Defines User Interface for New Analysis Put file in defining plug-ins descriptions folder

Create New Plug-in Create new eclipse plugin, File > New > Plug-in Project Name:

Create New Plug-in Create new eclipse plugin, File > New > Plug-in Project Name: edu. illinois. ncsa. ergo. eq. tu torial Leave rest as default Click Next

Create New Plug-in (2) Uncheck the box “This plug-in will make contributions to the

Create New Plug-in (2) Uncheck the box “This plug-in will make contributions to the UI” Leave rest as default Click Finish You can find your project under “Other Projects” working set

Create Descriptions Folder Right click on the new project and select New > Folder

Create Descriptions Folder Right click on the new project and select New > Folder Where it says “Folder Name: ” enter descriptions Click Finish

Create Analysis Desc. File Similar to the folder creation, right click on the descriptions

Create Analysis Desc. File Similar to the folder creation, right click on the descriptions folder and select New > File Where it says “File name” enter New. Building. Damage. xml Click Finish

Exercise 1. Create new Plug-in Project 2. Create descriptions folder 3. Create empty file

Exercise 1. Create new Plug-in Project 2. Create descriptions folder 3. Create empty file New. Building. Damage. xml

Analysis Description Tag <analysis-description> id (required) – must match the id given to the

Analysis Description Tag <analysis-description> id (required) – must match the id given to the analysis in the edu. illinois. ncsa. ergo. core. analysis. new. Analyses extension point (we will add the id later) help-context (optional) – assigns a help context id to this analysis Code: <analysis-description id="" help-context="">

Analysis Type Tag <analysis-type> type (required) - specifies analysis iteration type property (required) name

Analysis Type Tag <analysis-type> type (required) - specifies analysis iteration type property (required) name – special keyword to identify which dataset is the dataset being iterated over value – dataset to iterate over Code: <analysis-type="simple. Iteration"> <property name="iterating. Dataset. Key" value="buildings"/> </analysis-type>

Groups Tag <groups> Specify the grouping of User Interface Inputs and parameters Code: <groups>

Groups Tag <groups> Specify the grouping of User Interface Inputs and parameters Code: <groups> <group-name>Required</group-name> <group-name>Advanced</group-name> </groups>

Parameter Tag Attributes group (unused) – string that must match a member of <groups>

Parameter Tag Attributes group (unused) – string that must match a member of <groups> format – the format of whatever phylum parameter this is. For datasets, indicates type of dataset (mapping, shapefile, etc) phylum – type of parameter, currently supports string, dataset, or boolean cardinality – how many of this type, currently supports single or multiple key – name of property which will correspond to Analysis Task Setter (e. g. key = “building”, Analysis Task must have set. Building) friendly-name – name that should be displayed in the User Interface optional – value of true denotes this parameter is not needed to perform the analysis advanced – a value of true denotes this is an advanced parameter and should be in that grouping. It is required, but this will hide it in the UI under Advanced grouping

Parameter Tag (2) Elements <types> A list of types that are accepted by this

Parameter Tag (2) Elements <types> A list of types that are accepted by this <parameter>, this should match the tag field of the dataset type defined at edu. illinois. ncsa. ergo. gis. Schemas <description> A textual description of the parameter. Primarily used to generate tooltips in the UI.

Result Name Code: <!-- Name of result dataset --> <parameter format="result. Name" phylum="string" cardinality="single"

Result Name Code: <!-- Name of result dataset --> <parameter format="result. Name" phylum="string" cardinality="single" key="building. Damagev 4. result. Name" friendlyname="Result Name"/>

Building Dataset Code: <!-- Building Dataset Input --> <parameter phylum="dataset" cardinality="single" key="buildings" friendly-name="Buildings"> <types>

Building Dataset Code: <!-- Building Dataset Input --> <parameter phylum="dataset" cardinality="single" key="buildings" friendly-name="Buildings"> <types> <type>buildingv 4</type> <type>buildingv 5</type> </types> </parameter>

Hazard Dataset Code: <!-- Hazard Dataset Input --> <parameter phylum="dataset" cardinality="multiple" key="hazard" friendly-name="Hazard"> <types>

Hazard Dataset Code: <!-- Hazard Dataset Input --> <parameter phylum="dataset" cardinality="multiple" key="hazard" friendly-name="Hazard"> <types> <type>hazard. Raster</type> <type>deterministic. Hazard. Raster</type> <type>hazard</type> </types> </parameter>

Fragility Dataset Code: <!-- Building Fragility Dataset Input --> <parameter advanced="true" phylum="dataset" cardinality="single" key="fragilities"

Fragility Dataset Code: <!-- Building Fragility Dataset Input --> <parameter advanced="true" phylum="dataset" cardinality="single" key="fragilities" friendly-name="Fragilities"> <types> <type>building. Fragilities</type> </types> </parameter>

Output Tag <output> - two required properties base-dataset-key – the key of the <parameter>

Output Tag <output> - two required properties base-dataset-key – the key of the <parameter> which is the base for this new Dataset Schema – The id of the schema that this Dataset implements (see edu. illinois. ncsa. gis. Schemas extension point) Attributes format – the format of the parameter, currently supports string or dataset key – the name of the property for which value should be added. No spaces allowed friendly-name – name of property for which value should be added Elements property – additional properties required by output

Output Code: <!-- OUTPUTS --> <output friendly-name="Building Damage" key="building. Damagev 4" phylum="dataset" format="shapefile" geom="buildings"

Output Code: <!-- OUTPUTS --> <output friendly-name="Building Damage" key="building. Damagev 4" phylum="dataset" format="shapefile" geom="buildings" guids="buildings"> <property name="buildings" type="base-dataset-key" value="buildings"/> <property name="schema" type="schema" value=“edu. Illinois. ncsa. ergo. eq. schemas. building. Damage. Ver 4. v 1. 0"/> </output>

Produced Types Tag <produced-types> - types produced by this analysis Elements <type> – should

Produced Types Tag <produced-types> - types produced by this analysis Elements <type> – should match the output type (e. g. the tag in the edu. illinois. ncsa. ergo. gis. Schemas extension Code: <produced-types> <type>building. Damagev 4</type> </produced-types>

Closing Tag Code: </analysis-description> Ctrl-s to save the file

Closing Tag Code: </analysis-description> Ctrl-s to save the file

Exercise 1. Add the analysis description pieces for the new analysis

Exercise 1. Add the analysis description pieces for the new analysis

Step 2. Create Analysis Task Java class performs the work Must implement the Analysis

Step 2. Create Analysis Task Java class performs the work Must implement the Analysis Task that corresponds to the <analysis-type> (e. g. Simple. Feature. Task) Keys given to each parameter must match set methods in this class Column names given to the outputs must match values given in the output schema type

Add Required Dependencies Open project MANIFEST. MF under META-INF folder Select Dependencies tab Under

Add Required Dependencies Open project MANIFEST. MF under META-INF folder Select Dependencies tab Under Required Plug-ins, click Add edu. illinois. ncsa. ergo. core. analysis edu. illinois. ncsa. ergo. gis edu. illinois. ncsa. ergo. eq. hazard ncsa. tools. elf. core ncsa. tools. common ncsa. tools. ogrescript org. dom 4 j org. geotools Finish dependencies Ctrl-s to save MANIFEST. MF

Create New Java Class Right click on the project, New > Class Package: Name:

Create New Java Class Right click on the project, New > Class Package: Name: edu. illinois. ncsa. ergo. eq. tutorial. tasks New. Building. Damage. Task Superclass: Simple. Feature. Task edu. illinois. ncsa. ergo. core. analysis. ogrescript. tasks. core. Sim ple. Feature. Task Click Finish

Add Unimplemented Methods If your eclipse already add the method, you don’t need to

Add Unimplemented Methods If your eclipse already add the method, you don’t need to do this part. Click on the red x in the class and select add unimplemented methods Adds handle. Feature method – each building is passed in 1 at a time, we will add our business logic here

Add Set Methods For key=buildings Nothing to set, this is our iterating dataset For

Add Set Methods For key=buildings Nothing to set, this is our iterating dataset For key=hazard set. Hazard(List<Raster. Dataset> hazard. List) For key=fragilities set. Fragilities(Fragility. Dataset fragilities) Note: if your eclipse complaints “can’t resolve a type”, ctrl+shift+o (it will import all classes you need)

Hazard Input Add class variable Code: private Fragility. Hazard. Set hazard. Set = new

Hazard Input Add class variable Code: private Fragility. Hazard. Set hazard. Set = new Fragility. Hazard. Set(); Add Set Method Code: public void set. Hazard(List<Raster. Dataset> hazard. List) { hazard. Set. set. Datasets(hazard. List); }

Fragility Input Add Class Variable Code: private Fragility. Dataset fragilities; Add Set Method Code

Fragility Input Add Class Variable Code: private Fragility. Dataset fragilities; Add Set Method Code public void set. Fragilities(Fragility. Dataset fragilities) { this. fragilities = fragilities; }

Exercise 1. Add class variable for fragility and Set Method 2. Add class variable

Exercise 1. Add class variable for fragility and Set Method 2. Add class variable for hazard and Set method

Implement handle. Feature Code: Point location = (Point) feature. get. Attribute(0); // Period of

Implement handle. Feature Code: Point location = (Point) feature. get. Attribute(0); // Period of Demand Type double period = 0. 0; // Demand Type for Fragility String demand. Hazard. Type = "PGA"; // Units of Demand for Fragility String demand. Hazard. Units = "g"; // Default int spectrum. Override = 0;

Implement handle. Feature (2) Get hazard that best matches the period, demand type and

Implement handle. Feature (2) Get hazard that best matches the period, demand type and demand units. It will find the dataset that can best provide the hazard Code: //Find Hazard Value at Location double hazard. Val = hazard. Set. get. Hazard. Val(location, period, demand. Hazard. Type, demand. Hazard. Units, spectrum. Override);

Implement handle. Feature (3) Get the first fragility set in the map and get

Implement handle. Feature (3) Get the first fragility set in the map and get the damage value for the first fragility curve in the set for the hazard value Store the result in the result. Map associated with the Task Code: Fragility. Set random. Fragility = fragilities. get. Fragility. Sets(). values(). iterator(). next(); double damage = random. Fragility. get. Fragilities(). get(0). get. Value. At. Point(haz ard. Val); result. Map. put("meandamage", damage );

Exercise Implement handle. Feature 1. Get hazard value at building location 2. Get Fragility

Exercise Implement handle. Feature 1. Get hazard value at building location 2. Get Fragility curve and corresponding damage for the hazard value 3. Store damage as meandamage

Step 3. Register Analysis Objective Register analysis with edu. illinois. ncsa. ergo. core. analysis.

Step 3. Register Analysis Objective Register analysis with edu. illinois. ncsa. ergo. core. analysis. new. Analyses extension point Content How to register a new analysis

Analysis Extension Point Inside the project edu. illinois. ncsa. ergo. eq. tutorial, open MANIFEST.

Analysis Extension Point Inside the project edu. illinois. ncsa. ergo. eq. tutorial, open MANIFEST. MF Click on the Extensions tab Click Add Where it says Extension Point filter, search for edu. illinois. ncsa. ergo. core. an alysis. new. Analyses Select the Extension Point and Click Finish

Create Analysis Extension To create a new extension, right click on edu. illinois. ncsa.

Create Analysis Extension To create a new extension, right click on edu. illinois. ncsa. ergo. core. analysis. new. Analyses and select New > analysis Your eclipse may already add the new analysis for you, in this case, you don’t need to add another analysis This will create a blank analysis extension with the following attributes: id – This id must match the id given in the analysis description file, New. Building. Damage. xml name – Friendly name of the analysis and should be i 18 n tag – This tag must match the tag in the ncsa. tools. ogrescript. ogre. Tasks extension. No spaces allowed descriptor – Location of the analysis description file category – The category to put the new analysis in, for display purposes description – brief description of the new analysis

Analysis Extension Details Fill in the following for our new analysis id name descriptions/New.

Analysis Extension Details Fill in the following for our new analysis id name descriptions/New. Building. Damage. xml category tutorial. Building. Damage descriptor New Building Damage tag edu. illinois. ncsa. ergo. eq. tutorial. New. Buildi ng. Damage Building description new building damage analysis

Update Analysis Description Open New. Building. Damage. xml Replace <analysis-description id="" help-context=""> With <analysis-description

Update Analysis Description Open New. Building. Damage. xml Replace <analysis-description id="" help-context=""> With <analysis-description id="edu. illinois. ncsa. ergo. eq. tutorial. New. Build ing. Damage" help-context="">

Exercise 1. Add Extension Point in MANIFEST. MF 2. Add Extension to Extension Point

Exercise 1. Add Extension Point in MANIFEST. MF 2. Add Extension to Extension Point for new Analysis in MANIFEST. MF 3. Update New. Building. Damage. xml with analysis id

Step 4. Register Analysis Task Objective Register new analysis task with ncsa. tools. ogrescript.

Step 4. Register Analysis Task Objective Register new analysis task with ncsa. tools. ogrescript. ogre. Tasks extension point Content How to register a new analysis task

Analysis Task Extension Point Inside the project edu. illinois. ncsa. ergo. eq. tuto rial,

Analysis Task Extension Point Inside the project edu. illinois. ncsa. ergo. eq. tuto rial, open MANIFEST. MF Click on the Extensions tab Click Add Where it says Extension Point filter, search for ncsa. tools. ogrescript. ogre. Ta sks Select the Extension Point and Click Finish

Create Analysis Task Extension Similar to the new. Analyses extension, right click on ncsa.

Create Analysis Task Extension Similar to the new. Analyses extension, right click on ncsa. tools. ogrescript. ogre. Tasks and select New > ogre. Tasks This will create a blank analysis task extension with the following attributes: id – This id should match the fully qualified class name of the task (see class attribute) name – This is the friendly name of the Task and should be i 18 n tag – This tag must match the tag in the edu. illinois. ncsa. ergo. core. analysis. new. Analyses extension point class – This points to the implementing class we created previously

Analysis Task Extension Details Fill in the following for our new analysis task id

Analysis Task Extension Details Fill in the following for our new analysis task id name New Building Damage Task tag edu. illinois. ncsa. ergo. eq. tutorial. tas ks. New. Building. Damage. Task tutorial. Building. Damage Class edu. illinois. ncsa. ergo. eq. tutorial. tasks. N ew. Building. Damage. Task

Add Plug-in to Ergo Go to Run > Run Configurations… Under Eclipse Applications select

Add Plug-in to Ergo Go to Run > Run Configurations… Under Eclipse Applications select ergoeq. product Select the Plug-ins tab Locate our plugin edu. illinois. ncsa. ergo. eq. tutorial and check the box to include it Click Run

Update Preferences Click on File Select File > Preferences Locations Change Repository update service

Update Preferences Click on File Select File > Preferences Locations Change Repository update service URL to Windows - file: \C: repositories. xml Linux /Mac – file: /home/user-name/repositories. xml Or wherever you put the file Click OK

Sync Repositories Click on Synchronize button to fetch defined repositories

Sync Repositories Click on Synchronize button to fetch defined repositories

Create New Scenario Select File > New Scenario Where it says Name enter Tutorial

Create New Scenario Select File > New Scenario Where it says Name enter Tutorial Scenario Click Next

Create New Scenario (2) Where it says Country select United States of America Expand

Create New Scenario (2) Where it says Country select United States of America Expand Tennessee and select Shelby county Click Next Click Finish

Execute Analysis Right Click on the new scenario and select Execute Analysis Expand Building

Execute Analysis Right Click on the new scenario and select Execute Analysis Expand Building and select New Building Damage Click Finish

New Building Damage Click on the New Building Damage box to build the User

New Building Damage Click on the New Building Damage box to build the User Interface Note: the analysis is currently red because not all input parameters are satisified See next slide for inputs

New Building Damage (2) For Result Name, enter Building Damage For Buildings, click Search

New Building Damage (2) For Result Name, enter Building Damage For Buildings, click Search and locate Shelby County RES 3 For Hazard, click Search and locate Memphis 7. 7 M PGA For Fragilities, click Search and locate Default Building Fragilities 1. 0 Click the Execute button that should now be enabled

Exercise 1. Run the New Building Damage analysis

Exercise 1. Run the New Building Damage analysis

Advanced Topics

Advanced Topics

Add Dataset Type Objective Add new dataset type to Ergo-EQ Content Creating a new

Add Dataset Type Objective Add new dataset type to Ergo-EQ Content Creating a new dataset schema Adding schema extension to extension point Adding field-specific metadata

New Dataset Schema Create a folder in the root directory of your plugin called

New Dataset Schema Create a folder in the root directory of your plugin called gis. Schemas Create a new empty file called ergo- tutorial. Building. Damage_1. 0. xsd in gis. Schemas folder See ergo-building. Damage. Ver 4_1. 0. xsd in plugin edu. illinois. ncsa. ergo. eq as an example

Sample Code for Schema <? xml version="1. 0" encoding="UTF-8"? > <xsd: schema xmlns: gml="http:

Sample Code for Schema <? xml version="1. 0" encoding="UTF-8"? > <xsd: schema xmlns: gml="http: //www. opengis. net/gml" xmlns: xsd="http: //www. w 3. org/2001/XMLSchema" target. Namespace="http: //www. ionicsoft. com/wfs" xmlns: xlink="http: //www. w 3. org/1999/xlink" xmlns: iwfs="http: //www. ionicsoft. com/wfs" target. Namespace. Optional="true" xmlns="http: //www. ionicsoft. com/wfs" element. Form. Default="qualified"> <xsd: import namespace="http: //www. opengis. net/gml" schema. Location="http: //schemas. opengis. net/gml/2. 1. 2/feature. xsd"/> <xsd: element name="TUTORIALBUILDINGDAMAGE" substitution. Group="gml: _Feature" type="iwfs: TUTORIALBUILDINGDAMAGE"/> <xsd: complex. Type name="TUTORIALBUILDINGDAMAGE"> <xsd: complex. Content> <xsd: extension base="gml: Abstract. Feature. Type"> <xsd: sequence> <xsd: element name=“ergo. meandamage" min. Occurs="0" nillable="true" type="xsd: double"/> </xsd: sequence> </xsd: extension> </xsd: complex. Content> </xsd: complex. Type> </xsd: schema>

Add Schema Extension Point Go to edu. illinois. ncsa. ergo. eq. tutorial project and

Add Schema Extension Point Go to edu. illinois. ncsa. ergo. eq. tutorial project and open MANIFEST. MF Click on Extensions Click Add edu. illinois. ncsa. ergo. gis. Schemas

Add Schema Extension Right click on edu. illinois. ncsa. ergo. gis. Schemas and select

Add Schema Extension Right click on edu. illinois. ncsa. ergo. gis. Schemas and select New > gis. Schema This will create a new extension with the following attributes id – The id of the schema name – A friendly name for the schema version A version identifier for the schema type – a short type name for the schema (used in analysis description to identify input types) description – a user-friendly description of the schema file – The schema file defined in the previous step format – The format of the schema. Predefined formats include shapefile, fragility, mapping, raster, and table required. Fields – The list of fields that are required as a minimum for this schema. These will be prompted to map during ingestion of data map. Layer – For shapefiles, the suggested smart layering position in the map. Should be between 1 and 100. A map. Layer of -1 indicates dataset should be invisible by default category – a category name for the schema. Categories determine what subfodlers the schemas appear in the repository

Schema Extension Details Id - edu. illinois. ncsa. ergo. eq. tutorial. schemas. tutor ial.

Schema Extension Details Id - edu. illinois. ncsa. ergo. eq. tutorial. schemas. tutor ial. Building. Damage. v 1. 0 name - Tutorial Building Damage version - 1. 0 type - tutorial. Building. Damage description - Tutorial building damage output type file - gis. Schemas/ergotutorial. Building. Damage_1. 0. xsd format - Shapefile required. Fields - meandamage map. Layer - 10 category - Buildings

Field Specific Metadata Create a folder in the root directory of your plugin called

Field Specific Metadata Create a folder in the root directory of your plugin called gis. Metadata Create a file name corresponding to the schema xsd file name, but ending in. xml (e. g. ergotutorial. Building. Damage_1. 0. xml) Ergo will automatically look for a file with the same prefix in gis. Metadata when displaying fields in the User Interface

Metadata Attributes Column-id – The id to match the column id from the xsd

Metadata Attributes Column-id – The id to match the column id from the xsd file. Should not include the ergo. prefix Friendly-name Is-numeric Unit Field-length Importance Is-result Agg-type

Sample Metadata for Data Type <? xml version="1. 0" encoding="ISO-88591"? > <table-metadata> <column-metadata column-id="meandamage"

Sample Metadata for Data Type <? xml version="1. 0" encoding="ISO-88591"? > <table-metadata> <column-metadata column-id="meandamage" friendly-name="Mean Structural Damage" is-result="true" is-numeric="true" unit="decimal" importance="main. Value" agg-type="mean" field-length="10" /> </table-metadata>

Create Custom Iterator Objective Add new custom iterator Content What is a custom iterator

Create Custom Iterator Objective Add new custom iterator Content What is a custom iterator Adding a custom iterator extension

Custom Iterators Simple Feature Iterator Iterates over a feature dataset providing 1 feature per

Custom Iterators Simple Feature Iterator Iterates over a feature dataset providing 1 feature per iteration to the analysis task Table Iterator Iterates over a table dataset providing 1 row per iteration to the analysis task Custom Iterator Handles special cases where simple iteration is not applicable (e. g. see NBSR Iteration Handler)

Create Custom Iterator Class Right click on the project edu. illinois. ncsa. ergo. eq.

Create Custom Iterator Class Right click on the project edu. illinois. ncsa. ergo. eq. tutorial and select New > Class Package – edu. illinois. ncsa. ergo. eq. tutorial. handler s Name – Example. Iteration. Handler Superclass – Iteration. Handler Click Finish

Implement Iterator Class This code should go inside wrapped. Create. Iteration. Elements(…) Code: //

Implement Iterator Class This code should go inside wrapped. Create. Iteration. Elements(…) Code: // This must match the tag for the analysis and task Element e = new Default. Element("example"); // Name of the result e. add. Attribute(“result-Type", Analysis. Utils. variableize. As. Constant("result. type", “bldgresult")); // Input - must match "key" inside analysis description e. add. Attribute("my-buildings", Analysis. Utils. variableize. As. Constant(null, "mybuildings")); // Output - bldgresult must match to an output key in analysis description e. add. Attribute("result-bldg", Analysis. Utils. variableize. As. Constant("collection", "bldgresult")); e. add. Attribute("analysis-id", node. get. Unique. Id()); parent. add(e);

Create Analysis Task Right click on the project edu. illinois. ncsa. ergo. eq. tutorial

Create Analysis Task Right click on the project edu. illinois. ncsa. ergo. eq. tutorial and select New > Class Package – edu. illinois. ncsa. ergo. eq. tutorial. ta sks Name – Custom. Iterator. Analysis. Task Superclass – Analysis. Base. Task Click Finish

Implement Custom Analysis Task Code private Feature. Type result. Type; private Feature. Dataset my.

Implement Custom Analysis Task Code private Feature. Type result. Type; private Feature. Dataset my. Buildings; private Feature. Collection result. Bldg; public Feature. Type get. Resul. Type() { return result. Type; } public void set. Result. Type(Feature. Type result. Type) { this. result. Type = result. Type; } public void set. My. Buildings(Feature. Dataset my. Buildings) { this. mybuildings = my. Buildings; } public void get. Result. Bldg(Feature. Collection result. Bldg) { this. result. Bldg = result. Bldg; }

Implement Custom Analysis Task (2) Code @Override protected void wrapped. Execute(IProgress. Monitor monitor) throws

Implement Custom Analysis Task (2) Code @Override protected void wrapped. Execute(IProgress. Monitor monitor) throws Script. Execution. Exception { try { Feature. Collection fc = my. Buildings. get. Features(); Feature. Type original. Schema = fc. get. Schema(); List<Attribute. Type> new. Attribute. Types = new Linked. List<Attribute. Type>(); Attribute. Type[] attribute. Types = original. Schema. get. Attribute. Types() ; for (Attribute. Type type : attribute. Types) { new. Attribute. Types. add(type); } String type. Name = get. Result. Type(). get. Type. Name(); type. Name); Default. Feature. Type new. Schema = (Default. Feature. Type) Feature. Type. Builder. new. Feature. Type ( new. Attribute. Types. to. Array(new Attribute. Type[new. Attribute. Types. size ()]), Feature. Iterator iter = fc. features();

Implement Custom Analysis Task (3) Code try { while (iter. has. Next()) { List<Object>

Implement Custom Analysis Task (3) Code try { while (iter. has. Next()) { List<Object> data = new Linked. List<Object>(); Feature f = iter. next(); Object[] values = f. get. Attributes(null); for (Object obj : values) { data. add(obj); } Feature newf = new. Schema. create(data. to. Array()); result. Bldg. add(newf); } } finally { fc. close(iter); } commit. Features(result. Bldg, create. Feature. Store(new. Schema, "feature. store. bldgresult")); //$NON-NLS-1$ } catch (Schema. Exception e) { error("Scehma problem", e); //$NON-NLS-1$ } catch (Illegal. Attribute. Exception e) { error("Attribute. Type problem", e); //$NON-NLS-1$ } catch (IOException e) { error("IO problem", e); //$NON-NLS-1$ } catch (Environment. Access. Exception e) { error("Ogre Script Problem", e); //$NON-NLS-1$ }

Implement Custom Analysis Task (4) Code private Feature. Store create. Feature. Store(Feature. Type feature.

Implement Custom Analysis Task (4) Code private Feature. Store create. Feature. Store(Feature. Type feature. Type, String feature. Store. Key) throws IOException, Malformed. URLException, Environment. Access. Exception { File temp. Shapefile = File. create. Temp. File("temp", ". shp"); URL shape. URL = temp. Shapefile. to. URI(). to. URL(); Data. Store shapefile. Datastore = new Shapefile. Data. Store(shape. URL); shapefile. Datastore. create. Schema(feature. Type); Feature. Store feature. Store = (Feature. Store) shapefile. Datastore. get. Feature. Source(feature. Type. get. Type. Name()); } environment. add. Or. Set. Entry(feature. Store. Key, feature. Store, false); return feature. Store;

Implement Custom Analysis Task (5) Code private void commit. Features(Feature. Collection feature. Collection, Feature.

Implement Custom Analysis Task (5) Code private void commit. Features(Feature. Collection feature. Collection, Feature. Store feature. Store) throws IOException { Default. Transaction transaction = new Default. Transaction(); try { feature. Store. set. Transaction(transaction); feature. Store. add. Features(feature. Collection); transaction. commit(); feature. Store. set. Transaction(Transaction. AUTO_COMMIT); } } finally { feature. Collection. clear(); transaction. close(); }

Exercise 1. Create custom iterator class 2. Implement iterator class 3. Create Analysis Task

Exercise 1. Create custom iterator class 2. Implement iterator class 3. Create Analysis Task 4. Implement Analysis Task

Custom Analysis Description Right click on the descriptions folder and select New > File

Custom Analysis Description Right click on the descriptions folder and select New > File Where it says “File name” enter Custom. Iterator. Building. Damage. xml Click Finish

Custom Analysis Description (2) Code <analysis-description id="edu. illinois. ncsa. ergo. eq. tutorial. Custom. Building.

Custom Analysis Description (2) Code <analysis-description id="edu. illinois. ncsa. ergo. eq. tutorial. Custom. Building. Damage " help-context=""> <analysis-type="custom. Bldg. Iterator "> <property name="iterating. Dataset. Key " value="null"/> </analysis-type> <!-- GROUPS input and parameter fields --> <groups> <group-name>Required</group-name> <group-name>Advanced</group-name> </groups> <!-- INPUTS --> <!-- Name of result dataset --> <parameter format="result. Name" phylum="string" cardinality="single" key=“bldgresult. Name " friendly-name="Result Name"/> <!-- Building Dataset Input --> <parameter phylum="dataset" cardinality="single" key="mybuildings" friendly-name="Buildings"> <types> <type>buildingv 4</type> <type>buildingv 5</type> </types> </parameter> <!-- OUTPUTS --> <output friendly-name="Building Damage" key="bldgresult" phylum="dataset" format="shapefile" geom="mybuildings" guids="mybuildings"> <property name="mybuildings" type="base-dataset-key " value="mybuildings"/> <property name="schema" type="schema" value="edu. illinois. ncsa. ergo. eq. tutorial. schemas. tutorial. Building. Damage. v 1. 0 "/> </output> <produced-types> <type>building. Damagev 4 </type> </produced-types> </analysis-description >

Register Custom Iterator Extension Point edu. illinois. ncsa. ergo. core. analysis. iteration. Hand lers

Register Custom Iterator Extension Point edu. illinois. ncsa. ergo. core. analysis. iteration. Hand lers Attributes id – This id should match the fully qualified class name of the iteration handler tag – This tag is what will be used in the <analysistype> xml tag to identify what iteration handler to call for the analysis class – class that implements the new iteration handle

Custom Iterator Extension Inside edu. illinois. ncsa. ergo. eq. tutorial, open the MANIFEST. MF.

Custom Iterator Extension Inside edu. illinois. ncsa. ergo. eq. tutorial, open the MANIFEST. MF. Click on the Extensions tab • Click the Add button and add edu. illinois. ncsa. ergo. core. analysis. iteration. Handler s Right click on the extension point and select New > iteration. Handler

Iteration Handler Attributes id – edu. illinois. ncsa. ergo. eq. tuto rial. handlers. Example.

Iteration Handler Attributes id – edu. illinois. ncsa. ergo. eq. tuto rial. handlers. Example. Iteratio n. Handler name – Custom Building Iterator tag – custom. Bldg. Iterator class - edu. illinois. ncsa. ergo. eq. tuto rial. handlers. Example. Iteratio n. Handler

Register Custom Analysis Register at new. Analyses extension point id - edu. illinois. ncsa.

Register Custom Analysis Register at new. Analyses extension point id - edu. illinois. ncsa. ergo. eq. tutorial. C ustom. Building. Damage name – Custom Building Damage tag - example descriptor – descriptions/Custom. Iterator. Buildin g. Damage. xml category - Building

Register Custom Analysis Task Register at ogre. Tasks extension point id – edu. illinois.

Register Custom Analysis Task Register at ogre. Tasks extension point id – edu. illinois. ncsa. ergo. eq. tutorial. ta sks. Custom. Iterator. Analysis. Task name – Custom Building Damage tag - example class - edu. illinois. ncsa. ergo. eq. tutorial. ta sks. Custom. Iterator. Analysis. Task

Run Custom Iterator To see your new analysis with custom iterator, re-launch Ergo-EQ Open

Run Custom Iterator To see your new analysis with custom iterator, re-launch Ergo-EQ Open a scenario and follow the previous steps for executing a new analysis, you should see Custom Building Damage in the Building category

Questions?

Questions?

Resources User/Developer Documentation https: //opensource. ncsa. illinois. edu/confluence/display/ER GO/Ergo+Home Analysis Framework Developer’s Guide https:

Resources User/Developer Documentation https: //opensource. ncsa. illinois. edu/confluence/display/ER GO/Ergo+Home Analysis Framework Developer’s Guide https: //opensource. ncsa. illinois. edu/confluence/display/ER GO/Analysis+Framework+Developer%27 s+Guide Adding Dataset Types https: //opensource. ncsa. illinois. edu/confluence/display/ER GO/Creating+New+Data+Schemas Git e-book http: //git-scm. com/book