Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
dcf31f94
Commit
dcf31f94
authored
Jun 01, 2015
by
duminil
Browse files
Removing hard coded usernames.
parent
405be881
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/eu/simstadt/nf4j/ExportJobFromJavaFXRegionChooser.java
View file @
dcf31f94
...
@@ -32,11 +32,12 @@ public class ExportJobFromJavaFXRegionChooser implements JobStatusListener
...
@@ -32,11 +32,12 @@ public class ExportJobFromJavaFXRegionChooser implements JobStatusListener
public
void
processJob
(
Geometry
poly
,
String
productName
,
JSObject
novaFactoryOpenLayer
)
throws
InterruptedException
{
public
void
processJob
(
Geometry
poly
,
String
productName
,
JSObject
novaFactoryOpenLayer
)
throws
InterruptedException
{
this
.
novaFactoryOpenLayer
=
novaFactoryOpenLayer
;
this
.
novaFactoryOpenLayer
=
novaFactoryOpenLayer
;
ExportJobDescription
description
=
ExportJobDescription
.
getDefaultDescriptor
();
ExportJobDescription
description
=
ExportJobDescription
.
getDefaultDescriptor
();
description
.
setInitiator
(
"2758"
);
description
.
setInitiator
(
String
.
valueOf
((
int
)
(
Math
.
random
()
*
9999
)));
description
.
setAccount
(
"Bruse"
);
String
userName
=
System
.
getProperty
(
"user.name"
);
description
.
setAccount
(
userName
);
// description.setProduct("WU3");
// description.setProduct("WU3");
description
.
setProduct
(
productName
);
description
.
setProduct
(
productName
);
description
.
setJobnumber
(
"Bruse_0815"
);
description
.
setJobnumber
(
userName
);
//FIXME: Zipped GMLs coming from nF don't have any defined srsName
//FIXME: Zipped GMLs coming from nF don't have any defined srsName
...
@@ -88,7 +89,7 @@ public void jobStatusChanged(JobStatusEvent event) {
...
@@ -88,7 +89,7 @@ public void jobStatusChanged(JobStatusEvent event) {
try
{
try
{
File
file
=
job
.
getResult
();
File
file
=
job
.
getResult
();
novaFactoryOpenLayer
.
call
(
"updateStatus"
,
"DOWNLOADED AS ZIP"
);
novaFactoryOpenLayer
.
call
(
"updateStatus"
,
"DOWNLOADED AS ZIP"
);
novaFactoryOpenLayer
.
call
(
"selectSaveFile"
,
file
.
toString
());
//
novaFactoryOpenLayer.call("selectSaveFile", file.toString());
// System.out.println("CityGML at " + file.getAbsolutePath());
// System.out.println("CityGML at " + file.getAbsolutePath());
//TODO: Call downloadFinished if FAILED
//TODO: Call downloadFinished if FAILED
novaFactoryOpenLayer
.
call
(
"downloadFinished"
);
novaFactoryOpenLayer
.
call
(
"downloadFinished"
);
...
...
src/eu/simstadt/nf4j/async/JobFileBuilderImpl.java
View file @
dcf31f94
...
@@ -12,7 +12,6 @@
...
@@ -12,7 +12,6 @@
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
java.util.zip.ZipOutputStream
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.DocumentBuilderFactory
;
import
javax.xml.parsers.DocumentBuilderFactory
;
import
javax.xml.parsers.ParserConfigurationException
;
import
javax.xml.parsers.ParserConfigurationException
;
...
@@ -22,30 +21,30 @@
...
@@ -22,30 +21,30 @@
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.dom.DOMSource
;
import
javax.xml.transform.dom.DOMSource
;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamResult
;
import
org.osgeo.proj4j.BasicCoordinateTransform
;
import
org.osgeo.proj4j.BasicCoordinateTransform
;
import
org.osgeo.proj4j.CRSFactory
;
import
org.osgeo.proj4j.CRSFactory
;
import
org.osgeo.proj4j.CoordinateReferenceSystem
;
import
org.osgeo.proj4j.CoordinateReferenceSystem
;
import
org.osgeo.proj4j.ProjCoordinate
;
import
org.osgeo.proj4j.ProjCoordinate
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
org.w3c.dom.Element
;
import
eu.simstadt.nf4j.InvalidJobDescriptorException
;
import
eu.simstadt.nf4j.InvalidJobDescriptorException
;
/**
/**
* Builds nF import and export jobs using nF's XML job format. Please read the nF manual if you want more
* Builds nF import and export jobs using nF's XML job format. Please read the nF manual if you want more
details about
*
details about
the numerous job attributes listed below.
* the numerous job attributes listed below.
*
*
* @author Marcel Bruse
* @author Marcel Bruse
*/
*/
public
class
JobFileBuilderImpl
implements
JobFileBuilder
<
ImportJobDescription
,
ExportJobDescription
>
{
public
class
JobFileBuilderImpl
implements
JobFileBuilder
<
ImportJobDescription
,
ExportJobDescription
>
{
/** Supported version of the novaFACTORY. */
/** Supported version of the novaFACTORY. */
public
static
final
String
NOVA_FACTORY_VERSION
=
"6.3.1.1"
;
public
static
final
String
NOVA_FACTORY_VERSION
=
"6.3.1.1"
;
/** The version of the XML export job format. */
/** The version of the XML export job format. */
public
static
final
String
EXPORT_JOB_VERSION
=
"1.0.0"
;
public
static
final
String
EXPORT_JOB_VERSION
=
"1.0.0"
;
/**
/**
* @return Returns the supported novaFACTORY version.
* @return Returns the supported novaFACTORY version.
*/
*/
...
@@ -69,14 +68,14 @@ public String supportsExportJobVersion() {
...
@@ -69,14 +68,14 @@ public String supportsExportJobVersion() {
public
String
supportsImportJobVersion
()
{
public
String
supportsImportJobVersion
()
{
return
null
;
return
null
;
}
}
/**
/**
* This is an intermediate prototype.
* This is an intermediate prototype.
*
*
* @param jobDescriptor A job descriptor which describes the export job with all its attributes according to
* @param jobDescriptor A job descriptor which describes the export job with all its attributes according to
a valid
*
a valid
nF export job DTD.
*
nF export job DTD.
* @return Returns a string representation of the nF export job.
* @return Returns a string representation of the nF export job.
* @throws FailedJobTransmissionException
* @throws FailedJobTransmissionException
*/
*/
@Override
@Override
public
File
buildExportJobFile
(
ExportJobDescription
jobDescriptor
)
throws
InvalidJobDescriptorException
{
public
File
buildExportJobFile
(
ExportJobDescription
jobDescriptor
)
throws
InvalidJobDescriptorException
{
...
@@ -85,31 +84,31 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
...
@@ -85,31 +84,31 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
try
{
try
{
DocumentBuilderFactory
factory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilderFactory
factory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
Document
doc
=
builder
.
newDocument
();
Document
doc
=
builder
.
newDocument
();
Element
root
=
doc
.
createElement
(
"EXPORT_JOB"
);
Element
root
=
doc
.
createElement
(
"EXPORT_JOB"
);
root
.
setAttribute
(
"version"
,
supportsExportJobVersion
());
root
.
setAttribute
(
"version"
,
supportsExportJobVersion
());
doc
.
appendChild
(
root
);
doc
.
appendChild
(
root
);
Element
job
=
doc
.
createElement
(
"job"
);
Element
job
=
doc
.
createElement
(
"job"
);
root
.
appendChild
(
job
);
root
.
appendChild
(
job
);
Element
initiator
=
doc
.
createElement
(
"initiator"
);
Element
initiator
=
doc
.
createElement
(
"initiator"
);
initiator
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getInitiator
()));
initiator
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getInitiator
()));
job
.
appendChild
(
initiator
);
job
.
appendChild
(
initiator
);
Element
jobnumber
=
doc
.
createElement
(
"jobnumber"
);
Element
jobnumber
=
doc
.
createElement
(
"jobnumber"
);
jobnumber
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getJobnumber
()));
jobnumber
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getJobnumber
()));
job
.
appendChild
(
jobnumber
);
job
.
appendChild
(
jobnumber
);
Element
account
=
doc
.
createElement
(
"account"
);
Element
account
=
doc
.
createElement
(
"account"
);
account
.
appendChild
(
doc
.
createTextNode
(
"Habib"
));
account
.
appendChild
(
doc
.
createTextNode
(
System
.
getProperty
(
"user.name"
)
));
job
.
appendChild
(
account
);
job
.
appendChild
(
account
);
Element
product
=
doc
.
createElement
(
"product"
);
Element
product
=
doc
.
createElement
(
"product"
);
product
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getProduct
()));
product
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getProduct
()));
root
.
appendChild
(
product
);
root
.
appendChild
(
product
);
Element
layers
=
doc
.
createElement
(
"layers"
);
Element
layers
=
doc
.
createElement
(
"layers"
);
layers
.
setAttribute
(
"color"
,
jobDescriptor
.
getColor
());
layers
.
setAttribute
(
"color"
,
jobDescriptor
.
getColor
());
layers
.
setAttribute
(
"mono"
,
jobDescriptor
.
getMono
());
layers
.
setAttribute
(
"mono"
,
jobDescriptor
.
getMono
());
...
@@ -117,17 +116,17 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
...
@@ -117,17 +116,17 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
layers
.
setAttribute
(
"plotframe"
,
jobDescriptor
.
getPlotframe
());
layers
.
setAttribute
(
"plotframe"
,
jobDescriptor
.
getPlotframe
());
layers
.
setAttribute
(
"single"
,
jobDescriptor
.
getSingle
());
layers
.
setAttribute
(
"single"
,
jobDescriptor
.
getSingle
());
root
.
appendChild
(
layers
);
root
.
appendChild
(
layers
);
appendLayers
(
doc
,
layers
,
jobDescriptor
.
getLayerList
());
appendLayers
(
doc
,
layers
,
jobDescriptor
.
getLayerList
());
Element
srs
=
doc
.
createElement
(
"srs"
);
Element
srs
=
doc
.
createElement
(
"srs"
);
srs
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getSrs
()));
srs
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getSrs
()));
root
.
appendChild
(
srs
);
root
.
appendChild
(
srs
);
Element
extent
=
doc
.
createElement
(
"extent"
);
Element
extent
=
doc
.
createElement
(
"extent"
);
extent
.
setAttribute
(
"merge_mapsheets"
,
jobDescriptor
.
getMergeMapsheets
());
extent
.
setAttribute
(
"merge_mapsheets"
,
jobDescriptor
.
getMergeMapsheets
());
root
.
appendChild
(
extent
);
root
.
appendChild
(
extent
);
if
(!
jobDescriptor
.
getUnitList
().
isEmpty
())
{
if
(!
jobDescriptor
.
getUnitList
().
isEmpty
())
{
extent
.
setAttribute
(
"tile1asgn"
,
jobDescriptor
.
getTile1asgn
());
extent
.
setAttribute
(
"tile1asgn"
,
jobDescriptor
.
getTile1asgn
());
for
(
Unit
unit
:
jobDescriptor
.
getUnitList
())
{
for
(
Unit
unit
:
jobDescriptor
.
getUnitList
())
{
...
@@ -137,23 +136,23 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
...
@@ -137,23 +136,23 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
unitElement
.
setAttribute
(
"select_mapsheets"
,
unit
.
getSelectMapsheets
());
unitElement
.
setAttribute
(
"select_mapsheets"
,
unit
.
getSelectMapsheets
());
unitElement
.
setAttribute
(
"subdivision"
,
unit
.
getSubdivision
());
unitElement
.
setAttribute
(
"subdivision"
,
unit
.
getSubdivision
());
unitElement
.
appendChild
(
doc
.
createTextNode
(
unit
.
getValue
()));
unitElement
.
appendChild
(
doc
.
createTextNode
(
unit
.
getValue
()));
extent
.
appendChild
(
unitElement
);
extent
.
appendChild
(
unitElement
);
}
}
}
else
{
}
else
{
Element
polygon
=
createRegionPolygonElement
(
doc
,
jobDescriptor
.
regionPolygon
);
Element
polygon
=
createRegionPolygonElement
(
doc
,
jobDescriptor
.
regionPolygon
);
extent
.
appendChild
(
polygon
);
extent
.
appendChild
(
polygon
);
}
}
Element
resolution
=
doc
.
createElement
(
"resolution"
);
Element
resolution
=
doc
.
createElement
(
"resolution"
);
resolution
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getResolution
()));
resolution
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getResolution
()));
root
.
appendChild
(
resolution
);
root
.
appendChild
(
resolution
);
Element
scale
=
doc
.
createElement
(
"scale"
);
Element
scale
=
doc
.
createElement
(
"scale"
);
scale
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getScale
()));
scale
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getScale
()));
root
.
appendChild
(
scale
);
root
.
appendChild
(
scale
);
Element
format
=
doc
.
createElement
(
"format"
);
Element
format
=
doc
.
createElement
(
"format"
);
format
.
setAttribute
(
"alphalinscale"
,
"0.0"
);
format
.
setAttribute
(
"alphalinscale"
,
"0.0"
);
format
.
setAttribute
(
"alphascale"
,
"1.0"
);
format
.
setAttribute
(
"alphascale"
,
"1.0"
);
format
.
setAttribute
(
"citygml_actfunc"
,
"undef"
);
format
.
setAttribute
(
"citygml_actfunc"
,
"undef"
);
...
@@ -178,52 +177,52 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
...
@@ -178,52 +177,52 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
format
.
setAttribute
(
"xyz"
,
"false"
);
format
.
setAttribute
(
"xyz"
,
"false"
);
format
.
appendChild
(
doc
.
createTextNode
(
"CityGML"
));
format
.
appendChild
(
doc
.
createTextNode
(
"CityGML"
));
root
.
appendChild
(
format
);
root
.
appendChild
(
format
);
Element
exportmetadata
=
doc
.
createElement
(
"exportmetadata"
);
Element
exportmetadata
=
doc
.
createElement
(
"exportmetadata"
);
exportmetadata
.
setAttribute
(
"calibration"
,
jobDescriptor
.
getCalibration
());
exportmetadata
.
setAttribute
(
"calibration"
,
jobDescriptor
.
getCalibration
());
exportmetadata
.
setAttribute
(
"xmetadata"
,
jobDescriptor
.
getXmetadata
());
exportmetadata
.
setAttribute
(
"xmetadata"
,
jobDescriptor
.
getXmetadata
());
exportmetadata
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getExportmetadata
()));
exportmetadata
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getExportmetadata
()));
root
.
appendChild
(
exportmetadata
);
root
.
appendChild
(
exportmetadata
);
Element
addfile
=
doc
.
createElement
(
"addfile"
);
Element
addfile
=
doc
.
createElement
(
"addfile"
);
addfile
.
setAttribute
(
"col"
,
jobDescriptor
.
getCol
());
addfile
.
setAttribute
(
"col"
,
jobDescriptor
.
getCol
());
addfile
.
setAttribute
(
"eck"
,
jobDescriptor
.
getEck
());
addfile
.
setAttribute
(
"eck"
,
jobDescriptor
.
getEck
());
root
.
appendChild
(
addfile
);
root
.
appendChild
(
addfile
);
Element
usenodatamask
=
doc
.
createElement
(
"usenodatamask"
);
Element
usenodatamask
=
doc
.
createElement
(
"usenodatamask"
);
usenodatamask
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getUsenodatamask
()));
usenodatamask
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getUsenodatamask
()));
root
.
appendChild
(
usenodatamask
);
root
.
appendChild
(
usenodatamask
);
Element
usepdctborderpoly
=
doc
.
createElement
(
"usepdctborderpoly"
);
Element
usepdctborderpoly
=
doc
.
createElement
(
"usepdctborderpoly"
);
usepdctborderpoly
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getUsepdctborderpoly
()));
usepdctborderpoly
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getUsepdctborderpoly
()));
root
.
appendChild
(
usepdctborderpoly
);
root
.
appendChild
(
usepdctborderpoly
);
Element
dhkresolvereferences
=
doc
.
createElement
(
"dhkresolvereferences"
);
Element
dhkresolvereferences
=
doc
.
createElement
(
"dhkresolvereferences"
);
dhkresolvereferences
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getDhkresolvereferences
()));
dhkresolvereferences
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getDhkresolvereferences
()));
root
.
appendChild
(
dhkresolvereferences
);
root
.
appendChild
(
dhkresolvereferences
);
Element
zipresult
=
doc
.
createElement
(
"zipresult"
);
Element
zipresult
=
doc
.
createElement
(
"zipresult"
);
zipresult
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getZipresult
()));
zipresult
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getZipresult
()));
root
.
appendChild
(
zipresult
);
root
.
appendChild
(
zipresult
);
Element
userdescription
=
doc
.
createElement
(
"userdescription"
);
Element
userdescription
=
doc
.
createElement
(
"userdescription"
);
root
.
appendChild
(
userdescription
);
root
.
appendChild
(
userdescription
);
Element
namingpattern
=
doc
.
createElement
(
"namingpattern"
);
Element
namingpattern
=
doc
.
createElement
(
"namingpattern"
);
root
.
appendChild
(
namingpattern
);
root
.
appendChild
(
namingpattern
);
TransformerFactory
transformerFactory
=
TransformerFactory
.
newInstance
();
TransformerFactory
transformerFactory
=
TransformerFactory
.
newInstance
();
Transformer
transformer
=
transformerFactory
.
newTransformer
();
Transformer
transformer
=
transformerFactory
.
newTransformer
();
StringWriter
writer
=
new
StringWriter
();
StringWriter
writer
=
new
StringWriter
();
StreamResult
streamResult
=
new
StreamResult
(
writer
);
StreamResult
streamResult
=
new
StreamResult
(
writer
);
transformer
.
transform
(
new
DOMSource
(
doc
),
streamResult
);
transformer
.
transform
(
new
DOMSource
(
doc
),
streamResult
);
File
tempfile
=
File
.
createTempFile
(
jobDescriptor
.
getProduct
()
+
"_"
,
".xml"
);
File
tempfile
=
File
.
createTempFile
(
jobDescriptor
.
getProduct
()
+
"_"
,
".xml"
);
PrintWriter
printWriter
=
new
PrintWriter
(
tempfile
);
PrintWriter
printWriter
=
new
PrintWriter
(
tempfile
);
printWriter
.
print
(
writer
.
toString
());
printWriter
.
print
(
writer
.
toString
());
printWriter
.
close
();
printWriter
.
close
();
return
tempfile
;
return
tempfile
;
}
catch
(
ParserConfigurationException
ex
)
{
}
catch
(
ParserConfigurationException
ex
)
{
// TODO Auto-generated catch block
// TODO Auto-generated catch block
...
@@ -246,7 +245,7 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
...
@@ -246,7 +245,7 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
}
}
return
result
;
return
result
;
}
}
/**
/**
* Appends layers to the XML job document.
* Appends layers to the XML job document.
*
*
...
@@ -261,24 +260,24 @@ private void appendLayers(Document doc, Element layers,
...
@@ -261,24 +260,24 @@ private void appendLayers(Document doc, Element layers,
layerElement
.
setAttribute
(
"name"
,
layer
.
getName
());
layerElement
.
setAttribute
(
"name"
,
layer
.
getName
());
String
product
=
layer
.
getProduct
();
String
product
=
layer
.
getProduct
();
if
(
Objects
.
nonNull
(
product
)
&&
!
product
.
isEmpty
())
{
if
(
Objects
.
nonNull
(
product
)
&&
!
product
.
isEmpty
())
{
layerElement
.
setAttribute
(
"product"
,
product
);
layerElement
.
setAttribute
(
"product"
,
product
);
}
}
String
style
=
layer
.
getStyle
();
String
style
=
layer
.
getStyle
();
if
(
Objects
.
nonNull
(
style
)
&&
!
style
.
isEmpty
())
{
if
(
Objects
.
nonNull
(
style
)
&&
!
style
.
isEmpty
())
{
layerElement
.
setAttribute
(
"style"
,
style
);
layerElement
.
setAttribute
(
"style"
,
style
);
}
}
layers
.
appendChild
(
layerElement
);
layers
.
appendChild
(
layerElement
);
}
}
}
}
/**
/**
* Transforms a global WGS 84 position into a coordinate of the given target SRS.
* Transforms a global WGS 84 position into a coordinate of the given target SRS.
*
*
* @param wgs84Position The WGS 84 position to be transformed to a position within the target SRS.
* @param wgs84Position The WGS 84 position to be transformed to a position within the target SRS.
* @param targetCRS The target SRS for the transformation.
* @param targetCRS The target SRS for the transformation.
* @return The transformed target position within the target SRS.
* @return The transformed target position within the target SRS.
*/
*/
public
static
ProjCoordinate
transformCoordinate
(
ProjCoordinate
wgs84Position
,
public
static
ProjCoordinate
transformCoordinate
(
ProjCoordinate
wgs84Position
,
CoordinateReferenceSystem
targetCRS
)
{
CoordinateReferenceSystem
targetCRS
)
{
ProjCoordinate
result
=
new
ProjCoordinate
();
ProjCoordinate
result
=
new
ProjCoordinate
();
CRSFactory
f
=
new
CRSFactory
();
CRSFactory
f
=
new
CRSFactory
();
...
@@ -287,10 +286,10 @@ public static ProjCoordinate transformCoordinate(ProjCoordinate wgs84Position,
...
@@ -287,10 +286,10 @@ public static ProjCoordinate transformCoordinate(ProjCoordinate wgs84Position,
transform
.
transform
(
wgs84Position
,
result
);
transform
.
transform
(
wgs84Position
,
result
);
return
result
;
return
result
;
}
}
/**
/**
* Appends the region polygon to the XML export job document. In order to do this, the given WGS 84 region
* Appends the region polygon to the XML export job document. In order to do this, the given WGS 84 region
polygon
*
polygon
will be transformed into a DHDN Gauss-Kruger zone 3 polygon.
* will be transformed into a DHDN Gauss-Kruger zone 3 polygon.
*
*
* @param doc The XML export job document.
* @param doc The XML export job document.
* @param regionPolygon The polygon of the region which has been selected to be exported.
* @param regionPolygon The polygon of the region which has been selected to be exported.
...
@@ -315,22 +314,22 @@ private static Element createRegionPolygonElement(Document doc, List<Coord> regi
...
@@ -315,22 +314,22 @@ private static Element createRegionPolygonElement(Document doc, List<Coord> regi
/**
/**
* Builds a zipped import job file. This file can be sent to a nF server instance by the caller afterwards.
* Builds a zipped import job file. This file can be sent to a nF server instance by the caller afterwards.
*
*
* @param jobDescriptor A job descriptor which describes the import job with all its attributes according to
* @param jobDescriptor A job descriptor which describes the import job with all its attributes according to
a valid
*
a valid
nF import job DTD.
*
nF import job DTD.
* @return Returns a XML import job document.
* @return Returns a XML import job document.
*/
*/
@Override
@Override
public
File
buildImportJobFile
(
ImportJobDescription
jobDescriptor
)
public
File
buildImportJobFile
(
ImportJobDescription
jobDescriptor
)
throws
InvalidJobDescriptorException
{
throws
InvalidJobDescriptorException
{
if
(
Objects
.
nonNull
(
jobDescriptor
)
&&
jobDescriptor
.
isValid
())
{
if
(
Objects
.
nonNull
(
jobDescriptor
)
&&
jobDescriptor
.
isValid
())
{
try
{
try
{
// Write the nF start file which triggers and controls the processing of the CityGML file.
// Write the nF start file which triggers and controls the processing of the CityGML file.
String
startFilename
=
jobDescriptor
.
getProduct
()
+
"_"
+
jobDescriptor
.
getLeaf
()
+
".start"
;
String
startFilename
=
jobDescriptor
.
getProduct
()
+
"_"
+
jobDescriptor
.
getLeaf
()
+
".start"
;
File
startfile
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
),
startFilename
);
File
startfile
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
),
startFilename
);
PrintWriter
writer
=
new
PrintWriter
(
startfile
);
PrintWriter
writer
=
new
PrintWriter
(
startfile
);
writer
.
print
(
jobDescriptor
.
getLevel
());
writer
.
print
(
jobDescriptor
.
getLevel
());
writer
.
close
();
writer
.
close
();
// Zip start file, CityGML file and ADE schemata
// Zip start file, CityGML file and ADE schemata
File
zippedCityGMLFile
=
File
.
createTempFile
(
"nF_Import_"
,
".zip"
);
File
zippedCityGMLFile
=
File
.
createTempFile
(
"nF_Import_"
,
".zip"
);
ZipOutputStream
zos
=
new
ZipOutputStream
(
new
FileOutputStream
(
zippedCityGMLFile
));
ZipOutputStream
zos
=
new
ZipOutputStream
(
new
FileOutputStream
(
zippedCityGMLFile
));
...
@@ -344,10 +343,10 @@ public File buildImportJobFile(ImportJobDescription jobDescriptor)
...
@@ -344,10 +343,10 @@ public File buildImportJobFile(ImportJobDescription jobDescriptor)
writeBytesToZipFile
(
new
FileInputStream
(
cityGMLFile
),
zos
,
zipFileName
);
writeBytesToZipFile
(
new
FileInputStream
(
cityGMLFile
),
zos
,
zipFileName
);
writeBytesToZipFile
(
new
FileInputStream
(
startfile
),
zos
,
startFilename
);
writeBytesToZipFile
(
new
FileInputStream
(
startfile
),
zos
,
startFilename
);
for
(
File
adeSchemaFile
:
jobDescriptor
.
getADESchemaFileList
())
{
for
(
File
adeSchemaFile
:
jobDescriptor
.
getADESchemaFileList
())
{
writeBytesToZipFile
(
new
FileInputStream
(
adeSchemaFile
),
zos
,
adeSchemaFile
.
getName
());
writeBytesToZipFile
(
new
FileInputStream
(
adeSchemaFile
),
zos
,
adeSchemaFile
.
getName
());
}
}
zos
.
close
();
zos
.
close
();
return
zippedCityGMLFile
;
return
zippedCityGMLFile
;
}
catch
(
FileNotFoundException
ex
)
{
}
catch
(
FileNotFoundException
ex
)
{
// TODO Auto-generated catch block
// TODO Auto-generated catch block
...
@@ -361,16 +360,16 @@ public File buildImportJobFile(ImportJobDescription jobDescriptor)
...
@@ -361,16 +360,16 @@ public File buildImportJobFile(ImportJobDescription jobDescriptor)
}
}
return
null
;
return
null
;
}
}
/**
/**
* Writes a file to the given ZipOutputStream which compresses the file.
* Writes a file to the given ZipOutputStream which compresses the file.
*
*
* @param fis The file input stream to be compressed.
* @param fis The file input stream to be compressed.
* @param zos The zip output stream.
* @param zos The zip output stream.
* @param zipEntry The new zip entry for the file to be compressed.
* @param zipEntry The new zip entry for the file to be compressed.
* @throws IOException You will get some of this, if your streams point to nirvana.
* @throws IOException You will get some of this, if your streams point to nirvana.
*/
*/
private
void
writeBytesToZipFile
(
FileInputStream
fis
,
ZipOutputStream
zos
,
String
zipEntry
)
private
void
writeBytesToZipFile
(
FileInputStream
fis
,
ZipOutputStream
zos
,
String
zipEntry
)
throws
IOException
{
throws
IOException
{
zos
.
putNextEntry
(
new
ZipEntry
(
zipEntry
));
zos
.
putNextEntry
(
new
ZipEntry
(
zipEntry
));
byte
[]
b
=
new
byte
[
1024
];
byte
[]
b
=
new
byte
[
1024
];
...
...
test/eu/simstadt/nf4j/async/test/SuccessfulExportJob.java
View file @
dcf31f94
...
@@ -30,10 +30,11 @@ public class SuccessfulExportJob implements JobStatusListener
...
@@ -30,10 +30,11 @@ public class SuccessfulExportJob implements JobStatusListener
@Test
@Test
public
void
processJob
()
throws
InterruptedException
{
public
void
processJob
()
throws
InterruptedException
{
ExportJobDescription
description
=
ExportJobDescription
.
getDefaultDescriptor
();
ExportJobDescription
description
=
ExportJobDescription
.
getDefaultDescriptor
();
description
.
setInitiator
(
"2758"
);
description
.
setInitiator
(
String
.
valueOf
((
int
)
(
Math
.
random
()
*
9999
)));
description
.
setAccount
(
"Bruse"
);
String
userName
=
System
.
getProperty
(
"user.name"
);
description
.
setAccount
(
userName
);
description
.
setProduct
(
"WU3"
);
description
.
setProduct
(
"WU3"
);
description
.
setJobnumber
(
"Bruse_0815"
);
description
.
setJobnumber
(
userName
);
//FIXME: Zipped GMLs coming from nF don't have any defined srsName
//FIXME: Zipped GMLs coming from nF don't have any defined srsName
//FIXME: Save files somewhere else
//FIXME: Save files somewhere else
...
@@ -140,7 +141,7 @@ public void jobStatusChanged(JobStatusEvent event) {
...
@@ -140,7 +141,7 @@ public void jobStatusChanged(JobStatusEvent event) {
try
{
try
{
File
file
=
job
.
getResult
();
File
file
=
job
.
getResult
();
assertTrue
(
file
.
canRead
());
assertTrue
(
file
.
canRead
());
// System.out.println("CityGML at " + file.getAbsolutePath());
// System.out.println("CityGML at " + file.getAbsolutePath());
}
catch
(
FailedTransmissionException
ex
)
{
}
catch
(
FailedTransmissionException
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment