Issue #2086 Move data delivery phase 3 code into AWIPS_baseline

Change-Id: I60bf6ac9d886d27c70543a0b7df24d626639fc3e

Former-commit-id: 1c7d99f53f [formerly c213b3b5552a2b11c69965bc6edcfb8acf7fa0a8]
Former-commit-id: da69d3e630
This commit is contained in:
Dustin Johnson 2013-06-10 17:54:15 -05:00
parent 9c3d79ad8e
commit 063e68bc93
397 changed files with 45119 additions and 106 deletions

View file

@ -49,7 +49,6 @@ import com.raytheon.uf.common.datadelivery.registry.PointTime;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.datadelivery.registry.ebxml.DataSetQuery;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -319,91 +318,89 @@ public class CreateSubscriptionDlg extends CaveSWTDialog implements
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
GridLayout gl = new GridLayout(2, false);
if (DataDeliveryConstants.PHASE3_ENABLED) {
final Group group = new Group(mainComp, SWT.NONE);
group.setLayout(gl);
group.setLayoutData(gd);
group.setText(" Shared Sites ");
final Group group = new Group(mainComp, SWT.NONE);
group.setLayout(gl);
group.setLayoutData(gd);
group.setText(" Shared Sites ");
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
gl = new GridLayout(2, false);
final Composite c = new Composite(group, SWT.NONE);
c.setLayout(gl);
c.setLayoutData(gd);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
gl = new GridLayout(2, false);
final Composite c = new Composite(group, SWT.NONE);
c.setLayout(gl);
c.setLayoutData(gd);
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
final Button btn = new Button(c, SWT.NONE);
btn.setLayoutData(new GridData(95, SWT.DEFAULT));
btn.setText("Select Sites...");
btn.setToolTipText("Select sites for sharing");
btn.setEnabled(false);
gl = new GridLayout(1, false);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
final Button btn = new Button(c, SWT.NONE);
btn.setLayoutData(new GridData(95, SWT.DEFAULT));
btn.setText("Select Sites...");
btn.setToolTipText("Select sites for sharing");
btn.setEnabled(false);
final DataDeliveryPermission permission = DataDeliveryPermission.SHARED_SUBSCRIPTION_CREATE;
final IUser user = UserController.getUserObject();
final String msg = user.uniqueId()
+ " is not authorized to create shared subscriptions. "
+ StringUtil.NEWLINE + "Permission: " + permission;
try {
if (DataDeliveryServices.getPermissionsService()
.checkPermission(user, msg, permission).isAuthorized()) {
btn.setEnabled(true);
} else {
c.addMouseTrackListener(new MouseTrackAdapter() {
final DataDeliveryPermission permission = DataDeliveryPermission.SHARED_SUBSCRIPTION_CREATE;
final IUser user = UserController.getUserObject();
final String msg = user.uniqueId()
+ " is not authorized to create shared subscriptions. "
+ StringUtil.NEWLINE + "Permission: " + permission;
try {
if (DataDeliveryServices.getPermissionsService()
.checkPermission(user, msg, permission).isAuthorized()) {
btn.setEnabled(true);
} else {
c.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
DataDeliveryGUIUtils.hideToolTip();
}
@Override
public void mouseExit(MouseEvent e) {
DataDeliveryGUIUtils.hideToolTip();
}
@Override
public void mouseHover(MouseEvent e) {
handleMouseEvent(e, msg, group.getBounds());
}
@Override
public void mouseHover(MouseEvent e) {
handleMouseEvent(e, msg, group.getBounds());
}
@Override
public void mouseEnter(MouseEvent e) {
handleMouseEvent(e, msg, group.getBounds());
}
});
}
} catch (VizException e1) {
statusHandler.handle(Priority.PROBLEM,
e1.getLocalizedMessage(), e1);
@Override
public void mouseEnter(MouseEvent e) {
handleMouseEvent(e, msg, group.getBounds());
}
});
}
btn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SiteSelectionDlg dlg = new SiteSelectionDlg(shell, "OAX",
sharedSites);
dlg.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
if (returnValue instanceof String[]) {
String[] sites = (String[]) returnValue;
processSites(sites);
}
} catch (VizException e1) {
statusHandler
.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1);
}
btn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SiteSelectionDlg dlg = new SiteSelectionDlg(shell, "OAX",
sharedSites);
dlg.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
if (returnValue instanceof String[]) {
String[] sites = (String[]) returnValue;
processSites(sites);
}
});
dlg.open();
}
});
}
});
dlg.open();
}
});
selectedSiteLbl = new Label(group, SWT.BORDER);
selectedSiteLbl.setFont(font);
selectedSiteLbl.setText("");
selectedSiteLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
true, false));
selectedSiteLbl = new Label(group, SWT.BORDER);
selectedSiteLbl.setFont(font);
selectedSiteLbl.setText("");
selectedSiteLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false));
if (!create) {
if (subscription != null
&& subscription.getOfficeIDs().size() > 0) {
String[] siteArr = subscription.getOfficeIDs().toArray(
new String[subscription.getOfficeIDs().size()]);
processSites(siteArr);
}
if (!create) {
if (subscription != null && subscription.getOfficeIDs().size() > 0) {
String[] siteArr = subscription.getOfficeIDs().toArray(
new String[subscription.getOfficeIDs().size()]);
processSites(siteArr);
}
}
}
/**

View file

@ -54,7 +54,6 @@ import com.raytheon.uf.common.datadelivery.registry.PointDataSet;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
import com.raytheon.uf.common.datadelivery.retrieval.util.DataSizeUtils;
import com.raytheon.uf.common.geospatial.MapUtil;
@ -420,7 +419,7 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
/** Create the buttons */
private void createButtons() {
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
final int numColumns = (DataDeliveryConstants.PHASE3_ENABLED) ? 4 : 3;
final int numColumns = 4;
GridLayout gl = new GridLayout(numColumns, false);
Composite bottomComp = new Composite(shell, SWT.NONE);

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="filter-v_1_0_0-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="filter-v_1_1_0-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="gml-v_2_1_2-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="gml-v_3_1_1-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="jaxb2-basics-runtime-0.6.0.jar"/>
<classpathentry exported="true" kind="lib" path="kml-v_2_2_0-schema-1.0.3.jar"/>
<classpathentry exported="true" kind="lib" path="ows-v_1_0_0-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="ows-v_1_1_0-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="se-v_1_1_0-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="sld-v_1_0_0-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="sld-v_1_1_0-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="wcs-v_1_1_2-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="wfs-v_1_1_0-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="wms-v_1_3_0-schema-1.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="wmts-v_1_0_0-schema-1.0.3.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

28
cots/net.opengis/.project Normal file
View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>net.opengis</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>

View file

@ -0,0 +1,8 @@
#Fri Jun 08 12:00:15 CDT 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,44 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Opengis
Bundle-SymbolicName: net.opengis
Bundle-Version: 1.0.2
Bundle-ClassPath: filter-v_1_0_0-schema-1.0.2.jar,
filter-v_1_1_0-schema-1.0.2.jar,
gml-v_2_1_2-schema-1.0.2.jar,
gml-v_3_1_1-schema-1.0.2.jar,
jaxb2-basics-runtime-0.6.0.jar,
kml-v_2_2_0-schema-1.0.3.jar,
ows-v_1_0_0-schema-1.0.2.jar,
ows-v_1_1_0-schema-1.0.2.jar,
se-v_1_1_0-schema-1.0.2.jar,
sld-v_1_0_0-schema-1.0.2.jar,
sld-v_1_1_0-schema-1.0.2.jar,
wcs-v_1_1_2-schema-1.0.2.jar,
wfs-v_1_1_0-schema-1.0.2.jar,
wms-v_1_3_0-schema-1.0.2.jar,
wmts-v_1_0_0-schema-1.0.3.1.jar
Export-Package: net.opengis.filter.v_1_0_0,
net.opengis.filter.v_1_1_0,
net.opengis.gml.v_2_1_2,
net.opengis.gml.v_3_1_1,
net.opengis.kml.v_2_2_0,
net.opengis.ows.v_1_0_0,
net.opengis.ows.v_1_1_0,
net.opengis.se.v_1_1_0,
net.opengis.sld.v_1_0_0,
net.opengis.sld.v_1_1_0,
net.opengis.wcs.v_1_1_2,
net.opengis.wfs.v_1_1_0,
net.opengis.wms.v_1_3_0,
net.opengis.wmts.v_1_0_0,
oasis.names.tc.ciq.xsdschema.xal._2,
org.jvnet.jaxb2_commons.i18n,
org.jvnet.jaxb2_commons.lang,
org.jvnet.jaxb2_commons.locator,
org.jvnet.jaxb2_commons.locator.util,
org.jvnet.jaxb2_commons.xml.bind,
org.jvnet.jaxb2_commons.xml.bind.annotation.adapters,
org.w3.smil.v_2_0,
org.w3.smil.v_2_0.language
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -0,0 +1,17 @@
bin.includes = META-INF/,\
.,\
filter-v_1_0_0-schema-1.0.2.jar,\
filter-v_1_1_0-schema-1.0.2.jar,\
gml-v_2_1_2-schema-1.0.2.jar,\
gml-v_3_1_1-schema-1.0.2.jar,\
jaxb2-basics-runtime-0.6.0.jar,\
kml-v_2_2_0-schema-1.0.3.jar,\
ows-v_1_0_0-schema-1.0.2.jar,\
ows-v_1_1_0-schema-1.0.2.jar,\
se-v_1_1_0-schema-1.0.2.jar,\
sld-v_1_0_0-schema-1.0.2.jar,\
sld-v_1_1_0-schema-1.0.2.jar,\
wcs-v_1_1_2-schema-1.0.2.jar,\
wfs-v_1_1_0-schema-1.0.2.jar,\
wms-v_1_3_0-schema-1.0.2.jar,\
wmts-v_1_0_0-schema-1.0.3.1.jar

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="ogc-tools-gml-jts-1.0.2.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ogc.tools.gml</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>

View file

@ -0,0 +1,8 @@
#Fri Jun 08 11:56:09 CDT 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,11 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ogc.tools.gml
Bundle-SymbolicName: ogc.tools.gml
Bundle-Version: 1.0.2
Bundle-ClassPath: ogc-tools-gml-jts-1.0.2.jar
Export-Package: org.jvnet.ogc.gml.v_3_1_1,
org.jvnet.ogc.gml.v_3_1_1.jts
Require-Bundle: org.geotools;bundle-version="2.6.4",
net.opengis;bundle-version="1.0.2"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -0,0 +1,3 @@
bin.includes = META-INF/,\
.,\
ogc-tools-gml-jts-1.0.2.jar

Binary file not shown.

View file

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.common.datadelivery.request;
import com.raytheon.uf.common.util.ServiceLoaderUtil;
/**
* Consolidates data delivery server constants.
@ -46,19 +45,6 @@ public final class DataDeliveryConstants {
public static final String NCF_BANDWIDTH_MANAGER_SERVICE = "ncf.bandwidth.manager.service";
/**
* Denotes whether or not the phase 3 code is enabled. Will only return true
* if components from the 5-Data_Delivery repository are installed.
*/
public static final boolean PHASE3_ENABLED = ServiceLoaderUtil.load(
DataDeliveryConstants.class, IPhase3Initializer.class,
new IPhase3Initializer() {
@Override
public boolean isPhase3CodeEnabled() {
return false;
}
}).isPhase3CodeEnabled();
/**
* Private constructor.
*/

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.common.dataplugin.madis</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>

View file

@ -0,0 +1,8 @@
#Wed Mar 20 13:58:02 CDT 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Madis
Bundle-SymbolicName: com.raytheon.uf.common.dataplugin.madis
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Export-Package: com.raytheon.uf.common.dataplugin.madis
Require-Bundle: javax.persistence;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
javax.measure;bundle-version="1.0.0",
com.raytheon.edex.common;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy

View file

@ -0,0 +1 @@
com.raytheon.uf.common.dataplugin.madis.MadisRecord

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.common.spatial</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>

View file

@ -0,0 +1,8 @@
#Thu Dec 02 10:55:26 CST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.raytheon.uf.common.spatial
Bundle-SymbolicName: com.raytheon.uf.common.spatial
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.raytheon.uf.common.spatial.reprojection
Require-Bundle: org.apache.commons.lang;bundle-version="2.3.0",
org.apache.commons.logging;bundle-version="1.1.1",
org.geotools;bundle-version="2.6.4",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
com.raytheon.uf.common.datastorage;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization;bundle-version="1.12.1174"

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,150 @@
/*
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* 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/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 15, 2011 bclement Initial creation
*
*/
package com.raytheon.uf.common.spatial.reprojection;
import java.awt.image.DataBuffer;
import java.awt.image.WritableRaster;
import javax.media.jai.RasterFactory;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.coverage.grid.GridCoverageFactory;
import org.geotools.geometry.jts.ReferencedEnvelope;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
/**
*
* @author bclement
* @version 1.0
*/
public abstract class AbstractDataReprojector<T extends IDataRecord> {
public static class RequestWrapper {
public Request req;
public ReferencedEnvelope env;
}
/**
* Copy data record into geotools grid coverage object
*
* @param dataRecord
* datset
* @param env
* geographics bounds for dataset
* @return
* @throws Exception
*/
protected abstract GridCoverage2D getGridCoverage(IDataRecord dataRecord,
ReferencedEnvelope env) throws Exception;
/**
* Copy data record into geotools grid coverage object
*
* @param dataRecord
* datset
* @param env
* geographics bounds for dataset
* @return
* @throws Exception
*/
protected abstract GridCoverage2D getMaskCoverage(IDataRecord dataRecord,
ReferencedEnvelope env) throws Exception;
/**
* Extract data from geotools coverage object into data record object
*
* @param coverage
* @return
*/
protected abstract T extractData(GridCoverage2D coverage);
/**
* Extract data from geotools coverage object into data record object with a
* mask for covering the non-data area.
*
* @param coverage
* @param maskCoverage
* @return
*/
protected abstract T extractData(GridCoverage2D coverage,
GridCoverage2D maskCoverage);
/**
* Apply slab request to data record, returning result in a new data record
* object.
*
* @param dataRecord
* @param req
* @return
*/
protected abstract T getDataSlice(IDataRecord dataRecord, Request req);
/**
* @param dataRecord
* @return true if this object can operate on native type of data record
*/
protected abstract boolean compatible(IDataRecord dataRecord);
/**
* Apply point request to data record, returning result in a new data record
* object.
*
* @param record
* @param req
* @return
*/
protected abstract IDataRecord getDataPoints(IDataRecord record, Request req);
/**
* Construct a new geotools grid coverage object using data buffer
*
* @param name
* name of coverage
* @param data
* raw data
* @param width
* @param height
* @param env
* geographic bounds of coverage
* @return
* @throws Exception
*/
public static GridCoverage2D constructGridCoverage(String name,
DataBuffer data, int width, int height, ReferencedEnvelope env)
throws Exception {
WritableRaster raster = RasterFactory.createBandedRaster(data, width,
height, width, new int[] { 0 }, new int[] { 0 }, null);
return new GridCoverageFactory().create(name, raster, env);
}
}

View file

@ -0,0 +1,238 @@
/*
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* 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/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 18, 2011 bclement Initial creation
*
*/
package com.raytheon.uf.common.spatial.reprojection;
import java.awt.Point;
import java.awt.image.DataBufferByte;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.util.Arrays;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
/**
*
* @author bclement
* @version 1.0
*/
public class ByteDataReprojector extends
AbstractDataReprojector<ByteDataRecord> {
protected byte fill = 0;
protected byte dataMaskValue = -1;
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getGridCoverage
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
* org.opengis.referencing.crs.CoordinateReferenceSystem,
* org.opengis.geometry.Envelope)
*/
@Override
protected GridCoverage2D getGridCoverage(IDataRecord record,
ReferencedEnvelope env)
throws Exception {
ByteDataRecord dataRecord = (ByteDataRecord) record;
byte[] data = dataRecord.getByteData();
DataBufferByte buff = new DataBufferByte(data, data.length);
int x = (int) dataRecord.getSizes()[0];
int y = (int) dataRecord.getSizes()[1];
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getMaskCoverage
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
* org.opengis.referencing.crs.CoordinateReferenceSystem,
* org.opengis.geometry.Envelope)
*/
@Override
protected GridCoverage2D getMaskCoverage(IDataRecord record,
ReferencedEnvelope env) throws Exception {
int x = (int) record.getSizes()[0];
int y = (int) record.getSizes()[1];
byte[] mask = new byte[x * y];
Arrays.fill(mask, dataMaskValue);
DataBufferByte buff = new DataBufferByte(mask, mask.length);
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
* .geotools.coverage.grid.GridCoverage2D)
*/
@Override
protected ByteDataRecord extractData(GridCoverage2D coverage) {
RenderedImage image = coverage.getRenderedImage();
Raster raster;
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer();
byte[] data = dataBuffer.getData();
int height = raster.getHeight();
int width = raster.getWidth();
return new ByteDataRecord("", "", data, 2, new long[] { width, height });
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
* .geotools.coverage.grid.GridCoverage2D,
* org.geotools.coverage.grid.GridCoverage2D)
*/
@Override
protected ByteDataRecord extractData(GridCoverage2D coverage,
GridCoverage2D maskCoverage) {
RenderedImage image = coverage.getRenderedImage();
Raster raster;
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer();
byte[] data = dataBuffer.getData();
// Extract mask
image = maskCoverage.getRenderedImage();
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
dataBuffer = (DataBufferByte) raster.getDataBuffer();
byte[] mask = dataBuffer.getData();
if (mask.length == data.length) {
for (int i = 0; i < data.length; ++i) {
if (mask[i] != dataMaskValue) {
data[i] = fill;
}
}
}
int height = raster.getHeight();
int width = raster.getWidth();
return new ByteDataRecord("", "", data, 2, new long[] { width, height });
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getDataSlice(com
* .raytheon.uf.common.datastorage.records.IDataRecord,
* com.raytheon.uf.common.datastorage.Request)
*/
@Override
protected ByteDataRecord getDataSlice(IDataRecord record, Request req) {
ByteDataRecord dataRecord = (ByteDataRecord) record;
int[] max = req.getMaxIndexForSlab();
int[] min = req.getMinIndexForSlab();
int toWidth = max[0] - min[0];
int toHeight = max[1] - min[1];
byte[] from = dataRecord.getByteData();
int fromWidth = (int) dataRecord.getSizes()[0];
byte[] to = new byte[toWidth * toHeight];
for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) {
int toRow = toY * toWidth;
int fromRow = fromY * fromWidth;
for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) {
to[toRow + toX] = from[fromRow + fromX];
}
}
long[] sizes = { toWidth, toHeight };
return new ByteDataRecord("", "", to, 2, sizes);
}
public byte getFill() {
return fill;
}
public void setFill(byte fill) {
this.fill = fill;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector#compatible
* (com.raytheon.uf.common.datastorage.records.IDataRecord)
*/
@Override
protected boolean compatible(IDataRecord dataRecord) {
return dataRecord instanceof ByteDataRecord;
}
@Override
protected IDataRecord getDataPoints(IDataRecord record, Request req) {
ByteDataRecord dataRecord = (ByteDataRecord) record;
byte[] from = dataRecord.getByteData();
int fromWidth = (int) dataRecord.getSizes()[0];
Point[] points = req.getPoints();
byte[] to = new byte[points.length];
for (int i = 0; i < to.length; ++i) {
Point p = points[i];
to[i] = from[p.y * fromWidth + p.x];
}
return new ByteDataRecord("", "", to, 1, new long[] { to.length });
}
}

View file

@ -0,0 +1,624 @@
/*
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* 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/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 18, 2011 bclement Initial creation
*
*/
package com.raytheon.uf.common.spatial.reprojection;
import java.awt.Point;
import java.io.FileNotFoundException;
import java.util.Iterator;
import java.util.Set;
import javax.media.jai.Interpolation;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.geotools.coverage.grid.GeneralGridEnvelope;
import org.geotools.coverage.grid.GridCoordinates2D;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.coverage.grid.ViewType;
import org.geotools.coverage.processing.Operations;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.geometry.DirectPosition;
import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.metadata.spatial.PixelOrientation;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform2D;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
import com.raytheon.uf.common.datastorage.records.ShortDataRecord;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector.RequestWrapper;
import com.raytheon.uf.common.spatial.reprojection.KeyLocker.KeyLock;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
/**
*
* @author bclement
* @version 1.0
*/
public class DataReprojector {
protected IDataStore dataStore;
protected String dataSetBase = "Data-";
protected String dataSet = "Data";
private AbstractDataReprojector<? extends IDataRecord> _typeProjector;
protected static Log log = LogFactory.getLog(DataReprojector.class);
protected static KeyLocker locker = new KeyLocker();
public DataReprojector(IDataStore dataStore) {
this.dataStore = dataStore;
}
/**
* @param group
* name of the datastore group that contains requested dataset
* @param spatial
* spatial object tied to requested dataset
* @param nativeEnv
* native bounds of dataset
* @param crs
* desired crs of returned data
* @param coords
* coordinates of requested data in requested crs
* @return null if any of the coordinates are out of the bounds of the grid
* geometry
* @throws Exception
*/
public IDataRecord getProjectedPoints(String group, ISpatialObject spatial,
ReferencedEnvelope nativeEnv, CoordinateReferenceSystem crs,
Coordinate[] coords) throws Exception {
// get envelope in requested projection
ReferencedEnvelope targetEnv = nativeEnv.transform(crs, true);
// get target grid geometry
GridGeometry2D geom = getGridGeometry(targetEnv, spatial.getNx(),
spatial.getNy());
Point[] points = new Point[coords.length];
for (int i = 0; i < points.length; ++i) {
Coordinate coord = coords[i];
GridCoordinates2D point = getGridPoint(geom, coord);
int nx = spatial.getNx();
int ny = spatial.getNy();
// coordinate was out of bounds, bail
if (point.x < 0 || point.x > nx || point.y < 0 || point.y > ny) {
return null;
}
// need to repackage point due to pypies not knowing about
// gridcoordinates2d
points[i] = new Point(point);
}
String reprojectedDataset = buildDatasetName(crs);
Request req = Request.buildPointRequest(points);
return getDataRecordWithReproject(group, reprojectedDataset, spatial,
crs, req);
}
/**
* @param group
* name of the datastore group that contains requested dataset
* @param reprojectedDataset
* dataset name for reprojected data
* @param spatial
* spatial object tied to requested dataset
* @param crs
* desired crs of returned data
* @param req
* datastore request object
* @return
* @throws Exception
*/
protected IDataRecord getDataRecordWithReproject(String group,
String reprojectedDataset, ISpatialObject spatial,
CoordinateReferenceSystem crs, Request req) throws Exception {
IDataRecord dataRecord;
// check if data has already been reprojected
if (!datasetExists(group, reprojectedDataset)) {
// it hasn't lock and reproject
dataRecord = reprojectLocked(group, reprojectedDataset, spatial,
crs, req);
} else {
// it has, just request the data
dataRecord = getDataRecord(group, reprojectedDataset, req);
}
return dataRecord;
}
/**
* @param group
* name of the datastore group that contains requested dataset
* @param reprojectedDataset
* dataset name for reprojected data
* @param spatial
* spatial object tied to requested dataset
* @param crs
* desired crs of returned data
* @param req
* datastore request object
* @return
* @throws Exception
*/
protected IDataRecord reprojectLocked(String group,
String reprojectedDataset, ISpatialObject spatial,
CoordinateReferenceSystem crs, Request req) throws Exception {
KeyLock lock = null;
IDataRecord dataRecord;
try {
// get reproject lock
lock = locker.getLock(group + reprojectedDataset);
lock.lock();
// recheck that dataset still doesn't exist
if (!datasetExists(group, reprojectedDataset)) {
// still not there, reproject
dataRecord = reprojectAndStore(spatial, group, crs, req);
} else {
// another thread created it, just grab it
dataRecord = getDataRecord(group, reprojectedDataset, req);
}
lock.unlock();
return dataRecord;
} finally {
if (lock != null) {
lock.release();
}
}
}
/**
* @param group
* @param dataset
* @return true if dataset exists in datastore
* @throws FileNotFoundException
* @throws StorageException
*/
protected boolean datasetExists(String group, String dataset)
throws FileNotFoundException, StorageException {
String[] datasets = dataStore.getDatasets(group);
return ArrayUtils.contains(datasets, dataset);
}
/**
* @param geom
* Grid geometry
* @param coord
* desired geographic coordinate
* @return grid point for coordinate
* @throws PluginException
*/
public static GridCoordinates2D getGridPoint(GridGeometry2D geom,
Coordinate coord) throws PluginException {
DirectPosition src = new DirectPosition2D(coord.x, coord.y);
DirectPosition inGrid = new DirectPosition2D();
try {
MathTransform2D crsToGrid2D = geom
.getCRSToGrid2D(PixelOrientation.UPPER_LEFT);
crsToGrid2D.transform(src, inGrid);
} catch (Exception e) {
throw new PluginException("Unable to get grid point for geometry",
e);
}
// floor of grid points should be upper left of pixel
int x = (int) Math.floor(inGrid.getOrdinate(0));
int y = (int) Math.floor(inGrid.getOrdinate(1));
GridCoordinates2D rval = new GridCoordinates2D(x, y);
return rval;
}
/**
* @param group
* name of the datastore group that contains requested dataset
* @param spatial
* spatial object tied to requested dataset
* @param nativeEnv
* native bounds of dataset
* @param targetEnv
* bounds of requested data
* @return null if target envelope is out of bounds for dataset
* @throws Exception
*/
public GridCoverage2D getReprojectedCoverage(String group,
ISpatialObject spatial, ReferencedEnvelope nativeEnv,
ReferencedEnvelope targetEnv)
throws Exception {
ReferencedDataRecord rep = getReprojected(group, spatial, nativeEnv,
targetEnv);
if (rep == null) {
return null;
}
ReferencedEnvelope re = rep.getEnvelope();
IDataRecord record = rep.getRecord();
return getTypeProjector(record).getGridCoverage(rep.getRecord(), re);
}
/**
* @param group
* name of the datastore group that contains requested dataset
* @param spatial
* spatial object tied to requested dataset
* @param nativeEnvelope
* native bounds of dataset
* @param targetEnvelope
* bounds of requested data
* @return null if target envelope is out of bounds for dataset
* @throws Exception
*/
public ReferencedDataRecord getReprojected(String group,
ISpatialObject spatial, ReferencedEnvelope nativeEnvelope,
ReferencedEnvelope targetEnvelope)
throws Exception {
RequestWrapper req = getRequest(spatial, nativeEnvelope, targetEnvelope);
if (req == null) {
return null;
}
CoordinateReferenceSystem targetCrs = targetEnvelope
.getCoordinateReferenceSystem();
String reprojectedDataset = buildDatasetName(targetCrs);
IDataRecord dataRecord = getDataRecordWithReproject(group,
reprojectedDataset, spatial, targetCrs, req.req);
return new ReferencedDataRecord(dataRecord, req.env);
}
/**
* @param group
* name of the datastore group that contains requested dataset
* @param targetDataset
* dataset name for requested data
* @param req
* datastore request object
* @return
* @throws Exception
*/
protected IDataRecord getDataRecord(String group, String targetDataset,
Request req) throws Exception {
IDataRecord rval = dataStore.retrieve(group, targetDataset, req);
return rval;
}
/**
* Get a projector that is compatible with record
*
* @param record
* @return
* @throws Exception
*/
protected AbstractDataReprojector<? extends IDataRecord> getTypeProjector(
IDataRecord record) throws Exception {
if (_typeProjector == null || !_typeProjector.compatible(record)) {
if (record instanceof ByteDataRecord) {
_typeProjector = new ByteDataReprojector();
} else if (record instanceof FloatDataRecord) {
_typeProjector = new FloatDataReprojector();
} else if (record instanceof ShortDataRecord) {
_typeProjector = new ShortDataReprojector();
} else if (record instanceof IntegerDataRecord) {
_typeProjector = new IntDataReprojector();
} else {
throw new Exception("Unsupported data store type");
}
}
return _typeProjector;
}
/**
* Gets the entire coverage from the store and reprojects it. Reprojected
* coverage is then stored under a name derived from the projected crs.
*
* @param spatial
* spatial object tied to requested dataset
* @param group
* name of the datastore group that contains requested dataset
* @param targetCRS
* desired crs of returned data
* @param req
* datastore request object
* @return datarecord as per the request object
* @throws Exception
*/
protected IDataRecord reprojectAndStore(ISpatialObject spatial,
String group, CoordinateReferenceSystem targetCRS, Request req)
throws Exception {
GridGeometry2D geom = MapUtil.getGridGeometry(spatial);
IDataRecord original = getDataRecord(group, dataSet, Request.ALL);
ReferencedEnvelope env = new ReferencedEnvelope(geom.getEnvelope());
AbstractDataReprojector<? extends IDataRecord> typeProjector = getTypeProjector(original);
GridCoverage2D cov = typeProjector.getGridCoverage(original, env);
GridCoverage2D reprojected = MapUtil.reprojectCoverage(cov, targetCRS);
IDataRecord rval;
if (typeProjector instanceof FloatDataReprojector) {
// TODO So far, the problem that this fixes has only appeared with
// float data. If it happens with other data we can change this.
GridCoverage2D maskCov = typeProjector.getMaskCoverage(original,
env);
GridCoverage2D reprojectedMask = (GridCoverage2D) Operations.DEFAULT
.resample(maskCov.view(ViewType.GEOPHYSICS), targetCRS,
null, Interpolation
.getInstance(Interpolation.INTERP_NEAREST));
rval = typeProjector.extractData(reprojected, reprojectedMask);
} else {
rval = typeProjector.extractData(reprojected);
}
rval.setGroup(group);
rval.setName(buildDatasetName(targetCRS));
dataStore.addDataRecord(rval);
dataStore.store();
return getDataPerReq(rval, req);
}
/**
* @param record
* data record containing full coverage
* @param req
* datastore request object
* @return result of applying request object to data record
* @throws Exception
*/
protected IDataRecord getDataPerReq(IDataRecord record, Request req)
throws Exception {
AbstractDataReprojector<? extends IDataRecord> typeProjector = getTypeProjector(record);
IDataRecord rval;
switch (req.getType()) {
case ALL:
rval = record;
break;
case POINT:
rval = typeProjector.getDataPoints(record, req);
break;
case SLAB:
rval = typeProjector.getDataSlice(record, req);
break;
case XLINE:
case YLINE:
default:
throw new Exception("Data reprojector " + req.getType()
+ " not implemented");
}
return rval;
}
/**
* @param env
* geographic bounds of data
* @param nx
* length of x axis
* @param ny
* length of y axis
* @return
*/
public static GridGeometry2D getGridGeometry(ReferencedEnvelope env,
int nx, int ny) {
// TODO cache
GridGeometry2D mapGeom = null;
mapGeom = new GridGeometry2D(new GeneralGridEnvelope(
new int[] { 0, 0 }, new int[] { nx, ny }, false), env);
return mapGeom;
}
/**
* Build up slice request for reprojected dataset
*
* @param record
* @param crs
* @param targetEnvelope
* bbox in crs
* @return null if envelope is outside of data bounds
* @throws TransformException
* @throws MismatchedDimensionException
* @throws FactoryException
*/
protected RequestWrapper getRequest(ISpatialObject spatial,
ReferencedEnvelope nativeEnv, ReferencedEnvelope targetEnvelope)
throws MismatchedDimensionException,
TransformException, FactoryException {
RequestWrapper rval = null;
CoordinateReferenceSystem targetCrs = targetEnvelope
.getCoordinateReferenceSystem();
// get full bounds of reprojected dataset
ReferencedEnvelope dataEnv = nativeEnv.transform(targetCrs, true);
if (!dataEnv.intersects((Envelope) targetEnvelope)) {
// request and data envelopes are disjoint, return null
return null;
}
// get grid geometry for reprojected dataset
GridGeometry2D geom = getGridGeometry(dataEnv, spatial.getNx(),
spatial.getNy());
int[] dims = { spatial.getNx(), spatial.getNy() };
if (dataEnv.contains((Envelope) targetEnvelope)) {
// requested slice is entirely inside data bounds
// build slice based on requested bounds
rval = getSubSlice(geom, targetEnvelope, dims);
} else {
// build slice based on intersection
Envelope intersection = targetEnvelope.intersection(dataEnv);
rval = getSubSlice(geom, intersection, dims);
}
return rval;
}
/**
* @param geom
* grid geometry for projected dataset
* @param env
* geographic bounds for slice
* @param dims
* dimensions of dataset
* @return grid slice that corresponds to env
* @throws MismatchedDimensionException
* @throws TransformException
*/
protected RequestWrapper getSubSlice(GridGeometry2D geom, Envelope env,
int[] dims) throws MismatchedDimensionException, TransformException {
RequestWrapper rval = new RequestWrapper();
MathTransform2D crsToGrid2D = geom
.getCRSToGrid2D(PixelOrientation.UPPER_LEFT);
// find a slice that has data for entire envelope (can have extra)
int[][] minmax = transformEnv(crsToGrid2D, env, dims);
MathTransform2D gridToCrs = crsToGrid2D.inverse();
// find an envelope that matches the slice (could be a bit larger than
// previous envelope)
rval.env = transformGrid(gridToCrs, minmax,
geom.getCoordinateReferenceSystem());
rval.req = Request.buildSlab(minmax[0], minmax[1]);
return rval;
}
/**
* @param gridToCrs
* @param minmax
* 2d array holding slice
* @param crs
* @return
* @throws MismatchedDimensionException
* @throws TransformException
*/
protected ReferencedEnvelope transformGrid(MathTransform2D gridToCrs,
int[][] minmax, CoordinateReferenceSystem crs)
throws MismatchedDimensionException, TransformException {
int[] min = minmax[0];
int[] max = minmax[1];
DirectPosition lower = new DirectPosition2D(min[0], min[1]);
DirectPosition upper = new DirectPosition2D(max[0], max[1]);
DirectPosition lowerCrs = gridToCrs.transform(lower, null);
DirectPosition upperCrs = gridToCrs.transform(upper, null);
double x0 = lowerCrs.getOrdinate(0);
double x1 = upperCrs.getOrdinate(0);
// handle y axis flip
double y0 = upperCrs.getOrdinate(1);
double y1 = lowerCrs.getOrdinate(1);
return new ReferencedEnvelope(x0, x1, y0, y1, crs);
}
/**
* transforms crs coordinates to grid indexes using given math transform
*
* @param crsToGrid
* @param env
* @param dims
* max bounds to be limited to
* @return an array with [[minx, miny], [maxx, maxy]]
* @throws MismatchedDimensionException
* @throws TransformException
*/
protected int[][] transformEnv(MathTransform2D crsToGrid, Envelope env,
int[] dims) throws MismatchedDimensionException, TransformException {
DirectPosition lower = new DirectPosition2D(env.getMinX(),
env.getMinY());
DirectPosition upper = new DirectPosition2D(env.getMaxX(),
env.getMaxY());
DirectPosition lowerGrid = crsToGrid.transform(lower, null);
DirectPosition upperGrid = crsToGrid.transform(upper, null);
int x0 = (int) Math.floor(lowerGrid.getOrdinate(0));
// we want ceiling since slices are inclusive
int x1 = (int) Math.ceil(upperGrid.getOrdinate(0));
// handle y axis flip
int y0 = (int) Math.floor(upperGrid.getOrdinate(1));
// we want ceiling since slices are inclusive
int y1 = (int) Math.ceil(lowerGrid.getOrdinate(1));
// truncate requests to dataset dimensions
if (x0 < 0) {
x0 = 0;
}
if (y0 < 0) {
y0 = 0;
}
if (x1 > dims[0]) {
x1 = dims[0];
}
if (y1 > dims[1]) {
y1 = dims[1];
}
return new int[][] { { x0, y0 }, { x1, y1 } };
}
/**
* construct the dataset name based on the name of the crs.
*
* @param crs
* @return
*/
protected String buildDatasetName(CoordinateReferenceSystem crs) {
Set<ReferenceIdentifier> ids = crs.getIdentifiers();
String code;
if (ids == null || ids.isEmpty()) {
code = crs.getName().toString();
} else {
Iterator<ReferenceIdentifier> i = ids.iterator();
code = i.next().toString();
while (i.hasNext()) {
code += "-" + i.next().toString();
}
}
return dataSetBase + code;
}
public IDataStore getDataStore() {
return dataStore;
}
public void setDataStore(IDataStore dataStore) {
this.dataStore = dataStore;
}
public String getDataSetBase() {
return dataSetBase;
}
public void setDataSetBase(String dataSetBase) {
this.dataSetBase = dataSetBase;
}
public String getDataSet() {
return dataSet;
}
public void setDataSet(String dataSet) {
this.dataSet = dataSet;
}
}

View file

@ -0,0 +1,246 @@
/*
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* 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/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 13, 2011 bclement Initial creation
*
*/
package com.raytheon.uf.common.spatial.reprojection;
import java.awt.Point;
import java.awt.image.DataBufferFloat;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.util.Arrays;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
/**
*
* @author bclement
* @version 1.0
*/
public class FloatDataReprojector extends
AbstractDataReprojector<FloatDataRecord> {
protected float fill = -999999.0f;
protected float dataMaskValue = -0;
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getGridCoverage
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
* org.opengis.referencing.crs.CoordinateReferenceSystem,
* org.opengis.geometry.Envelope)
*/
@Override
protected GridCoverage2D getGridCoverage(IDataRecord record,
ReferencedEnvelope env) throws Exception {
FloatDataRecord dataRecord = (FloatDataRecord) record;
float[] data = dataRecord.getFloatData();
DataBufferFloat buff = new DataBufferFloat(data, data.length);
int x = (int) dataRecord.getSizes()[0];
int y = (int) dataRecord.getSizes()[1];
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getMaskCoverage
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
* org.opengis.referencing.crs.CoordinateReferenceSystem,
* org.opengis.geometry.Envelope)
*/
@Override
protected GridCoverage2D getMaskCoverage(IDataRecord record,
ReferencedEnvelope env) throws Exception {
int x = (int) record.getSizes()[0];
int y = (int) record.getSizes()[1];
float[] mask = new float[x * y];
Arrays.fill(mask, dataMaskValue);
DataBufferFloat buff = new DataBufferFloat(mask, mask.length);
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
* .geotools.coverage.grid.GridCoverage2D)
*/
@Override
protected FloatDataRecord extractData(GridCoverage2D coverage) {
RenderedImage image = coverage.getRenderedImage();
Raster raster;
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
DataBufferFloat dataBuffer = (DataBufferFloat) raster.getDataBuffer();
float[] data = dataBuffer.getData();
int height = raster.getHeight();
int width = raster.getWidth();
return new FloatDataRecord("", "", data, 2,
new long[] { width, height });
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
* .geotools.coverage.grid.GridCoverage2D,
* org.geotools.coverage.grid.GridCoverage2D)
*/
@Override
protected FloatDataRecord extractData(GridCoverage2D coverage,
GridCoverage2D maskCoverage) {
RenderedImage image = coverage.getRenderedImage();
Raster raster;
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
DataBufferFloat dataBuffer = (DataBufferFloat) raster.getDataBuffer();
float[] data = dataBuffer.getData();
// Extract mask
image = maskCoverage.getRenderedImage();
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
dataBuffer = (DataBufferFloat) raster.getDataBuffer();
float[] mask = dataBuffer.getData();
if (mask.length == data.length) {
for (int i = 0; i < data.length; ++i) {
if (mask[i] != dataMaskValue) {
data[i] = fill;
}
}
}
int height = raster.getHeight();
int width = raster.getWidth();
return new FloatDataRecord("", "", data, 2,
new long[] { width, height });
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getDataSlice(com
* .raytheon.uf.common.datastorage.records.IDataRecord,
* com.raytheon.uf.common.datastorage.Request)
*/
@Override
protected FloatDataRecord getDataSlice(IDataRecord record, Request req) {
FloatDataRecord dataRecord = (FloatDataRecord) record;
int[] max = req.getMaxIndexForSlab();
int[] min = req.getMinIndexForSlab();
int toWidth = max[0] - min[0];
int toHeight = max[1] - min[1];
float[] from = dataRecord.getFloatData();
int fromWidth = (int) dataRecord.getSizes()[0];
float[] to = new float[toWidth * toHeight];
for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) {
int toRow = toY * toWidth;
int fromRow = fromY * fromWidth;
for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) {
to[toRow + toX] = from[fromRow + fromX];
}
}
long[] sizes = { toWidth, toHeight };
return new FloatDataRecord("", "", to, 2, sizes);
}
/**
* @return the fill
*/
public float getFill() {
return fill;
}
/**
* @param fill
* the fill to set
*/
public void setFill(float fill) {
this.fill = fill;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector#compatible
* (com.raytheon.uf.common.datastorage.records.IDataRecord)
*/
@Override
protected boolean compatible(IDataRecord dataRecord) {
return dataRecord instanceof FloatDataRecord;
}
@Override
protected IDataRecord getDataPoints(IDataRecord record, Request req) {
FloatDataRecord dataRecord = (FloatDataRecord) record;
float[] from = dataRecord.getFloatData();
int fromWidth = (int) dataRecord.getSizes()[0];
Point[] points = req.getPoints();
float[] to = new float[points.length];
for (int i = 0; i < to.length; ++i) {
Point p = points[i];
to[i] = from[p.y * fromWidth + p.x];
}
return new FloatDataRecord("", "", to, 1, new long[] { to.length });
}
}

View file

@ -0,0 +1,247 @@
/*
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* 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/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 13, 2011 bclement Initial creation
*
*/
package com.raytheon.uf.common.spatial.reprojection;
import java.awt.Point;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.util.Arrays;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
/**
*
* @author bclement
* @version 1.0
*/
public class IntDataReprojector extends
AbstractDataReprojector<IntegerDataRecord> {
protected int fill = 0;
protected int dataMaskValue = -1;
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getGridCoverage
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
* org.opengis.referencing.crs.CoordinateReferenceSystem,
* org.opengis.geometry.Envelope)
*/
@Override
protected GridCoverage2D getGridCoverage(IDataRecord record,
ReferencedEnvelope env) throws Exception {
IntegerDataRecord dataRecord = (IntegerDataRecord) record;
int[] data = dataRecord.getIntData();
DataBuffer buff = new DataBufferInt(data, data.length);
int x = (int) dataRecord.getSizes()[0];
int y = (int) dataRecord.getSizes()[1];
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getMaskCoverage
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
* org.opengis.referencing.crs.CoordinateReferenceSystem,
* org.opengis.geometry.Envelope)
*/
@Override
protected GridCoverage2D getMaskCoverage(IDataRecord record,
ReferencedEnvelope env) throws Exception {
int x = (int) record.getSizes()[0];
int y = (int) record.getSizes()[1];
int[] mask = new int[x * y];
Arrays.fill(mask, dataMaskValue);
DataBufferInt buff = new DataBufferInt(mask, mask.length);
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
* .geotools.coverage.grid.GridCoverage2D)
*/
@Override
protected IntegerDataRecord extractData(GridCoverage2D coverage) {
RenderedImage image = coverage.getRenderedImage();
Raster raster;
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer();
int[] data = dataBuffer.getData();
int height = raster.getHeight();
int width = raster.getWidth();
return new IntegerDataRecord("", "", data, 2, new long[] { width,
height });
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
* .geotools.coverage.grid.GridCoverage2D,
* org.geotools.coverage.grid.GridCoverage2D)
*/
@Override
protected IntegerDataRecord extractData(GridCoverage2D coverage,
GridCoverage2D maskCoverage) {
RenderedImage image = coverage.getRenderedImage();
Raster raster;
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer();
int[] data = dataBuffer.getData();
// Extract mask
image = maskCoverage.getRenderedImage();
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
dataBuffer = (DataBufferInt) raster.getDataBuffer();
int[] mask = dataBuffer.getData();
if (mask.length == data.length) {
for (int i = 0; i < data.length; ++i) {
if (mask[i] != dataMaskValue) {
data[i] = fill;
}
}
}
int height = raster.getHeight();
int width = raster.getWidth();
return new IntegerDataRecord("", "", data, 2, new long[] { width,
height });
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getDataSlice(com
* .raytheon.uf.common.datastorage.records.IDataRecord,
* com.raytheon.uf.common.datastorage.Request)
*/
@Override
protected IntegerDataRecord getDataSlice(IDataRecord record, Request req) {
IntegerDataRecord dataRecord = (IntegerDataRecord) record;
int[] max = req.getMaxIndexForSlab();
int[] min = req.getMinIndexForSlab();
int toWidth = max[0] - min[0];
int toHeight = max[1] - min[1];
int[] from = dataRecord.getIntData();
int fromWidth = (int) dataRecord.getSizes()[0];
int[] to = new int[toWidth * toHeight];
for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) {
int toRow = toY * toWidth;
int fromRow = fromY * fromWidth;
for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) {
to[toRow + toX] = from[fromRow + fromX];
}
}
long[] sizes = { toWidth, toHeight };
return new IntegerDataRecord("", "", to, 2, sizes);
}
/**
* @return the fill
*/
public int getFill() {
return fill;
}
/**
* @param fill
* the fill to set
*/
public void setFill(int fill) {
this.fill = fill;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector#compatible
* (com.raytheon.uf.common.datastorage.records.IDataRecord)
*/
@Override
protected boolean compatible(IDataRecord dataRecord) {
return dataRecord instanceof IntegerDataRecord;
}
@Override
protected IDataRecord getDataPoints(IDataRecord record, Request req) {
IntegerDataRecord dataRecord = (IntegerDataRecord) record;
int[] from = dataRecord.getIntData();
int fromWidth = (int) dataRecord.getSizes()[0];
Point[] points = req.getPoints();
int[] to = new int[points.length];
for (int i = 0; i < to.length; ++i) {
Point p = points[i];
to[i] = from[p.y * fromWidth + p.x];
}
return new IntegerDataRecord("", "", to, 1, new long[] { to.length });
}
}

View file

@ -0,0 +1,104 @@
/*
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* 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/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*/
package com.raytheon.uf.common.spatial.reprojection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* Class for managing a pool of concurrency locks organized by string keys.
*
* @author bclement
* @version 1.0
*/
public class KeyLocker {
public class KeyLock {
private final String key;
private final Lock lock;
private boolean released = false;
public KeyLock(String key, Lock lock) {
this.key = key;
this.lock = lock;
}
@Override
protected void finalize() throws Throwable {
release();
}
public void release() {
if (!this.released) {
releaseLock(this.key);
this.released = true;
}
}
public void lock() {
this.lock.lock();
}
public void unlock() {
this.lock.unlock();
}
}
private class Entry {
int count = 0;
final Lock lock = new ReentrantLock();
}
private final Map<String, Entry> locks = new HashMap<String, Entry>();
public KeyLock getLock(String key) {
synchronized (locks) {
Entry e = locks.get(key);
if (e == null) {
e = new Entry();
locks.put(key, e);
}
e.count++;
return new KeyLock(key, e.lock);
}
}
void releaseLock(String key) {
synchronized (locks) {
Entry e = locks.get(key);
if (e != null) {
e.count--;
if (e.count <= 0) {
locks.remove(key);
}
}
}
}
}

View file

@ -0,0 +1,64 @@
/*
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* 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/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 18, 2011 bclement Initial creation
*
*/
package com.raytheon.uf.common.spatial.reprojection;
import org.geotools.geometry.jts.ReferencedEnvelope;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
public class ReferencedDataRecord{
protected IDataRecord record;
protected ReferencedEnvelope envelope;
public ReferencedDataRecord(IDataRecord record, ReferencedEnvelope envlope) {
this.record = record;
this.envelope = envlope;
}
public IDataRecord getRecord() {
return record;
}
public void setRecord(IDataRecord record) {
this.record = record;
}
public ReferencedEnvelope getEnvelope() {
return envelope;
}
public void setEnvelope(ReferencedEnvelope envelope) {
this.envelope = envelope;
}
}

View file

@ -0,0 +1,248 @@
/*
* The following software products were developed by Raytheon:
*
* ADE (AWIPS Development Environment) software
* CAVE (Common AWIPS Visualization Environment) software
* EDEX (Environmental Data Exchange) software
* uFrame (Universal Framework) software
*
* Copyright (c) 2010 Raytheon Co.
* 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/org/documents/epl-v10.php
*
*
* Contractor Name: Raytheon Company
* Contractor Address:
* 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 13, 2011 bclement Initial creation
*
*/
package com.raytheon.uf.common.spatial.reprojection;
import java.awt.Point;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferShort;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.util.Arrays;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.datastorage.records.ShortDataRecord;
/**
* TODO Add Description
*
* @author bclement
* @version 1.0
*/
public class ShortDataReprojector extends
AbstractDataReprojector<ShortDataRecord> {
protected short fill = 0;
protected short dataMaskValue = -1;
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getGridCoverage
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
* org.opengis.referencing.crs.CoordinateReferenceSystem,
* org.opengis.geometry.Envelope)
*/
@Override
protected GridCoverage2D getGridCoverage(IDataRecord record,
ReferencedEnvelope env) throws Exception {
ShortDataRecord dataRecord = (ShortDataRecord) record;
short[] data = dataRecord.getShortData();
DataBuffer buff = new DataBufferShort(data, data.length);
int x = (int) dataRecord.getSizes()[0];
int y = (int) dataRecord.getSizes()[1];
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getMaskCoverage
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
* org.opengis.referencing.crs.CoordinateReferenceSystem,
* org.opengis.geometry.Envelope)
*/
@Override
protected GridCoverage2D getMaskCoverage(IDataRecord record,
ReferencedEnvelope env) throws Exception {
int x = (int) record.getSizes()[0];
int y = (int) record.getSizes()[1];
short[] mask = new short[x * y];
Arrays.fill(mask, dataMaskValue);
DataBufferShort buff = new DataBufferShort(mask, mask.length);
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
* .geotools.coverage.grid.GridCoverage2D)
*/
@Override
protected ShortDataRecord extractData(GridCoverage2D coverage) {
RenderedImage image = coverage.getRenderedImage();
Raster raster;
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
DataBufferShort dataBuffer = (DataBufferShort) raster.getDataBuffer();
short[] data = dataBuffer.getData();
int height = raster.getHeight();
int width = raster.getWidth();
return new ShortDataRecord("", "", data, 2,
new long[] { width, height });
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
* .geotools.coverage.grid.GridCoverage2D,
* org.geotools.coverage.grid.GridCoverage2D)
*/
@Override
protected ShortDataRecord extractData(GridCoverage2D coverage,
GridCoverage2D maskCoverage) {
RenderedImage image = coverage.getRenderedImage();
Raster raster;
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
DataBufferShort dataBuffer = (DataBufferShort) raster.getDataBuffer();
short[] data = dataBuffer.getData();
// Extract mask
image = maskCoverage.getRenderedImage();
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
// we can directly access data
raster = image.getTile(0, 0);
} else {
// need to copy data out
raster = image.getData();
}
dataBuffer = (DataBufferShort) raster.getDataBuffer();
short[] mask = dataBuffer.getData();
if (mask.length == data.length) {
for (int i = 0; i < data.length; ++i) {
if (mask[i] != dataMaskValue) {
data[i] = fill;
}
}
}
int height = raster.getHeight();
int width = raster.getWidth();
return new ShortDataRecord("", "", data, 2,
new long[] { width, height });
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getDataSlice(com
* .raytheon.uf.common.datastorage.records.IDataRecord,
* com.raytheon.uf.common.datastorage.Request)
*/
@Override
protected ShortDataRecord getDataSlice(IDataRecord record, Request req) {
ShortDataRecord dataRecord = (ShortDataRecord) record;
int[] max = req.getMaxIndexForSlab();
int[] min = req.getMinIndexForSlab();
int toWidth = max[0] - min[0];
int toHeight = max[1] - min[1];
short[] from = dataRecord.getShortData();
int fromWidth = (int) dataRecord.getSizes()[0];
short[] to = new short[toWidth * toHeight];
for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) {
int toRow = toY * toWidth;
int fromRow = fromY * fromWidth;
for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) {
to[toRow + toX] = from[fromRow + fromX];
}
}
long[] sizes = { toWidth, toHeight };
return new ShortDataRecord("", "", to, 2, sizes);
}
/**
* @return the fill
*/
public short getFill() {
return fill;
}
/**
* @param fill
* the fill to set
*/
public void setFill(short fill) {
this.fill = fill;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector#compatible
* (com.raytheon.uf.common.datastorage.records.IDataRecord)
*/
@Override
protected boolean compatible(IDataRecord dataRecord) {
return dataRecord instanceof ShortDataRecord;
}
@Override
protected IDataRecord getDataPoints(IDataRecord record, Request req) {
ShortDataRecord dataRecord = (ShortDataRecord) record;
short[] from = dataRecord.getShortData();
int fromWidth = (int) dataRecord.getSizes()[0];
Point[] points = req.getPoints();
short[] to = new short[points.length];
for (int i = 0; i < to.length; ++i) {
Point p = points[i];
to[i] = from[p.y * fromWidth + p.x];
}
return new ShortDataRecord("", "", to, 1, new long[] { to.length });
}
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.datadelivery.bandwidth.ncf</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.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,18 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ncf
Bundle-SymbolicName: com.raytheon.uf.edex.datadelivery.bandwidth.ncf
Bundle-Version: 1.0.0.qualifier
Export-Package: com.raytheon.uf.edex.datadelivery.bandwidth.ncf
Require-Bundle: com.raytheon.uf.common.datadelivery.bandwidth;bundle-version="1.0.0",
com.raytheon.uf.edex.datadelivery.bandwidth;bundle-version="1.0.0",
com.raytheon.uf.common.util;bundle-version="1.12.1174",
com.raytheon.uf.common.datadelivery.registry;bundle-version="1.0.0",
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.registry.event;bundle-version="1.0.0",
com.raytheon.uf.edex.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.edex.core;bundle-version="1.12.1174"

View file

@ -0,0 +1,4 @@
source.. = src/
bin.includes = META-INF/,\
.,\
res/

View file

@ -0,0 +1,29 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<bean id="bandwidthManagerCreator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.ncf.NcfBandwidthManagerCreator" />
<bean id="sbnSubscriptionRetrievalAgentPrototype"
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.SubscriptionRetrievalAgent"
scope="prototype">
<constructor-arg value="SBN" />
<constructor-arg value="notifyRetrieval" />
<constructor-arg ref="retrievalAgentNotifier" />
<constructor-arg value="${bandwidth.default.retrieval.priority}" />
<constructor-arg ref="retrievalManager" />
<constructor-arg ref="bandwidthDao" />
<constructor-arg ref="retrievalDao" />
</bean>
<util:map id="retrievalAgents">
<entry key="Retrievals-1" value-ref="sbnSubscriptionRetrievalAgentPrototype" />
<entry key="Retrievals-2" value-ref="sbnSubscriptionRetrievalAgentPrototype" />
<entry key="Retrievals-3" value-ref="sbnSubscriptionRetrievalAgentPrototype" />
<entry key="Retrievals-4" value-ref="sbnSubscriptionRetrievalAgentPrototype" />
<entry key="Retrievals-5" value-ref="sbnSubscriptionRetrievalAgentPrototype" />
</util:map>
</beans>

View file

@ -0,0 +1,13 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="ncfBandwidthManagerServiceRouter" class="com.raytheon.uf.edex.auth.ServerRequestRouter" />
<bean id="registerNcfBandwidthManagerServiceRouter"
factory-bean="requestRouterRegistry" factory-method="register">
<constructor-arg ref="ncfBandwidthManagerServiceKey" />
<constructor-arg ref="ncfBandwidthManagerServiceRouter" />
</bean>
</beans>

View file

@ -0,0 +1,27 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<util:list id="subscriptionRoutesToSchedule">
<value>SBN</value>
</util:list>
<bean id="SBNRetrievalPlan"
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan">
<constructor-arg value="SBN" />
<constructor-arg ref="BandwidthMap" />
<constructor-arg ref="bandwidthDao" />
<property name="scheduler">
<bean
class="com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.PriorityRetrievalScheduler" />
</property>
</bean>
<util:map id="retrievalPlans">
<entry key="SBN">
<ref local="SBNRetrievalPlan" />
</entry>
</util:map>
</beans>

View file

@ -0,0 +1,30 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="sbnSimulator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.sbn.SbnSimulator" />
<camelContext id="SbnSimulator-context"
xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="errorHandler">
<endpoint id="checkForSbnDataCron"
uri="quartz://datadelivery/sbnSimulator?cron=${sbnSimulator-checkForSbnData.cron}" />
<route id="checkForSbnData">
<from uri="checkForSbnDataCron" />
<doTry>
<pipeline>
<bean ref="sbnSimulator" method="checkForSbnData" />
</pipeline>
<doCatch>
<exception>java.lang.Throwable</exception>
<to
uri="log:SbnSimulator?level=ERROR&amp;showBody=false&amp;showCaughtException=true&amp;showStackTrace=true" />
</doCatch>
</doTry>
</route>
</camelContext>
</beans>

View file

@ -0,0 +1,2 @@
# How often to check for dropped off SBN data
sbnSimulator-checkForSbnData.cron=0+*+*+*+*+?

View file

@ -0,0 +1,121 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.bandwidth.ncf;
import java.util.List;
import java.util.Set;
import com.raytheon.uf.common.datadelivery.bandwidth.ProposeScheduleResponse;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.util.JarUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.BandwidthManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory.IEdexBandwidthManagerCreator;
import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
* {@link IEdexBandwidthManagerCreator} for an NCF bandwidth manager.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 20, 2013 1543 djohnson Initial creation
* Feb 27, 2013 1644 djohnson Schedule SBN subscriptions.
* Mar 11, 2013 1645 djohnson Add missing Spring file.
* May 15, 2013 2000 djohnson Include daos.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class NcfBandwidthManagerCreator implements IEdexBandwidthManagerCreator {
/**
* NCF {@link BandwidthManager} implementation.
*/
static class NcfBandwidthManager extends BandwidthManager {
private static final String[] NCF_BANDWIDTH_MANAGER_FILES = new String[] {
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-ncf-edex-impl.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-edex-impl.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-daos.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-eventbus.xml"),
JarUtil.getResResourcePath("/spring/thrift-bandwidth.xml"),
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-ncf.xml") };
/**
* Constructor.
*
* @param dbInit
* @param bandwidthDao
* @param retrievalManager
* @param bandwidthDaoUtil
*/
public NcfBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
}
@Override
protected String[] getSpringFilesForNewInstance() {
return NCF_BANDWIDTH_MANAGER_FILES;
}
/**
* {@inheritDoc}
*/
@Override
protected ProposeScheduleResponse proposeScheduleSbnSubscription(
List<Subscription> subscriptions) throws Exception {
return proposeScheduleSubscriptions(subscriptions);
}
/**
* {@inheritDoc}
*/
@Override
protected Set<String> scheduleSbnSubscriptions(
List<Subscription> subscriptions) throws SerializationException {
return scheduleSubscriptions(subscriptions);
}
}
/**
* {@inheritDoc}
*/
@Override
public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
return new NcfBandwidthManager(dbInit, bandwidthDao, retrievalManager,
bandwidthDaoUtil);
}
}

View file

@ -0,0 +1,134 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.bandwidth.sbn;
import java.io.File;
import java.io.IOException;
import java.util.List;
import com.google.common.annotations.VisibleForTesting;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.common.util.file.FilenameFilters;
import com.raytheon.uf.edex.core.EDEXUtil;
/**
* The SBN simulator. Reads files from a configured directory, and then places
* them into the ingest queue.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 14, 2013 1648 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class SbnSimulator {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(SbnSimulator.class);
/**
* Interface to process files found in the scanned directory.
*/
interface IFileProcessor {
/**
* Process the file.
*
* @throws IOException
*/
void processFile(File file) throws IOException;
}
private static class CopyFileToManualIngest implements IFileProcessor {
/**
* {@inheritDoc}
*/
@Override
public void processFile(File file) throws IOException {
FileUtil.copyFile(
file,
new File(FileUtil
.join(EDEXUtil.EDEX_HOME, "data", "manual"), file
.getName()));
statusHandler.info("Processed [" + file + "]");
}
}
private final File directoryToScan;
private final IFileProcessor fileProcessor;
/**
* Private constructor.
*/
public SbnSimulator() {
this(new File(System.getProperty("sbn.retrieval.transfer.directory")),
new CopyFileToManualIngest());
}
/**
* Set up an {@link SbnSimulator} with the specified file processor.
*
* @param fileProcessor
*/
@VisibleForTesting
SbnSimulator(File scanDirectory, IFileProcessor fileProcessor) {
this.fileProcessor = fileProcessor;
this.directoryToScan = scanDirectory;
}
/**
* Check for sbn data.
*
* @throws IOException
*/
public void checkForSbnData() throws IOException {
final List<File> files = FileUtil.listFiles(directoryToScan,
FilenameFilters.ACCEPT_FILES, false);
statusHandler
.info("Found [" + files.size() + "] files from the SBN...");
for (File file : files) {
try {
fileProcessor.processFile(file);
} catch (IOException e) {
statusHandler.error("Error processing file [" + file + "]", e);
} finally {
if (!file.delete()) {
statusHandler.warn("Unable to delete [" + file + "]");
}
}
}
}
}

View file

@ -121,4 +121,114 @@
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.datadelivery.bandwidth.ncf"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.plugin.datadelivery.retrieval"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.spatial"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.ogc.common"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.plugin.grib.ogc"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.plugin.obs.ogc"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.wcs"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.wfs"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.wms"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="net.opengis"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="ogc.tools.gml"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="com.raytheon.uf.edex.plugin.madis.ogc"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.dataplugin.madis"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.plugin.madis"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.datadelivery.registry"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.datadelivery.retrieval.wfs"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.datadelivery.registry</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>

View file

@ -0,0 +1,8 @@
#Thu Apr 11 12:14:11 CDT 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,19 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Registry
Bundle-SymbolicName: com.raytheon.uf.edex.datadelivery.registry
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: com.raytheon.uf.common.registry.schemas.ebxml;bundle-version="1.0.0",
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.uf.common.util;bundle-version="1.12.1174",
com.raytheon.uf.edex.registry.ebxml;bundle-version="1.0.0",
com.raytheon.uf.edex.database;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
org.springframework;bundle-version="2.5.6",
com.raytheon.uf.common.time;bundle-version="1.12.1174",
com.raytheon.uf.edex.core;bundle-version="1.12.1174"

View file

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
res/

View file

@ -0,0 +1,15 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean name="federationManager"
class="com.raytheon.uf.edex.datadelivery.registry.federation.NcfRegistryFederationManager">
<constructor-arg ref="ebxmlFederationEnabled"/>
<constructor-arg ref="lcmServiceImpl" />
<constructor-arg value="ebxml/federation/ncfFederationConfig.xml" />
<property name="replicationManager" ref="RegistryReplicationManager"/>
<property name="registryObjectDao" ref="registryObjectDao"/>
<property name="registryDao" ref="registryDao"/>
</bean>
</beans>

View file

@ -0,0 +1,17 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean name="federationManager"
class="com.raytheon.uf.edex.datadelivery.registry.federation.WfoRegistryFederationManager">
<constructor-arg ref="ebxmlFederationEnabled"/>
<constructor-arg ref="lcmServiceImpl" />
<constructor-arg value="ebxml/federation/federationConfig.xml"/>
<constructor-arg value="${NCF_ADDRESS}" />
<property name="replicationManager" ref="RegistryReplicationManager"/>
<property name="registryObjectDao" ref="registryObjectDao"/>
<property name="registryDao" ref="registryDao"/>
<property name="txTemplate" ref="metadataTxTemplate"/>
</bean>
</beans>

View file

@ -0,0 +1,19 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod"
value="com.raytheon.uf.edex.datadelivery.registry.replication.RegistryReplicationManager.addObjectTypesToSubscribeTo" />
<property name="arguments">
<list>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Federation</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Registry</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Association</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Person</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Organization</value>
</list>
</property>
</bean>
</beans>

View file

@ -0,0 +1,9 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean name="replicationConfigFileName" class="java.lang.String">
<constructor-arg value="ebxml/notification/notificationServers_NCF.xml" />
</bean>
</beans>

View file

@ -0,0 +1,9 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean name="replicationConfigFileName" class="java.lang.String">
<constructor-arg value="ebxml/notification/notificationServers_WFO.xml" />
</bean>
</beans>

View file

@ -0,0 +1,33 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="RegistryReplicationManager" class="com.raytheon.uf.edex.datadelivery.registry.replication.RegistryReplicationManager">
<constructor-arg ref="ebxmlSubscriptionsEnabled"/>
<constructor-arg ref="replicationConfigFileName"/>
</bean>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod"
value="com.raytheon.uf.edex.datadelivery.registry.replication.RegistryReplicationManager.addObjectTypesToSubscribeTo" />
<property name="arguments">
<list>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.DataSet</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.DataSetMetaData</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.DataSetName</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.GroupDefinition</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.InitialPendingSharedSubscription</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.InitialPendingSiteSubscription</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.Parameter</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.ParameterLevel</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.PendingSharedSubscription</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.PendingSiteSubscription</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.Provider</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.SharedSubscription</value>
<value>urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:com.raytheon.uf.common.datadelivery.registry.SiteSubscription</value>
</list>
</property>
</bean>
</beans>

View file

@ -0,0 +1 @@
# Required to keep the empty directory present

View file

@ -0,0 +1,440 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.registry.federation;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.datatype.Duration;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.OrganizationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.PersonNameType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.PersonType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.PostalAddressType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.TelephoneNumberType;
import com.raytheon.uf.common.registry.constants.RegistryObjectTypes;
import com.raytheon.uf.common.registry.constants.StatusTypes;
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
/**
*
* Container class to hold the properties of the registry that will be joining
* the federation
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 5/22/2013 1707 bphillip Initial implementation
* </pre>
*
* @author bphillip
* @version 1
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class FederationProperties {
/**
* A RegistryType instance MAY have an attribute named conformanceProfile
* that declares the conformance profile that the server supports. The
* conformance profiles choices are RegistryLite and RegistryFull as
* defined by [regrep-rs-v4.0]
*/
@XmlElement(required = true)
private String conformanceProfile;
/**
* A RegistryType instance MUST have an attribute named specificationVersion
* that is the version of the ebXML RegReg Specifications it implements.
*/
@XmlElement(required = true)
private String specificationVersion;
/**
* A RegistryType instance MAY have an attribute named catalogingLatency
* that specifies the maximum latency between the time a submission is made
* to the server and the time it gets cataloged by any cataloging services
* defined for the objects within the submission. The default value of PT0S
* indicates a duration of 0 seconds which implies that cataloging happens
* immediately when request is submitted.
*/
@XmlElement(required = true)
private Duration catalogingLatency;
/**
* A RegistryType instance MAY have an attribute named
* replicationSyncLatency that specifies the maximum latency between the
* time when an original object changes and the time when its replica object
* within the local server gets updated to synchronize with the new state of
* the original object. The default value of P1D indicates a duration of
* once a day.
*/
@XmlElement(required = true)
private Duration replicationSyncLatency;
/**
* A FederationType instance MAY specify a replicationSyncLatency attribute
* that describes the time duration that is the amount of time within which
* a member of this Federation MUST synchronize itself with the current
* state of the Federation. Members of the Federation MAY use this parameter
* to periodically synchronize the federation metadata they MUST cache
* locally about the state of the Federation and its members. Such
* synchronization MAY be based upon the registry event notification
* capability.
*/
@XmlElement(required = true)
private Duration federationReplicationSyncLatency;
/** The site identifier of this site */
@XmlElement(required = true)
private String siteIdentifier;
/** Description of this site */
@XmlElement
private String siteDescription = "";
/** The site primary contact's first name */
@XmlElement(required = true)
private String sitePrimaryContactFirstName;
/** The site primary contact's middle name */
@XmlElement
private String sitePrimaryContactMiddleName = "";
/** The site primary contact's last name */
@XmlElement(required = true)
private String sitePrimaryContactLastName;
/** The site primary contact's phone area code */
@XmlElement
private String sitePrimaryContactPhoneAreaCode = "";
/** The site primary contact's phone number */
@XmlElement
private String sitePrimaryContactPhoneNumber = "";
/** The site's street address number */
@XmlElement
private String siteAddressStreetNumber = "";
/** The site's address street name */
@XmlElement
private String siteAddressStreet = "";
/** The site's address city */
@XmlElement
private String siteAddressCity = "";
/** The site's address state or province */
@XmlElement
private String siteAddressState = "";
/** The site's address country */
@XmlElement
private String siteAddressCountry = "";
/** The site's address postal code */
@XmlElement
private String siteAddressPostalCode = "";
/** The site phone's area code */
@XmlElement
private String sitePhoneAreaCode = "";
/** The site's phone number */
@XmlElement
private String sitePhoneNumber = "";
/**
* Creates a new FederationProperties object
*/
public FederationProperties() {
}
/**
* Creates a RegistryType object based on the properties
*
* @return A RegistryType object based on the properties
*/
public RegistryType createRegistryObject() {
RegistryType registryObj = new RegistryType();
registryObj.setId(siteIdentifier + " Registry");
registryObj.setLid(registryObj.getId());
registryObj.setName(RegistryUtil.getInternationalString(siteIdentifier
+ " Registry Specification"));
registryObj.setObjectType(RegistryObjectTypes.REGISTRY);
registryObj.setDescription(registryObj.getName());
registryObj.setOwner(siteIdentifier);
registryObj.setStatus(StatusTypes.APPROVED);
registryObj.setCatalogingLatency(catalogingLatency);
registryObj.setConformanceProfile(conformanceProfile);
registryObj.setOperator(RegistryUtil.DEFAULT_OWNER);
registryObj.setReplicationSyncLatency(replicationSyncLatency);
registryObj.setSpecificationVersion(specificationVersion);
registryObj.setBaseURL(RegistryUtil.LOCAL_REGISTRY_ADDRESS);
return registryObj;
}
/**
* Creates a PersonType object representing the primary contact for this
* registry based on the fields in this class
*
* @return The PersonType object
*/
public PersonType createPrimaryContactPerson() {
TelephoneNumberType phone = new TelephoneNumberType();
phone.setAreaCode(sitePrimaryContactPhoneAreaCode);
phone.setNumber(sitePrimaryContactPhoneNumber);
PersonType person = new PersonType();
person.setId(siteIdentifier + " Primary Contact");
person.setLid(person.getId());
person.setName(RegistryUtil.getInternationalString(person.getId()));
person.setDescription(person.getName());
person.setStatus(StatusTypes.APPROVED);
person.setObjectType(RegistryObjectTypes.PERSON);
person.setOwner(siteIdentifier);
PersonNameType personName = new PersonNameType();
personName.setFirstName(sitePrimaryContactFirstName);
personName.setMiddleName(sitePrimaryContactMiddleName);
personName.setLastName(sitePrimaryContactLastName);
person.setPersonName(personName);
person.getPostalAddress().add(getSiteAddress());
person.getTelephoneNumber().add(phone);
return person;
}
/**
* Creates an OrganizationType object representing this registry based on
* the fields in this class
*
* @return The OrganizationType object
*/
public OrganizationType createOrganization() {
OrganizationType org = new OrganizationType();
org.setPrimaryContact(siteIdentifier + " Primary Contact");
org.setId(siteIdentifier);
org.setLid(org.getId());
org.setName(RegistryUtil
.getInternationalString("National Weather Service Office: "
+ siteIdentifier));
org.setDescription(org.getName());
org.setStatus(StatusTypes.APPROVED);
org.setObjectType(RegistryObjectTypes.ORGANIZATION);
org.setOwner(siteIdentifier);
TelephoneNumberType phone = new TelephoneNumberType();
phone.setAreaCode(sitePhoneAreaCode);
phone.setNumber(sitePhoneNumber);
org.getTelephoneNumber().add(phone);
org.getPostalAddress().add(getSiteAddress());
return org;
}
/**
* Gets the site address of the organization hosting this registry based on
* the fields in this object
*
* @return The Postal address
*/
private PostalAddressType getSiteAddress() {
PostalAddressType siteAddress = new PostalAddressType();
siteAddress.setStreetNumber(siteAddressStreetNumber);
siteAddress.setStreet(siteAddressStreet);
siteAddress.setCity(siteAddressCity);
siteAddress.setStateOrProvince(siteAddressState);
siteAddress.setCountry(siteAddressCountry);
siteAddress.setPostalCode(siteAddressPostalCode);
return siteAddress;
}
public String getConformanceProfile() {
return conformanceProfile;
}
public void setConformanceProfile(String conformanceProfile) {
this.conformanceProfile = conformanceProfile;
}
public String getSpecificationVersion() {
return specificationVersion;
}
public void setSpecificationVersion(String specificationVersion) {
this.specificationVersion = specificationVersion;
}
public Duration getCatalogingLatency() {
return catalogingLatency;
}
public void setCatalogingLatency(Duration catalogingLatency) {
this.catalogingLatency = catalogingLatency;
}
public Duration getReplicationSyncLatency() {
return replicationSyncLatency;
}
public void setReplicationSyncLatency(Duration replicationSyncLatency) {
this.replicationSyncLatency = replicationSyncLatency;
}
public Duration getFederationReplicationSyncLatency() {
return federationReplicationSyncLatency;
}
public void setFederationReplicationSyncLatency(
Duration federationReplicationSyncLatency) {
this.federationReplicationSyncLatency = federationReplicationSyncLatency;
}
public String getSiteIdentifier() {
return siteIdentifier;
}
public void setSiteIdentifier(String siteIdentifier) {
this.siteIdentifier = siteIdentifier;
}
public String getSiteDescription() {
return siteDescription;
}
public void setSiteDescription(String siteDescription) {
this.siteDescription = siteDescription;
}
public String getSitePrimaryContactFirstName() {
return sitePrimaryContactFirstName;
}
public void setSitePrimaryContactFirstName(
String sitePrimaryContactFirstName) {
this.sitePrimaryContactFirstName = sitePrimaryContactFirstName;
}
public String getSitePrimaryContactMiddleName() {
return sitePrimaryContactMiddleName;
}
public void setSitePrimaryContactMiddleName(
String sitePrimaryContactMiddleName) {
this.sitePrimaryContactMiddleName = sitePrimaryContactMiddleName;
}
public String getSitePrimaryContactLastName() {
return sitePrimaryContactLastName;
}
public void setSitePrimaryContactLastName(String sitePrimaryContactLastName) {
this.sitePrimaryContactLastName = sitePrimaryContactLastName;
}
public String getSitePrimaryContactPhoneAreaCode() {
return sitePrimaryContactPhoneAreaCode;
}
public void setSitePrimaryContactPhoneAreaCode(
String sitePrimaryContactPhoneAreaCode) {
this.sitePrimaryContactPhoneAreaCode = sitePrimaryContactPhoneAreaCode;
}
public String getSitePrimaryContactPhoneNumber() {
return sitePrimaryContactPhoneNumber;
}
public void setSitePrimaryContactPhoneNumber(
String sitePrimaryContactPhoneNumber) {
this.sitePrimaryContactPhoneNumber = sitePrimaryContactPhoneNumber;
}
public String getSiteAddressStreetNumber() {
return siteAddressStreetNumber;
}
public void setSiteAddressStreetNumber(String siteAddressStreetNumber) {
this.siteAddressStreetNumber = siteAddressStreetNumber;
}
public String getSiteAddressStreet() {
return siteAddressStreet;
}
public void setSiteAddressStreet(String siteAddressStreet) {
this.siteAddressStreet = siteAddressStreet;
}
public String getSiteAddressCity() {
return siteAddressCity;
}
public void setSiteAddressCity(String siteAddressCity) {
this.siteAddressCity = siteAddressCity;
}
public String getSiteAddressState() {
return siteAddressState;
}
public void setSiteAddressState(String siteAddressState) {
this.siteAddressState = siteAddressState;
}
public String getSiteAddressCountry() {
return siteAddressCountry;
}
public void setSiteAddressCountry(String siteAddressCountry) {
this.siteAddressCountry = siteAddressCountry;
}
public String getSiteAddressPostalCode() {
return siteAddressPostalCode;
}
public void setSiteAddressPostalCode(String siteAddressPostalCode) {
this.siteAddressPostalCode = siteAddressPostalCode;
}
public String getSitePhoneAreaCode() {
return sitePhoneAreaCode;
}
public void setSitePhoneAreaCode(String sitePhoneAreaCode) {
this.sitePhoneAreaCode = sitePhoneAreaCode;
}
public String getSitePhoneNumber() {
return sitePhoneNumber;
}
public void setSitePhoneNumber(String sitePhoneNumber) {
this.sitePhoneNumber = sitePhoneNumber;
}
}

View file

@ -0,0 +1,128 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.registry.federation;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBException;
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AssociationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.FederationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.OrganizationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.PersonType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryType;
import com.raytheon.uf.common.registry.constants.RegistryObjectTypes;
import com.raytheon.uf.common.registry.constants.StatusTypes;
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
/**
*
* NCF specific implementation of the federation manager
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 5/22/2013 1707 bphillip Initial implementation
* </pre>
*
* @author bphillip
* @version 1
*/
public class NcfRegistryFederationManager extends RegistryFederationManager {
/**
* Creates a new NcfRegistryFederationManager
*/
protected NcfRegistryFederationManager() {
}
/**
* Creates a new NcfRegistryFederationManager
*
* @param federationEnabled
* Boolean denoting if this registry is participating in the
* federation
* @param lcm
* The lifecycle manager that will be used
* @param federationPropertiesFileName
* The name of the file containing the registry properties
* @throws JAXBException
* If errors occur while creating the JAXB manager
* @throws SerializationException
* If errors occur while deserializing the federation properties
*/
protected NcfRegistryFederationManager(boolean federationEnabled,
LifecycleManager lcm, String federationPropertiesFileName)
throws JAXBException, IOException, SerializationException {
super(federationEnabled, lcm, federationPropertiesFileName);
}
@Override
public void executeAfterRegistryInit() throws EbxmlRegistryException {
if (federationEnabled) {
List<RegistryObjectType> objects = new ArrayList<RegistryObjectType>(
5);
FederationType federation = getFederation();
RegistryType registry = federationProperties.createRegistryObject();
OrganizationType org = federationProperties.createOrganization();
PersonType primaryContact = federationProperties
.createPrimaryContactPerson();
AssociationType federationAssociation = getFederationAssociation(
registry, getFederation());
objects.add(federation);
objects.add(registry);
objects.add(org);
objects.add(primaryContact);
objects.add(federationAssociation);
submitObjects(objects);
replicationManager.submitRemoteSubscriptions(registry.getBaseURL());
} else {
statusHandler.info("Federation is disabled for this registry.");
}
}
protected FederationType getFederation() throws EbxmlRegistryException {
FederationType federation = new FederationType();
federation.setId(FEDERATION_ID);
federation.setLid(FEDERATION_ID);
federation.setName(RegistryUtil
.getInternationalString("NWS EBXML Registry Federation"));
federation
.setDescription(RegistryUtil
.getInternationalString("Federation object for NWS EBXML Registries"));
federation.setOwner(RegistryUtil.DEFAULT_OWNER);
federation.setStatus(StatusTypes.APPROVED);
federation.setObjectType(RegistryObjectTypes.FEDERATION);
federation.setReplicationSyncLatency(this.federationProperties
.getFederationReplicationSyncLatency());
return federation;
}
}

View file

@ -0,0 +1,216 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.registry.federation;
import java.io.File;
import java.util.List;
import javax.xml.bind.JAXBException;
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.Mode;
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AssociationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.FederationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.registry.constants.AssociationTypes;
import com.raytheon.uf.common.registry.constants.RegistryObjectTypes;
import com.raytheon.uf.common.registry.constants.StatusTypes;
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.datadelivery.registry.replication.RegistryReplicationManager;
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryDao;
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
import com.raytheon.uf.edex.registry.ebxml.init.RegistryInitializedListener;
/**
*
* Abstract implementation of the federation manager. This class is responsible
* for managing this registry's interactions with the registry federation.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 5/22/2013 1707 bphillip Initial implementation
* </pre>
*
* @author bphillip
* @version 1
*/
@Service
@Transactional
public abstract class RegistryFederationManager implements
RegistryInitializedListener {
/** The logger instance */
protected static final IUFStatusHandler statusHandler = UFStatus
.getHandler(RegistryFederationManager.class);
/** The federation identifier */
public static final String FEDERATION_ID = "Registry Federation";
/** The registry replication manager */
protected RegistryReplicationManager replicationManager;
/** Denotes if this registry is participating in the federation */
protected boolean federationEnabled;
/** The lifecycle manager */
protected LifecycleManager lcm;
/** The JAXB Manager for serializing registry objects */
protected JAXBManager jaxbManager;
/** The properties describing this registry in the federation */
protected FederationProperties federationProperties;
/** Data access object for registry objects */
protected RegistryObjectDao registryObjectDao;
/** Data Access object for RegistryType objects */
protected RegistryDao registryDao;
/**
* Gets the federation object for this federation
*
* @return The federation object
* @throws EbxmlRegistryException
* If errors occur getting the federatino
*/
protected abstract FederationType getFederation()
throws EbxmlRegistryException;
/**
* Creates a new RegistryFederationManager
*/
protected RegistryFederationManager() {
}
/**
* Creates a new RegistryFederationManager
*
* @param federationEnabled
* Boolean denoting if the federation is enabled
* @param lcm
* The lifecycle manager to be used
* @param federationPropertiesFileName
* The name of the file containing the properties for this
* registry
* @throws JAXBException
* If errors occur when creating the jaxb manager
* @throws SerializationException
* If errors occur when unmarshalling the federation properties
*/
protected RegistryFederationManager(boolean federationEnabled,
LifecycleManager lcm, String federationPropertiesFileName)
throws JAXBException, SerializationException {
this.federationEnabled = federationEnabled;
this.lcm = lcm;
jaxbManager = new JAXBManager(SubmitObjectsRequest.class,
FederationProperties.class);
File federationPropertiesFile = PathManagerFactory.getPathManager()
.getStaticFile(federationPropertiesFileName);
if (federationEnabled) {
if (federationPropertiesFile == null) {
statusHandler
.warn("Unable to locate federation configuration file: "
+ federationPropertiesFileName
+ ". Federation functionality is disabled");
this.federationEnabled = false;
} else {
federationProperties = (FederationProperties) jaxbManager
.jaxbUnmarshalFromXmlFile(federationPropertiesFile);
}
}
}
/**
* Creates the association object between this registry and the federation
*
* @param registry
* The registry joining the federation
* @param federation
* The federation the registry is joining
* @return The association object
*/
protected AssociationType getFederationAssociation(RegistryType registry,
FederationType federation) {
AssociationType association = new AssociationType();
association.setId(registry.getId()
+ " Federation Membership Association");
association.setLid(association.getId());
association.setObjectType(RegistryObjectTypes.ASSOCIATION);
association.setType(AssociationTypes.HAS_FEDERATION_MEMBER);
association.setStatus(StatusTypes.APPROVED);
association.setName(RegistryUtil.getInternationalString(registry
.getId() + " Federation Membership"));
association.setDescription(association.getName());
association.setTargetObject(registry.getId());
association.setSourceObject(federation.getId());
return association;
}
protected void submitObjects(List<RegistryObjectType> objects)
throws EbxmlRegistryException {
SubmitObjectsRequest submitObjectsRequest2 = new SubmitObjectsRequest(
"Federation Objects submission",
"Submitting federation related objects", null,
new RegistryObjectListType(objects), false,
Mode.CREATE_OR_REPLACE);
try {
lcm.submitObjects(submitObjectsRequest2);
} catch (MsgRegistryException e) {
throw new EbxmlRegistryException(
"Error submitting federation objects to registry", e);
}
}
public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) {
this.registryObjectDao = registryObjectDao;
}
public void setReplicationManager(
RegistryReplicationManager replicationManager) {
this.replicationManager = replicationManager;
}
public void setRegistryDao(RegistryDao registryDao) {
this.registryDao = registryDao;
}
}

View file

@ -0,0 +1,283 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.registry.federation;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.xml.bind.JAXBException;
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryRequest;
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
import oasis.names.tc.ebxml.regrep.xsd.query.v4.ResponseOptionType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.AssociationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.FederationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.OrganizationType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.PersonType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringValueType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
import com.raytheon.uf.common.registry.constants.CanonicalQueryTypes;
import com.raytheon.uf.common.registry.constants.Format;
import com.raytheon.uf.common.registry.constants.Languages;
import com.raytheon.uf.common.registry.constants.QueryReturnTypes;
import com.raytheon.uf.common.registry.services.RegistryRESTServices;
import com.raytheon.uf.common.registry.services.RegistrySOAPServices;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
/**
*
* WFO specific implementation of the federation manager.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 5/22/2013 1707 bphillip Initial implementation
* </pre>
*
* @author bphillip
* @version 1
*/
@Service
@Transactional
public class WfoRegistryFederationManager extends RegistryFederationManager {
/** The address of the NCF */
private String ncfAddress;
/**
* The scheduler service used for registering this registry with the
* federation
*/
private ScheduledExecutorService scheduler;
/** The transaction template used to manually handle transactions */
private TransactionTemplate txTemplate;
/**
* Creates a new WfoRegistryFederationManager
*/
protected WfoRegistryFederationManager() {
}
/**
* Creates a new WfoRegistryFederationManager
*
* @param federationEnabled
* Boolean denoting if this registry is participating in the
* federation
* @param lcm
* The lifecycle manager that will be used
* @param federationPropertiesFileName
* The name of the file containing the registry properties
* @param ncfAddress
* The address of the NCF
* @throws JAXBException
* If errors occur while creating the JAXB manager
* @throws SerializationException
* If errors occur while deserializing the federation properties
*/
protected WfoRegistryFederationManager(boolean federationEnabled,
LifecycleManager lcm, String federationPropertiesFileName,
String ncfAddress) throws JAXBException, IOException,
SerializationException {
super(federationEnabled, lcm, federationPropertiesFileName);
this.ncfAddress = ncfAddress;
scheduler = Executors.newSingleThreadScheduledExecutor();
}
@Override
public void executeAfterRegistryInit() throws EbxmlRegistryException {
if (federationEnabled) {
final RegisterWithFederationTask federationRegistrationTask = new RegisterWithFederationTask();
final ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(
federationRegistrationTask, 0, 10, TimeUnit.SECONDS);
scheduler.schedule(new Runnable() {
@Override
public void run() {
if (federationRegistrationTask.success) {
statusHandler
.info("Federation registration successful. Cancelling future registration attempts.");
future.cancel(false);
}
}
}, 5, TimeUnit.SECONDS);
} else {
statusHandler.info("Federation is disabled for this registry.");
}
}
/**
* Registers this registry with federation
*
* @throws EbxmlRegistryException
* If errors occur while registering this registry with the
* federation
*/
private void registerWithFederation() throws EbxmlRegistryException {
List<RegistryObjectType> objects = new ArrayList<RegistryObjectType>(5);
RegistryType registry = federationProperties.createRegistryObject();
OrganizationType org = federationProperties.createOrganization();
PersonType primaryContact = federationProperties
.createPrimaryContactPerson();
FederationType federation = getFederation();
AssociationType federationAssociation = null;
if (federation == null) {
statusHandler
.error("Unable to locate Federation Object! Registry is unable to join the federation at this time.");
} else {
federationAssociation = getFederationAssociation(registry,
federation);
}
objects.add(registry);
objects.add(org);
objects.add(primaryContact);
objects.add(federationAssociation);
submitObjects(objects);
replicationManager.setSubscriptionProcessingEnabled(true);
replicationManager.submitRemoteSubscriptions(registry.getBaseURL());
}
protected FederationType getFederation() throws EbxmlRegistryException {
statusHandler
.info("Attempting to acquire federation object from NCF...");
QueryType query = new QueryType(CanonicalQueryTypes.GET_OBJECT_BY_ID,
new SlotType("id", new StringValueType(FEDERATION_ID)));
QueryRequest queryRequest = new QueryRequest("Query for federation",
"Query to get the status of the federation",
new ResponseOptionType(QueryReturnTypes.REGISTRY_OBJECT, true),
query, false, null, Format.EBRIM, Languages.EN_US, 0, 0, 0,
false);
QueryResponse response = null;
try {
response = RegistrySOAPServices.getQueryServiceForHost(ncfAddress)
.executeQuery(queryRequest);
} catch (Exception e) {
throw new EbxmlRegistryException(
"Error getting Federation from NCF!", e);
}
if (response.getRegistryObjectList() == null
|| response.getRegistryObjectList().getRegistryObject()
.isEmpty()) {
throw new EbxmlRegistryException("Federation not found at NCF!");
} else {
List<RegistryObjectType> responseObjects = response
.getRegistryObjectList().getRegistryObject();
return (FederationType) responseObjects.get(0);
}
}
/**
*
* Runnable task that continuously attempts to register this registry with
* the federation until it succeeds
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 5/22/2013 1707 bphillip Initial implementation
* </pre>
*
* @author bphillip
* @version 1
*/
private class RegisterWithFederationTask implements Runnable {
/**
* Denotes if this task has successfully registered this registry with
* the federation
*/
private boolean success = false;
/**
* Creates a new RegisterwithFederationTask
*/
public RegisterWithFederationTask() {
}
@Override
public void run() {
if (!success) {
txTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(
TransactionStatus status) {
try {
try {
if (RegistryRESTServices
.isRegistryAvailable(ncfAddress)) {
statusHandler
.info("NCF Registry is available. Attempting to join federation...");
} else {
statusHandler
.error("NCF is currently unreachable. Local registry is unable to join the federation at this time. Retrying in 10 seconds...");
replicationManager
.setSubscriptionProcessingEnabled(false);
success = false;
return;
}
registerWithFederation();
success = true;
} catch (EbxmlRegistryException e) {
statusHandler.error(
"Error registering with federation", e);
success = false;
}
} catch (Throwable e) {
throw new RuntimeException(
"Error initializing EBXML database!", e);
}
}
});
}
}
}
public void setTxTemplate(TransactionTemplate txTemplate) {
this.txTemplate = txTemplate;
}
}

View file

@ -0,0 +1,93 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.registry.replication;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
/**
*
* Host configuration information
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/9/2013 1802 bphillip Initial implementation
* 6/4/2013 1707 bphillip Renamed and changed fields for clarity
* </pre>
*
* @author bphillip
* @version 1
*/
@XmlAccessorType(XmlAccessType.NONE)
public class NotificationHostConfiguration {
/** The site that this registry is running at */
@XmlElement
private String registrySiteName;
/** Descripion of the host */
@XmlElement
private String registryDescription;
/** The name of the host */
@XmlElement
private String registryBaseURL;
public NotificationHostConfiguration() {
}
public NotificationHostConfiguration(String registrySiteName,
String registryDescription, String registryBaseURL) {
this.registrySiteName = registrySiteName;
this.registryDescription = registryDescription;
this.registryBaseURL = registryBaseURL;
}
public String getRegistrySiteName() {
return registrySiteName;
}
public void setRegistrySiteName(String registrySiteName) {
this.registrySiteName = registrySiteName;
}
public String getRegistryDescription() {
return registryDescription;
}
public void setRegistryDescription(String registryDescription) {
this.registryDescription = registryDescription;
}
public String getRegistryBaseURL() {
return registryBaseURL;
}
public void setRegistryBaseURL(String registryBaseURL) {
this.registryBaseURL = registryBaseURL;
}
}

View file

@ -0,0 +1,65 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.registry.replication;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* Container class holding the upstream and downstream servers used for registry
* replication via subscription/notification
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/9/2013 1802 bphillip Initial implementation
* 5/21/2013 1707 bphillip Removed unused fields
* 6/4/2013 1707 bphillip Renamed and changed fields for clarity
* </pre>
*
* @author bphillip
* @version 1
*/
@XmlRootElement(name = "NotificationServers")
@XmlAccessorType(XmlAccessType.NONE)
public class NotificationServers {
/** The server located upstream from this server */
@XmlElements({ @XmlElement(name = "registry", type = NotificationHostConfiguration.class) })
private List<NotificationHostConfiguration> registryReplicationServers;
public List<NotificationHostConfiguration> getRegistryReplicationServers() {
return registryReplicationServers;
}
public void setRegistryReplicationServers(
List<NotificationHostConfiguration> registryReplicationServers) {
this.registryReplicationServers = registryReplicationServers;
}
}

View file

@ -0,0 +1,415 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.registry.replication;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.xml.bind.JAXBException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.Mode;
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.DeliveryInfoType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringValueType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SubscriptionType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.VersionInfoType;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.registry.RegistryException;
import com.raytheon.uf.common.registry.constants.CanonicalQueryTypes;
import com.raytheon.uf.common.registry.constants.DeliveryMethodTypes;
import com.raytheon.uf.common.registry.constants.Namespaces;
import com.raytheon.uf.common.registry.constants.NotificationOptionTypes;
import com.raytheon.uf.common.registry.constants.RegistryObjectTypes;
import com.raytheon.uf.common.registry.constants.StatusTypes;
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
import com.raytheon.uf.common.registry.services.RegistryRESTServices;
import com.raytheon.uf.common.registry.services.RegistrySOAPServices;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.util.CollectionUtil;
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
/**
*
* Manages subscriptions associated with Data Delivery Registry replication
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/24/2013 1675 bphillip Initial implementation
* 6/4/2013 1707 bphillip Changed to use new NotificationServer objects
* </pre>
*
* @author bphillip
* @version 1
*/
public class RegistryReplicationManager {
/** The logger instance */
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(RegistryReplicationManager.class);
/** Scheduler service for monitoring subscription submission tasks */
private ScheduledExecutorService scheduler;
/** The servers that we are subscribing to */
private NotificationServers servers;
/**
* The JAXBManager instance for marshalling/unmarshalling objects
*/
private JAXBManager jaxbManager;
/**
* The name of the configuration files defining which servers we are
* sending/receiving replicated objects to/from
*/
private String replicationConfigFileName;
/** Environment variable denoting whether subscription processing is enabled */
private boolean subscriptionProcessingEnabled;
/** Object types to automatically create subscriptions for */
private static List<String> objectTypes = new ArrayList<String>();
/**
* Creates a new RegistryReplicationManager
*
* @param subscriptionProcessingEnabled
* The state of subscription processing
* @param notificationServerConfigFileName
* The replication configuration files
* @throws JAXBException
* If errors occur while creating the JAXBManager
* @throws SerializationException
*/
public RegistryReplicationManager(boolean subscriptionProcessingEnabled,
String notificationServerConfigFileName) throws JAXBException,
SerializationException {
this.subscriptionProcessingEnabled = subscriptionProcessingEnabled;
this.replicationConfigFileName = notificationServerConfigFileName;
jaxbManager = new JAXBManager(NotificationServers.class,
SubscriptionType.class);
File notificationServerConfigFile = PathManagerFactory.getPathManager()
.getStaticFile(replicationConfigFileName);
if (notificationServerConfigFile == null) {
statusHandler
.error("Notification server config file not found! Registry replication will be disabled");
this.subscriptionProcessingEnabled = false;
return;
}
servers = (NotificationServers) jaxbManager
.jaxbUnmarshalFromXmlFile(notificationServerConfigFile);
scheduler = Executors.newSingleThreadScheduledExecutor();
}
/**
* Static method only used during the Spring container to inject the object
* types to subscribe to for registry replication
*
* @param types
* The object types to subscribe to
*/
public static void addObjectTypesToSubscribeTo(String... types) {
for (String type : types) {
objectTypes.add(type);
}
}
/**
* Submits subscriptions to the registry at the provided URL
*
* @param baseURL
* The url of the registry to send the subscriptions to
*/
public void submitRemoteSubscriptions(String baseURL) {
if (subscriptionProcessingEnabled) {
statusHandler.info("Registry Replication is enabled.");
} else {
statusHandler.warn("Registry Replication is disabled");
// TODO: Add code in here to remove replication
// subscriptions from remote servers if replication is disabled
return;
}
List<NotificationHostConfiguration> replicationRegistries = servers
.getRegistryReplicationServers();
if (CollectionUtil.isNullOrEmpty(replicationRegistries)) {
statusHandler.info("No registry replication servers configured.");
} else {
statusHandler
.info("Submitting subscriptions to registry replication servers...");
for (NotificationHostConfiguration config : replicationRegistries) {
scheduleSubscriptionSubmission(config, baseURL);
}
}
}
/**
* Schedules a task to submit subscriptions
*
* @param config
* The server configuration
* @param baseURL
* The url of the registry to submit the subscriptions to
*/
private void scheduleSubscriptionSubmission(
NotificationHostConfiguration config, String baseURL) {
final SubmitSubscriptionTask submitSubscriptionTask = new SubmitSubscriptionTask(
config, baseURL);
final ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(
submitSubscriptionTask, 0, 10, TimeUnit.SECONDS);
scheduler.schedule(new Runnable() {
@Override
public void run() {
if (submitSubscriptionTask.success) {
statusHandler
.info("Subscription submission successful. Cancelling future subscription submission retries");
future.cancel(false);
}
}
}, 5, TimeUnit.SECONDS);
}
/**
* Creates and submits objects to the server described in the config object
*
* @param config
* The object describing the destination server to make registry
* replication subscriptions to
*/
private void submitSubscriptionsToHost(
NotificationHostConfiguration config, String localRegistryBaseURL) {
statusHandler
.info("Generating registry replication subscriptions for registry at ["
+ config.getRegistrySiteName()
+ "] at URL ["
+ config.getRegistryBaseURL() + "]");
List<RegistryObjectType> subscriptions = new ArrayList<RegistryObjectType>();
for (String objectType : objectTypes) {
SubscriptionType subscription;
try {
subscription = createSubscription(config.getRegistryBaseURL(),
objectType, localRegistryBaseURL);
} catch (Exception e) {
throw new RegistryException("Error creating subscription", e);
}
subscriptions.add(subscription);
}
SubmitObjectsRequest request = new SubmitObjectsRequest(
"Subscription Submission", "Subscription Submission", null,
new RegistryObjectListType(subscriptions), false,
Mode.CREATE_OR_REPLACE);
RegistrySOAPServices.sendSubmitObjectsRequest(request,
config.getRegistryBaseURL());
}
/**
* Creates a new subscription object
*
* @param host
* The destination host
* @param objectType
* The object type to create the subscription for
* @return The subscription object
* @throws Exception
* If errors occur while creating the subscription object
*/
private SubscriptionType createSubscription(String host, String objectType,
String localRegistryBaseURL) throws Exception {
// Set normal registry object fields
String subscriptionDetail = "Replication Subscription for ["
+ objectType + "] objects for server [" + localRegistryBaseURL
+ "]";
SubscriptionType sub = new SubscriptionType();
sub.setId(subscriptionDetail);
sub.setLid(subscriptionDetail);
sub.setObjectType(RegistryObjectTypes.SUBSCRIPTION);
sub.setName(RegistryUtil.getInternationalString(subscriptionDetail));
sub.setDescription(RegistryUtil
.getInternationalString(subscriptionDetail));
VersionInfoType version = new VersionInfoType();
version.setVersionName("1");
version.setUserVersionName("1");
sub.setVersionInfo(version);
sub.setOwner("Subscription Owner");
sub.setStatus(StatusTypes.APPROVED);
sub.setStartTime(EbxmlObjectUtil.getTimeAsXMLGregorianCalendar(0));
QueryType selectorQuery = new QueryType();
selectorQuery.setQueryDefinition(CanonicalQueryTypes.BASIC_QUERY);
SlotType slot = new SlotType();
StringValueType valType = new StringValueType();
valType.setValue(objectType);
slot.setName("objectType");
slot.setSlotValue(valType);
selectorQuery.getSlot().add(slot);
sub.setSelector(selectorQuery);
Duration notificationInterval = DatatypeFactory.newInstance()
.newDuration(0);
sub.setNotificationInterval(notificationInterval);
String endpointType = DeliveryMethodTypes.SOAP;
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
builder.address(RegistrySOAPServices.getNotificationListenerServiceUrl(
localRegistryBaseURL).toString());
W3CEndpointReference ref = builder.build();
DOMResult dom = new DOMResult();
ref.writeTo(dom);
Document doc = (Document) dom.getNode();
NodeList nodes = doc.getElementsByTagNameNS(
Namespaces.ADDRESSING_NAMESPACE, "Address");
for (int i = 0; i < nodes.getLength(); i++) {
Node addressNode = nodes.item(i);
Attr endpointTypeAttr = doc.createAttributeNS(
Namespaces.EBXML_RIM_NAMESPACE_URI, "endpointType");
endpointTypeAttr.setValue(endpointType);
addressNode.getAttributes().setNamedItemNS(endpointTypeAttr);
}
ref = new W3CEndpointReference(new DOMSource(dom.getNode()));
// Set subscription specific fields
DeliveryInfoType deliveryInfo = new DeliveryInfoType();
deliveryInfo.setNotificationOption(NotificationOptionTypes.OBJECT_REFS);
deliveryInfo.setNotifyTo(ref);
sub.getDeliveryInfo().add(deliveryInfo);
return sub;
}
/**
*
* Task for submitting subscriptions to a remote registry
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 5/21/2013 1707 bphillip Initial implementation
* </pre>
*
* @author bphillip
* @version 1
*/
private class SubmitSubscriptionTask implements Runnable {
/**
* Denotes if the subscription has successfully been submitted to the
* remote server
*/
private boolean success = false;
/** The server configuration */
private NotificationHostConfiguration config;
/** The base URL of the remote registry */
private String baseURL;
/**
* Creates a new SubmitSubscriptionTask
*
* @param config
* The server configuration
* @param baseURL
* The base URL of the remote registry
*/
public SubmitSubscriptionTask(NotificationHostConfiguration config,
String baseURL) {
this.config = config;
this.baseURL = baseURL;
}
@Override
public void run() {
if (!success) {
String remoteRegistryBaseURL = config.getRegistryBaseURL();
statusHandler.info("Checking if remote registry at ["
+ remoteRegistryBaseURL + "] is available...");
if (RegistryRESTServices
.isRegistryAvailable(remoteRegistryBaseURL)) {
statusHandler.info("Registry at [" + remoteRegistryBaseURL
+ "] is available!");
} else {
statusHandler.error("Registry at [" + remoteRegistryBaseURL
+ "] is not available! Retrying in 10 seconds...");
success = false;
return;
}
try {
submitSubscriptionsToHost(config, baseURL);
success = true;
} catch (Exception e) {
statusHandler
.error("Error submitting subscriptions! Retrying in 10 seconds...",
e);
success = false;
}
}
}
}
public void setSubscriptionProcessingEnabled(
boolean subscriptionProcessingEnabled) {
this.subscriptionProcessingEnabled = subscriptionProcessingEnabled;
}
public NotificationServers getServers() {
return servers;
}
}

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<federationProperties>
<conformanceProfile>RegistryFull</conformanceProfile>
<specificationVersion>4.0</specificationVersion>
<catalogingLatency>PT0.000S</catalogingLatency>
<replicationSyncLatency>PT0.000S</replicationSyncLatency>
<siteIdentifier>NCF</siteIdentifier>
<siteDescription>AWIPS Network Control Facility</siteDescription>
<sitePrimaryContactFirstName>National</sitePrimaryContactFirstName>
<sitePrimaryContactMiddleName>Weather</sitePrimaryContactMiddleName>
<sitePrimaryContactLastName>Service</sitePrimaryContactLastName>
<siteAddressStreetNumber>1325</siteAddressStreetNumber>
<siteAddressStreet>East West Highway</siteAddressStreet>
<siteAddressCity>Silver Spring</siteAddressCity>
<siteAddressState>MD</siteAddressState>
<siteAddressCountry>USA</siteAddressCountry>
<siteAddressPostalCode>20910</siteAddressPostalCode>
</federationProperties>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.datadelivery.retrieval.wfs</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.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,25 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: DataDelivery Retrieval Phase3
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-SymbolicName: com.raytheon.uf.edex.datadelivery.retrieval.wfs
Bundle-Version: 1.0.0.qualifier
Require-Bundle: com.raytheon.uf.common.datadelivery.retrieval;bundle-version="1.0.0",
com.raytheon.uf.edex.datadelivery.retrieval;bundle-version="1.0.0",
com.raytheon.uf.common.time;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
net.opengis;bundle-version="1.0.2",
com.raytheon.uf.common.datadelivery.registry;bundle-version="1.0.0",
com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0",
org.geotools;bundle-version="2.6.4",
com.raytheon.uf.edex.plugin.madis.ogc;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin.madis;bundle-version="1.0.0",
com.raytheon.uf.common.util;bundle-version="1.12.1174",
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.uf.common.event;bundle-version="1.0.0",
com.raytheon.uf.edex.ogc.common;bundle-version="1.0.0",
com.raytheon.uf.edex.wfs;bundle-version="1.0.0"

View file

@ -0,0 +1,4 @@
source.. = src/
bin.includes = META-INF/,\
.,\
res/

View file

@ -0,0 +1,15 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean factory-bean="metadataAdapterRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.madis.MadisRecord" />
<constructor-arg value="com.raytheon.uf.edex.datadelivery.retrieval.metadata.adapters.madis.MadisMetadataAdapter" type="java.lang.Class" />
</bean>
<bean factory-bean="serviceFactoryRegistry" factory-method="register">
<constructor-arg value="WFS" />
<constructor-arg value="com.raytheon.uf.edex.datadelivery.retrieval.wfs.WfsServiceFactory" type="java.lang.Class" />
</bean>
</beans>

View file

@ -0,0 +1,52 @@
package com.raytheon.uf.edex.datadelivery.retrieval.metadata.adapters.madis;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.madis.MadisRecord;
import com.raytheon.uf.edex.datadelivery.retrieval.metadata.adapters.AbstractMetadataAdapter;
import com.raytheon.uf.edex.plugin.madis.ogc.feature.Madis;
/**
*
* Convert RetrievalAttribute to MadisRecords.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 12, 2013 753 dhladky Initial javadoc
* May 31, 2013 2038 djohnson Move to correct git repo.
*
* </pre>
*
* @author dhladky
* @version 1.0
*/
public class MadisMetadataAdapter extends AbstractMetadataAdapter<Madis> {
public MadisMetadataAdapter() {
}
@Override
public PluginDataObject getRecord(Madis madis) {
return madis.getRecord();
}
@Override
public void allocatePdoArray(int size) {
pdos = new MadisRecord[size];
}
/**
* {@inheritDoc}
*/
@Override
public void processAttributeXml(RetrievalAttribute attXML)
throws InstantiationException {
this.attXML = attXML;
}
}

View file

@ -0,0 +1,35 @@
package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
import javax.xml.bind.JAXBException;
import net.opengis.wfs.v_1_1_0.FeatureCollectionType;
import com.raytheon.uf.edex.ogc.common.jaxb.OgcJaxbManager;
/**
*
* Interface for creating WFS derived objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 22, 2013 753 dhladky Initial javadoc
*
* </pre>
*
* @author dhladky
* @version 1.0
*/
public interface IWfsMetaDataAdapter {
public void configureMarshaller() throws JAXBException;
public OgcJaxbManager getMarshaller();
public FeatureCollectionType getFeatureCollection(String payload) throws JAXBException;
}

View file

@ -0,0 +1,168 @@
package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.geotools.geometry.jts.ReferencedEnvelope;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.retrieval.util.HarvesterServiceManager;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.datadelivery.retrieval.xml.ServiceConfig;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.datadelivery.retrieval.request.RequestBuilder;
/**
*
* WFS Request Builder.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 12, 2013 753 dhladky created.
* May 31, 2013 2038 djohnson Move to correct repo.
*
* </pre>
*
* @author dhladky
* @version 1.0
*/
public class WfsRequestBuilder extends RequestBuilder {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(WfsRequestBuilder.class);
protected static ServiceConfig wfsServiceConfig;
public static final String separator = getServiceConfig().getConstantValue("COMMA");
private final String wfsURL;
WfsRequestBuilder(WfsRetrievalAdapter adapter,
RetrievalAttribute attXML) {
super(attXML);
// Create URL
// this works in this order
StringBuilder buffer = new StringBuilder();
// apply the base WFS service URL
buffer.append(adapter.getProviderRetrievalXMl().getConnection()
.getUrl());
buffer.append("?");
// apply the feature you are trying to retrieve
buffer.append(getRetrievalAttribute().getParameter().getProviderName());
// process the coverage bounding box
buffer.append(processCoverage());
// process the time range you are trying to retrieve
buffer.append(processTime(getRetrievalAttribute().getTime()));
this.wfsURL = buffer.toString().trim();
}
private static ThreadLocal<SimpleDateFormat> ogcDateFormat = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
SimpleDateFormat sdf = new SimpleDateFormat(getServiceConfig()
.getDateConfig().getFormats().get(0));
return sdf;
}
};
@Override
public String processTime(Time time) {
try {
if (time.getEndDate() != null && time.getStartDate() != null) {
Date sDate = time.getStartDate();
Date eDate = time.getEndDate();
String endDateString = ogcDateFormat.get().format(eDate);
String startDateString = ogcDateFormat.get().format(sDate);
StringBuilder sb = new StringBuilder();
sb.append("&TIME=");
sb.append(startDateString);
sb.append("/");
if (!endDateString.equals(startDateString)) {
sb.append(endDateString);
}
return sb.toString();
}
} catch (Exception e) {
statusHandler.error("Couldn't parse Time object." + e);
}
// no times, return blank
return getServiceConfig().getConstantValue("BLANK");
}
@Override
public String processCoverage() {
// &srsName=crs:84&bbox=-100.0,41.0,-98.0,43.0
StringBuilder sb = new StringBuilder();
Coverage coverage = getRetrievalAttribute().getCoverage();
if (coverage != null) {
ReferencedEnvelope re = coverage.getRequestEnvelope();
// manage the box
double lowerLon = re.getMinX();
double lowerLat = re.getMinY();
double upperLon = re.getMaxX();
double upperLat = re.getMaxY();
sb.append("&srsName=");
sb.append(coverage.getEnvelope().getCoordinateReferenceSystem()
.getName());
sb.append("&bbox=");
sb.append(lowerLon);
sb.append(separator);
sb.append(lowerLat);
sb.append(separator);
sb.append(upperLon);
sb.append(separator);
sb.append(upperLat);
return sb.toString();
}
return getServiceConfig().getConstantValue("BLANK");
}
@Override
public String getRequest() {
return wfsURL;
}
@Override
public RetrievalAttribute getAttribute() {
return getRetrievalAttribute();
}
/**
* Get the instance of the service config
* @return
*/
private static ServiceConfig getServiceConfig() {
if (wfsServiceConfig == null) {
wfsServiceConfig = HarvesterServiceManager.getInstance()
.getServiceConfig(ServiceType.WFS);
}
return wfsServiceConfig;
}
}

View file

@ -0,0 +1,139 @@
package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.CollectionUtil;
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalEvent;
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalRequestBuilder;
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse;
import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
import com.raytheon.uf.edex.datadelivery.retrieval.util.WfsConnectionUtil;
/**
* WFS OGC Provider Retrieval Adapter
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 07, 2011 dhladky Initial creation
* Jul 25, 2012 955 djohnson Moved to wfs specific package.
* May 12, 2013 753 dhladky implemented.
* May 31, 2013 2038 djohnson Move to correct repo.
*
* </pre>
*
* @author dhladky
* @version 1.0
*/
public class WfsRetrievalAdapter extends RetrievalAdapter {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(WfsRetrievalAdapter.class);
private static final Pattern splitter = Pattern.compile("?");
@Override
public IRetrievalRequestBuilder createRequestMessage(
RetrievalAttribute attXML) {
WfsRequestBuilder reqBuilder = new WfsRequestBuilder(this, attXML);
return reqBuilder;
}
@Override
public Map<String, PluginDataObject[]> processResponse(
IRetrievalResponse response) throws TranslationException {
Map<String, PluginDataObject[]> map = new HashMap<String, PluginDataObject[]>();
WfsTranslator translator;
try {
translator = getWfsTranslator(response.getAttribute());
} catch (InstantiationException e) {
throw new TranslationException(
"Unable to instantiate a required class!", e);
}
String payload = (String) response.getPayLoad();
try {
if (payload != null) {
PluginDataObject[] pdos = translator
.asPluginDataObjects(payload);
if (!CollectionUtil.isNullOrEmpty(pdos)) {
String pluginName = pdos[0].getPluginName();
map.put(pluginName,
CollectionUtil.combine(PluginDataObject.class,
map.get(pluginName), pdos));
}
}
} catch (ClassCastException e) {
throw new TranslationException(e);
}
return map;
}
@Override
public RetrievalResponse performRequest(IRetrievalRequestBuilder request) {
String xmlMessage = null;
try {
// break url into CGI parameters and address
String[] parts = splitter.split(request.getRequest());
xmlMessage = WfsConnectionUtil.wfsConnect(parts[0], parts[1]);
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
EventBus.publish(new RetrievalEvent(e.getMessage()));
}
RetrievalResponse pr = new WfsRetrievalResponse(request.getAttribute());
pr.setPayLoad(xmlMessage);
return pr;
}
/**
* @param attribute
* @return
*/
WfsTranslator getWfsTranslator(RetrievalAttribute attribute)
throws InstantiationException {
return new WfsTranslator(attribute);
}
}

View file

@ -0,0 +1,227 @@
package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.common.annotations.VisibleForTesting;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.Parameter;
import com.raytheon.uf.common.datadelivery.registry.PointDataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.PointTime;
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.common.datadelivery.registry.ProviderType;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBundle;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerator;
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
/**
*
* WFS Retrieval Generator.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 25, 2012 955 djohnson Moved to wfs specific package.
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* May 12, 2013 753 dhladky Implemented
* May 31, 2013 2038 djohnson Move to correct repo.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
class WfsRetrievalGenerator extends RetrievalGenerator {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(WfsRetrievalGenerator.class);
WfsRetrievalGenerator() {
super(ServiceType.WFS);
}
@Override
public List<Retrieval> buildRetrieval(SubscriptionBundle bundle) {
List<Retrieval> retrievals = Collections.emptyList();
switch (bundle.getDataType()) {
case POINT:
retrievals = getPointRetrievals(bundle);
break;
default:
statusHandler.error("Grid DATA WFS NOT YET IMPLEMENTED");
throw new IllegalArgumentException(
"Grid DATA WFS NOT YET IMPLEMENTED");
}
return retrievals;
}
/**
* create the grid type retrievals
*
* @param bundle
* @return
*/
private List<Retrieval> getPointRetrievals(SubscriptionBundle bundle) {
List<Retrieval> retrievals = new ArrayList<Retrieval>();
Subscription sub = bundle.getSubscription();
sub = removeDuplicates(sub);
if (sub != null) {
PointTime subTime = (PointTime) sub.getTime();
String retrievalUrl = getRetrievalUrl(sub);
sub.setUrl(retrievalUrl);
if (sub.getUrl() == null) {
statusHandler
.info("Skipping subscription that is unfulfillable with the current metadata.");
return Collections.emptyList();
}
// with point data they all have the same data
Parameter param = sub.getParameter().get(0);
Retrieval retrieval = getRetrieval(sub, bundle, param, subTime);
retrievals.add(retrieval);
}
return retrievals;
}
/**
* Determines the retrieval URL
*
* @param subscription
* the subscription
* @return the url for retrieval or null if no retrieval should take place
*/
private static String getRetrievalUrl(Subscription subscription) {
String url = subscription.getUrl();
DataSetMetaData result = null;
try {
result = DataDeliveryHandlers.getDataSetMetaDataHandler().getById(
url);
if (result == null) {
throw new RegistryHandlerException(
"Unable to find the dataset by id from its unique url!",
new NullPointerException("DataSetMetaData"));
}
if (satisfiesSubscriptionCriteria(subscription, result)) {
return url;
}
} catch (RegistryHandlerException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to find the dataset by id from its unique url!", e);
}
return null;
}
/**
* Determines whether a subscription can be satisified by the dataset
* metadata.
*
* @param subscription
* the subscription
* @param dsmd
* the dataset metadata
* @return true if the datasetmetadata will satisfy the subscription
*/
@VisibleForTesting
static boolean satisfiesSubscriptionCriteria(Subscription subscription,
DataSetMetaData dsmd) {
if (dsmd instanceof PointDataSetMetaData) {
// PointDataSetMetaData data = (PointDataSetMetaData) dsmd;
// TODO determine some check for validity of point data sets
return true;
}
return false;
}
/**
* Get the retrieval
*
* @param sub
* @param bundle
* @param param
* @param level
* @param Time
* @return
*/
private Retrieval getRetrieval(Subscription sub, SubscriptionBundle bundle,
Parameter param, PointTime time) {
Retrieval retrieval = new Retrieval();
retrieval.setSubscriptionName(sub.getName());
retrieval.setServiceType(getServiceType());
retrieval.setConnection(bundle.getConnection());
retrieval.getConnection().setUrl(sub.getUrl());
retrieval.setOwner(sub.getOwner());
retrieval.setSubscriptionType(getSubscriptionType(sub));
retrieval.setNetwork(sub.getRoute());
// Coverage and type processing
Coverage cov = sub.getCoverage();
if (cov instanceof Coverage) {
retrieval.setDataType(DataType.POINT);
} else {
throw new UnsupportedOperationException(
"WFS retrieval does not yet support coverages other than Point. ");
}
final ProviderType providerType = bundle.getProvider().getProviderType(
bundle.getDataType());
final String plugin = providerType.getPlugin();
// Attribute processing
RetrievalAttribute att = new RetrievalAttribute();
Parameter lparam = processParameter(param);
att.setCoverage(cov);
lparam.setLevels(param.getLevels());
att.setTime(time);
att.setParameter(lparam);
att.setSubName(retrieval.getSubscriptionName());
att.setPlugin(plugin);
att.setProvider(sub.getProvider());
retrieval.addAttribute(att);
return retrieval;
}
/**
* {@inheritDoc}
*/
@Override
protected RetrievalAdapter getServiceRetrievalAdapter() {
return new WfsRetrievalAdapter();
}
@Override
protected Subscription removeDuplicates(Subscription sub) {
throw new UnsupportedOperationException("Not implemented");
}
}

View file

@ -0,0 +1,52 @@
package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
/**
* {@link RetrievalResponse} for WFS.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 12, 2013 753 dhladky Initial creation
* May 31, 2013 2038 djohnson Move to correct repo.
*
* </pre>
*
* @author dhladky
* @version 1.0
*/
@DynamicSerialize
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class WfsRetrievalResponse extends RetrievalResponse {
@XmlElement
private String payload;
public WfsRetrievalResponse(RetrievalAttribute attribute) {
}
@Override
public void setPayLoad(Object payLoad) {
this.payload = (String) payLoad;
}
@Override
public String getPayLoad() {
return payload;
}
}

View file

@ -0,0 +1,91 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
import java.util.Date;
import com.raytheon.uf.common.datadelivery.registry.Provider;
import com.raytheon.uf.edex.datadelivery.retrieval.IExtractMetaData;
import com.raytheon.uf.edex.datadelivery.retrieval.IParseMetaData;
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerator;
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory;
/**
* {@link ServiceFactory} implementation for WFS.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 25, 2012 955 djohnson Initial creation
* May 12, 2013 753 dhladky implementation
* May 31, 2013 2038 djohnson Add setProvider.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class WfsServiceFactory implements ServiceFactory {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory#getExtractor()
*/
@Override
public IExtractMetaData getExtractor() {
throw new UnsupportedOperationException("Not implemented");
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory#getParser(
* java.util.Date)
*/
@Override
public IParseMetaData getParser(Date lastUpdate) {
throw new UnsupportedOperationException("Not implemented");
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory#
* getRetrievalGenerator()
*/
@Override
public RetrievalGenerator getRetrievalGenerator() {
return new WfsRetrievalGenerator();
}
/**
* {@inheritDoc}
*/
@Override
public void setProvider(Provider provider) {
throw new UnsupportedOperationException("Not implemented");
}
}

View file

@ -0,0 +1,152 @@
package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import net.opengis.gml.v_3_1_1.AbstractFeatureType;
import net.opengis.gml.v_3_1_1.FeaturePropertyType;
import net.opengis.wfs.v_1_1_0.FeatureCollectionType;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.madis.MadisRecord;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalTranslator;
import com.raytheon.uf.edex.ogc.common.jaxb.OgcJaxbManager;
import com.raytheon.uf.edex.plugin.madis.ogc.feature.Madis;
import com.raytheon.uf.edex.plugin.madis.ogc.feature.MadisObjectFactory;
import com.raytheon.uf.edex.wfs.reg.Unique;
/**
*
* Translate WFS retrievals into PDOs
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 12, 2013 753 dhladky Initial javadoc
* May 31, 2013 2038 djohnson Move to correct repo.
* May 31, 2013 1763 dhladky Fixed up merge.
*
* </pre>
*
* @author unknown
* @version 1.0
*/
public class WfsTranslator extends RetrievalTranslator {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(WfsTranslator.class);
WfsTranslator(RetrievalAttribute attXML, String className)
throws InstantiationException {
super(attXML, className);
}
public WfsTranslator(RetrievalAttribute attXML) throws InstantiationException {
super(attXML);
}
@Override
protected int getSubsetNumTimes() {
// TODO Auto-generated method stub
return 0;
}
@Override
protected int getSubsetNumLevels() {
// TODO Auto-generated method stub
return 0;
}
@Override
protected List<DataTime> getTimes() {
// TODO Auto-generated method stub
return null;
}
/**
* XML string into abstract features then to PDOs
* @param payload
* @return
*/
public PluginDataObject[] asPluginDataObjects(String payload) {
try {
FeatureCollectionType featureCollection = ((IWfsMetaDataAdapter)metadataAdapter).getFeatureCollection(payload);
if (featureCollection.getNumberOfFeatures().intValue() > 0) {
int i = 0;
metadataAdapter.allocatePdoArray(featureCollection.getNumberOfFeatures().intValue());
for (FeaturePropertyType type : featureCollection.getFeatureMember()) {
JAXBElement<? extends AbstractFeatureType> feature = type.getFeature();
metadataAdapter.getPdos()[i] = metadataAdapter.getRecord(feature);
i++;
}
}
} catch (JAXBException e) {
statusHandler.handle(Priority.PROBLEM, "Can't de-serialize FeatureCollection", e);
}
return metadataAdapter.getPdos();
}
public static void main(String[] args) {
String fileName = args[0];
OgcJaxbManager ctx = null;
Class<?>[] classes = new Class<?>[] {
net.opengis.gml.v_3_1_1.ObjectFactory.class,
net.opengis.wfs.v_1_1_0.ObjectFactory.class,
net.opengis.filter.v_1_1_0.ObjectFactory.class,
Unique.class,
Madis.class,
MadisObjectFactory.class};
try {
ctx = new OgcJaxbManager(classes);
} catch (JAXBException e1) {
e1.printStackTrace();
statusHandler.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1);
}
try {
try {
File file = new File(fileName);
FileReader reader = new FileReader(file);
List<MadisRecord> featureList = new ArrayList<MadisRecord>();
FeatureCollectionType features = (FeatureCollectionType) ctx.unmarshal(reader);
for (FeaturePropertyType type: features.getFeatureMember()) {
Madis feature = (Madis)type.getFeature().getValue();
MadisRecord record = feature.getRecord();
featureList.add(record);
}
System.out.println("FeatureList size: "+featureList.size());
} catch (JAXBException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.ogc.common</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>

Some files were not shown because too many files have changed in this diff Show more