Commit 20454d45 authored by bruse's avatar bruse
Browse files

Now, NFConnector lets you import Energy ADE specific attributes along with your standard CityGML.

No related merge requests found
Showing with 999 additions and 631 deletions
+999 -631
......@@ -18,6 +18,19 @@ public static ExportJob getNewInstance() {
return new ExportJob(JobStatus.UNKOWN);
}
/**
* Initializes a new export job instance with unknown state and connector instance. This is a
* convenient method.
*
* @param The nF connector which answers status requests for this job.
* @return Returns a new export job instance with unknown state.
*/
public static ExportJob getNewInstance(NFConnector<?, ?> nFConnector) {
ExportJob result = getNewInstance();
result.setNFConnector(nFConnector);
return result;
}
/**
* This constructor forces the job to have a defined state.
*
......@@ -26,6 +39,21 @@ public static ExportJob getNewInstance() {
public ExportJob(JobStatus status) {
super(status);
}
/**
* Connects to the nF and refreshes the status of this job. If there is no nF connector set,
* this operation will throw a FailedTransmissionException.
*
* @throws FailedTransmissionException If the connection to the nF is broken you will get some of this.
*/
public void updateStatus() throws FailedTransmissionException {
if (Objects.nonNull(getNFConnector())) {
Job job = getNFConnector().requestExportJob(getJobId());
setStatus(job.getStatus());
} else {
throw new FailedTransmissionException();
}
}
/**
* Sets the status of this job depending on the given nF status code. nF status codes will be sent
......
package eu.simstadt.nf4j;
import java.util.ArrayList;
import java.util.List;
/**
* Every instance of this class describes an export job for the novaFACTORY. Instances of JobBuilder
* take JobDescriptions and build XML export job files out of it.
* Implementations of this interface are known to implement export job descriptions.
*
* @author Marcel Bruse
*
*/
public class ExportJobDescriptor implements JobDescriptor {
private static final String DEFAULT_ACCOUNT = "Habib";
private static final String DEFAULT_XMETA_DATA = "0";
private static final String DEFAULT_CALIBRATION = "0";
private static final String DEFAULT_PRODUCT = "LBTEST";
private static final String DEFAULT_ZIP_RESULT = "0";
private static final String DEFAULT_DHK_RESOLVE_REFERENCES = "1";
private static final String DEFAULT_USE_PDCT_BORDER_POLY = "0";
private static final String DEFAULT_USE_NO_DATA_MASK = "0";
private static final String DEFAULT_ECK = "0";
private static final String DEFAULT_COL = "0";
private static final String DEFAULT_EXPORT_META_DATA = "1";
private static final String DEFAULT_FORMAT = "CityGML";
private static final String DEFAULT_SCALE = "10000.0";
private static final String DEFAULT_RESOLUTION = "100.0";
private static final String DEFAULT_MERGE_MAP_SHEETS = "off";
private static final String DEFAULT_SRS = "31467";
private static final String DEFAULT_SINGLE = "1";
private static final String DEFAULT_PLOTFRAME = "0";
private static final String DEFAULT_PLOT_LABEL_SRS = "-1";
private static final String DEFAULT_MONO = "0";
private static final String DEFAULT_COLOR = "0";
private static final String DEFAULT_JOBNUMBER = "GR_EXPORT_CITYGML_LOD1";
private static final String DEFAULT_INITIATOR = "2758";
/** The version of the novaFACTORY XML export job format. */
public static final String EXPORT_JOB_VERSION = "1.0.0";
/** TODO: Who or what is this initiator? */
private String initiator;
/** The number of the job which can actually be a string. */
private String jobnumber;
/** The account or user for which a job should be executed. */
private String account;
/** The product for which a job should be executed. */
private String product;
/** Color attribute of the layers tag. */
private String color;
/** The mono attribute of the layers tag. */
private String mono;
/** The plotLabelSrs flag of the layers tag. */
private String plotLabelSrs;
/** The plotframe flag of the layers tag. */
private String plotframe;
/** The single flag of the layers tag. */
private String single;
/** The layers which will be involved in a job. */
private ArrayList<Layer> layerList = new ArrayList<>();
/** The SRS for the job. */
private String srs;
/** The merge_mapsheets attribute of the extend tag. */
private String mergeMapsheets;
/** The polygon of the selected region which should be exported. */
ArrayList<Coord> regionPolygon = new ArrayList<>();
/** The resolution for the job. */
private String resolution;
/** The scale for the job. */
private String scale;
/** The format for the job. E.g. CityGML. */
private String format;
/** The exportmetadata flag for the job. */
private String exportmetadata;
/** The col attribute of the addfile tag. */
private String col;
/** The eck attribute of the addfile tag. */
private String eck;
/** The usenodatamask flag for the job. */
private String usenodatamask;
/** The usepdctborderpoly flag for the job. */
private String usepdctborderpoly;
/** The dhkresolvereferences flag for the job. */
private String dhkresolvereferences;
/** Flag for zipped results. */
private String zipresult;
/** The calibration attribute of the exportmetadata tag. */
private String calibration;
/** The xmetadata attribute of the exportmetadata tag. */
private String xmetadata;
public String getInitiator() {
return initiator;
}
public void setInitiator(String initiator) {
this.initiator = initiator;
}
public String getJobnumber() {
return jobnumber;
}
public void setJobnumber(String jobnumber) {
this.jobnumber = jobnumber;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getProduct() {
return product;
}
public void setProduct(String product) {
this.product = product;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getMono() {
return mono;
}
public void setMono(String mono) {
this.mono = mono;
}
public String getPlotLabelSrs() {
return plotLabelSrs;
}
public void setPlotLabelSrs(String plotLabelSrs) {
this.plotLabelSrs = plotLabelSrs;
}
public String getPlotframe() {
return plotframe;
}
public void setPlotframe(String plotframe) {
this.plotframe = plotframe;
}
public String getSingle() {
return single;
}
public void setSingle(String single) {
this.single = single;
}
public ArrayList<Layer> getLayerList() {
return layerList;
}
public void setLayerList(ArrayList<Layer> layerList) {
this.layerList = layerList;
}
public void addLayer(Layer layer) {
layerList.add(layer);
}
public String getSrs() {
return srs;
}
public void setSrs(String srs) {
this.srs = srs;
}
public String getMergeMapsheets() {
return mergeMapsheets;
}
public void setMergeMapsheets(String mergeMapsheets) {
this.mergeMapsheets = mergeMapsheets;
}
public String getResolution() {
return resolution;
}
public void setResolution(String resolution) {
this.resolution = resolution;
}
public String getScale() {
return scale;
}
public void setScale(String scale) {
this.scale = scale;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getExportmetadata() {
return exportmetadata;
}
public void setExportmetadata(String exportmetadata) {
this.exportmetadata = exportmetadata;
}
public String getCol() {
return col;
}
public void setCol(String col) {
this.col = col;
}
public String getEck() {
return eck;
}
public void setEck(String eck) {
this.eck = eck;
}
public String getUsenodatamask() {
return usenodatamask;
}
public void setUsenodatamask(String usenodatamask) {
this.usenodatamask = usenodatamask;
}
public String getUsepdctborderpoly() {
return usepdctborderpoly;
}
public void setUsepdctborderpoly(String usepdctborderpoly) {
this.usepdctborderpoly = usepdctborderpoly;
}
public String getDhkresolvereferences() {
return dhkresolvereferences;
}
public void setDhkresolvereferences(String dhkresolvereferences) {
this.dhkresolvereferences = dhkresolvereferences;
}
public String getZipresult() {
return zipresult;
}
public void setZipresult(String zipresult) {
this.zipresult = zipresult;
}
public String getCalibration() {
return calibration;
}
public void setCalibration(String calibration) {
this.calibration = calibration;
}
public String getXmetadata() {
return xmetadata;
}
public void setXmetadata(String xmetadata) {
this.xmetadata = xmetadata;
}
public interface ExportJobDescriptor extends JobDescriptor {
@Override
public String supportsJobVersion() {
return EXPORT_JOB_VERSION;
}
/**
* Adds a new coordinate to the region polygon. A region polygon is only used for export jobs.
*
* @param coordinate The new coordiante of the region polygon of a export job.
*/
public void addCoordinateToRegionPolygon(Coord coordinate) {
regionPolygon.add(coordinate);
}
/**
* Sets the whole region polygon for an export job.
*
* @param regionPolygon The region polygon to be used for an export job.
*/
public void setRegionPolygon(List<Coord> regionPolygon) {
this.regionPolygon.clear();
this.regionPolygon.addAll(regionPolygon);
}
/**
* @return Returns the region polygon.
*/
public ArrayList<Coord> getRegionPolygon() {
return regionPolygon;
}
/**
* @return Returns true, if all mandatory elements and attributes are set. Otherwise, false.
*/
public boolean isValid() {
if (regionPolygon.isEmpty()
|| layerList.isEmpty()
|| initiator.isEmpty()
|| account.isEmpty()
|| jobnumber.isEmpty()
|| product.isEmpty()
|| color.isEmpty()
|| mono.isEmpty()
|| plotLabelSrs.isEmpty()
|| plotframe.isEmpty()
|| single.isEmpty()
|| srs.isEmpty()
|| resolution.isEmpty()
|| scale.isEmpty()
|| format.isEmpty()
|| exportmetadata.isEmpty()
|| col.isEmpty()
|| eck.isEmpty()){
return false;
} else {
return true;
}
}
public static ExportJobDescriptor getDefaultDescriptor() {
ExportJobDescriptor descriptor = new ExportJobDescriptor();
descriptor.setInitiator(DEFAULT_INITIATOR);
descriptor.setJobnumber(DEFAULT_JOBNUMBER);
descriptor.setAccount(DEFAULT_ACCOUNT);
descriptor.setProduct(DEFAULT_PRODUCT);
descriptor.setColor(DEFAULT_COLOR);
descriptor.setMono(DEFAULT_MONO);
descriptor.setPlotLabelSrs(DEFAULT_PLOT_LABEL_SRS);
descriptor.setPlotframe(DEFAULT_PLOTFRAME);
descriptor.setSingle(DEFAULT_SINGLE);
descriptor.setSrs(DEFAULT_SRS);
descriptor.setMergeMapsheets(DEFAULT_MERGE_MAP_SHEETS);
descriptor.setResolution(DEFAULT_RESOLUTION);
descriptor.setScale(DEFAULT_SCALE);
descriptor.setFormat(DEFAULT_FORMAT);
descriptor.setExportmetadata(DEFAULT_EXPORT_META_DATA);
descriptor.setCol(DEFAULT_COL);
descriptor.setEck(DEFAULT_ECK);
descriptor.setUsenodatamask(DEFAULT_USE_NO_DATA_MASK);
descriptor.setUsepdctborderpoly(DEFAULT_USE_PDCT_BORDER_POLY);
descriptor.setDhkresolvereferences(DEFAULT_DHK_RESOLVE_REFERENCES);
descriptor.setZipresult(DEFAULT_ZIP_RESULT);
descriptor.setCalibration(DEFAULT_CALIBRATION);
descriptor.setXmetadata(DEFAULT_XMETA_DATA);
return descriptor;
}
}
package eu.simstadt.nf4j;
import java.util.ArrayList;
import java.util.List;
/**
* Every instance of this class describes an export job for the novaFACTORY. Instances of JobBuilder
* take JobDescriptions and build XML export job files out of it.
*
* @author Marcel Bruse
*/
public class ExportJobDescriptorImpl implements ExportJobDescriptor {
private static final String DEFAULT_ACCOUNT = "Marcel";
private static final String DEFAULT_XMETA_DATA = "0";
private static final String DEFAULT_CALIBRATION = "0";
private static final String DEFAULT_PRODUCT = "WUDEV";
private static final String DEFAULT_ZIP_RESULT = "0";
private static final String DEFAULT_DHK_RESOLVE_REFERENCES = "1";
private static final String DEFAULT_USE_PDCT_BORDER_POLY = "0";
private static final String DEFAULT_USE_NO_DATA_MASK = "0";
private static final String DEFAULT_ECK = "0";
private static final String DEFAULT_COL = "0";
private static final String DEFAULT_EXPORT_META_DATA = "1";
private static final String DEFAULT_FORMAT = "CityGML";
private static final String DEFAULT_SCALE = "10000.0";
private static final String DEFAULT_RESOLUTION = "100.0";
private static final String DEFAULT_MERGE_MAP_SHEETS = "off";
private static final String DEFAULT_TILE1ASGN = "false";
private static final String DEFAULT_EXTERIOR = "0";
private static final String DEFAULT_FRAME = "0";
private static final String DEFAULT_SELECT_MAP_SHEETS = "0";
private static final String DEFAULT_SUBDIVISION = "4";
private static final String DEFAULT_SRS = "31467";
private static final String DEFAULT_SINGLE = "1";
private static final String DEFAULT_PLOTFRAME = "0";
private static final String DEFAULT_PLOT_LABEL_SRS = "-1";
private static final String DEFAULT_MONO = "0";
private static final String DEFAULT_COLOR = "0";
private static final String DEFAULT_JOBNUMBER = "GR_EXPORT_CITYGML_LOD1";
private static final String DEFAULT_INITIATOR = "2758";
/** The version of the novaFACTORY XML export job format. */
public static final String EXPORT_JOB_VERSION = "1.0.0";
/** TODO: Who or what is this initiator? */
private String initiator;
/** The number of the job which can actually be a string. */
private String jobnumber;
/** The account or user for which a job should be executed. */
private String account;
/** The product for which a job should be executed. */
private String product;
/** Color attribute of the layers tag. */
private String color;
/** The mono attribute of the layers tag. */
private String mono;
/** The plotLabelSrs flag of the layers tag. */
private String plotLabelSrs;
/** The plotframe flag of the layers tag. */
private String plotframe;
/** The single flag of the layers tag. */
private String single;
/** The layers which will be involved in a job. */
private ArrayList<Layer> layerList = new ArrayList<>();
/** The SRS for the job. */
private String srs;
/** The merge_mapsheets attribute of the extent tag. */
private String mergeMapsheets;
/** The tile1asgn attribute of the extent tag. */
private String tile1asgn;
/** The exterior attribute of the unit tag. */
private String exterior;
/** The frame attribute of the unit tag. */
private String frame;
/** The select mapsheet attribute of the unit tag. */
private String selectMapsheets;
/** The subdivision attribute of the unit tag. */
private String subdivision;
/** The unit tag of the extent. */
private String unit;
/** The polygon of the selected region which should be exported. */
ArrayList<Coord> regionPolygon = new ArrayList<>();
/** The resolution for the job. */
private String resolution;
/** The scale for the job. */
private String scale;
/** The format for the job. E.g. CityGML. */
private String format;
/** The exportmetadata flag for the job. */
private String exportmetadata;
/** The col attribute of the addfile tag. */
private String col;
/** The eck attribute of the addfile tag. */
private String eck;
/** The usenodatamask flag for the job. */
private String usenodatamask;
/** The usepdctborderpoly flag for the job. */
private String usepdctborderpoly;
/** The dhkresolvereferences flag for the job. */
private String dhkresolvereferences;
/** Flag for zipped results. */
private String zipresult;
/** The calibration attribute of the exportmetadata tag. */
private String calibration;
/** The xmetadata attribute of the exportmetadata tag. */
private String xmetadata;
public String getInitiator() {
return initiator;
}
public void setInitiator(String initiator) {
this.initiator = initiator;
}
public String getJobnumber() {
return jobnumber;
}
public void setJobnumber(String jobnumber) {
this.jobnumber = jobnumber;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getProduct() {
return product;
}
public void setProduct(String product) {
this.product = product;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getMono() {
return mono;
}
public void setMono(String mono) {
this.mono = mono;
}
public String getPlotLabelSrs() {
return plotLabelSrs;
}
public void setPlotLabelSrs(String plotLabelSrs) {
this.plotLabelSrs = plotLabelSrs;
}
public String getPlotframe() {
return plotframe;
}
public void setPlotframe(String plotframe) {
this.plotframe = plotframe;
}
public String getSingle() {
return single;
}
public void setSingle(String single) {
this.single = single;
}
public ArrayList<Layer> getLayerList() {
return layerList;
}
public void setLayerList(ArrayList<Layer> layerList) {
this.layerList = layerList;
}
public void addLayer(Layer layer) {
layerList.add(layer);
}
public String getSrs() {
return srs;
}
public void setSrs(String srs) {
this.srs = srs;
}
public String getMergeMapsheets() {
return mergeMapsheets;
}
public void setMergeMapsheets(String mergeMapsheets) {
this.mergeMapsheets = mergeMapsheets;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getExterior() {
return exterior;
}
public void setExterior(String exterior) {
this.exterior = exterior;
}
public String getTile1asgn() {
return tile1asgn;
}
public void setTile1asgn(String tile1asgn) {
this.tile1asgn = tile1asgn;
}
public String getFrame() {
return frame;
}
public void setFrame(String frame) {
this.frame = frame;
}
public String getSelectMapsheets() {
return selectMapsheets;
}
public void setSelectMapsheets(String selectMapsheets) {
this.selectMapsheets = selectMapsheets;
}
public String getSubdivision() {
return subdivision;
}
public void setSubdivision(String subdivision) {
this.subdivision = subdivision;
}
public String getResolution() {
return resolution;
}
public void setResolution(String resolution) {
this.resolution = resolution;
}
public String getScale() {
return scale;
}
public void setScale(String scale) {
this.scale = scale;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getExportmetadata() {
return exportmetadata;
}
public void setExportmetadata(String exportmetadata) {
this.exportmetadata = exportmetadata;
}
public String getCol() {
return col;
}
public void setCol(String col) {
this.col = col;
}
public String getEck() {
return eck;
}
public void setEck(String eck) {
this.eck = eck;
}
public String getUsenodatamask() {
return usenodatamask;
}
public void setUsenodatamask(String usenodatamask) {
this.usenodatamask = usenodatamask;
}
public String getUsepdctborderpoly() {
return usepdctborderpoly;
}
public void setUsepdctborderpoly(String usepdctborderpoly) {
this.usepdctborderpoly = usepdctborderpoly;
}
public String getDhkresolvereferences() {
return dhkresolvereferences;
}
public void setDhkresolvereferences(String dhkresolvereferences) {
this.dhkresolvereferences = dhkresolvereferences;
}
public String getZipresult() {
return zipresult;
}
public void setZipresult(String zipresult) {
this.zipresult = zipresult;
}
public String getCalibration() {
return calibration;
}
public void setCalibration(String calibration) {
this.calibration = calibration;
}
public String getXmetadata() {
return xmetadata;
}
public void setXmetadata(String xmetadata) {
this.xmetadata = xmetadata;
}
@Override
public String supportsJobVersion() {
return EXPORT_JOB_VERSION;
}
/**
* Adds a new coordinate to the region polygon. A region polygon is only used for export jobs.
*
* @param coordinate The new coordiante of the region polygon of a export job.
*/
public void addCoordinateToRegionPolygon(Coord coordinate) {
regionPolygon.add(coordinate);
}
/**
* Sets the whole region polygon for an export job.
*
* @param regionPolygon The region polygon to be used for an export job.
*/
public void setRegionPolygon(List<Coord> regionPolygon) {
this.regionPolygon.clear();
this.regionPolygon.addAll(regionPolygon);
}
/**
* @return Returns the region polygon.
*/
public ArrayList<Coord> getRegionPolygon() {
return regionPolygon;
}
/**
* @return Returns true, if all mandatory elements and attributes are set. Otherwise, false.
*/
@Override
public boolean isValid() {
if ((regionPolygon.isEmpty()
&& (unit.isEmpty()
|| exterior.isEmpty()
|| frame.isEmpty()
|| selectMapsheets.isEmpty()
|| subdivision.isEmpty()
))
|| layerList.isEmpty()
|| initiator.isEmpty()
|| account.isEmpty()
|| jobnumber.isEmpty()
|| product.isEmpty()
|| color.isEmpty()
|| mono.isEmpty()
|| plotLabelSrs.isEmpty()
|| plotframe.isEmpty()
|| single.isEmpty()
|| srs.isEmpty()
|| resolution.isEmpty()
|| scale.isEmpty()
|| format.isEmpty()
|| exportmetadata.isEmpty()
|| col.isEmpty()
|| eck.isEmpty()){
return false;
} else {
return true;
}
}
public static ExportJobDescriptorImpl getDefaultDescriptor() {
ExportJobDescriptorImpl descriptor = new ExportJobDescriptorImpl();
descriptor.setInitiator(DEFAULT_INITIATOR);
descriptor.setJobnumber(DEFAULT_JOBNUMBER);
descriptor.setAccount(DEFAULT_ACCOUNT);
descriptor.setProduct(DEFAULT_PRODUCT);
descriptor.setColor(DEFAULT_COLOR);
descriptor.setMono(DEFAULT_MONO);
descriptor.setPlotLabelSrs(DEFAULT_PLOT_LABEL_SRS);
descriptor.setPlotframe(DEFAULT_PLOTFRAME);
descriptor.setSingle(DEFAULT_SINGLE);
descriptor.setSrs(DEFAULT_SRS);
descriptor.setMergeMapsheets(DEFAULT_MERGE_MAP_SHEETS);
descriptor.setExterior(DEFAULT_EXTERIOR);
descriptor.setTile1asgn(DEFAULT_TILE1ASGN);
descriptor.setFrame(DEFAULT_FRAME);
descriptor.setSelectMapsheets(DEFAULT_SELECT_MAP_SHEETS);
descriptor.setSubdivision(DEFAULT_SUBDIVISION);
descriptor.setResolution(DEFAULT_RESOLUTION);
descriptor.setScale(DEFAULT_SCALE);
descriptor.setFormat(DEFAULT_FORMAT);
descriptor.setExportmetadata(DEFAULT_EXPORT_META_DATA);
descriptor.setCol(DEFAULT_COL);
descriptor.setEck(DEFAULT_ECK);
descriptor.setUsenodatamask(DEFAULT_USE_NO_DATA_MASK);
descriptor.setUsepdctborderpoly(DEFAULT_USE_PDCT_BORDER_POLY);
descriptor.setDhkresolvereferences(DEFAULT_DHK_RESOLVE_REFERENCES);
descriptor.setZipresult(DEFAULT_ZIP_RESULT);
descriptor.setCalibration(DEFAULT_CALIBRATION);
descriptor.setXmetadata(DEFAULT_XMETA_DATA);
return descriptor;
}
}
package eu.simstadt.nf4j;
/**
* This exception may be thrown by classes of the nf4j package if/on ...
* - the connector is null
* - malformed URLs
* - missing or malformed XML reports
* - HTTP failures
*
* @author Marcel Bruse
*/
public class FailedTransmissionException extends Exception {
private static final long serialVersionUID = -3530932388888249528L;
private String message;
public FailedTransmissionException() {}
public FailedTransmissionException(String message) {
this.message = message;
}
@Override
public String getMessage() {
return message;
}
}
package eu.simstadt.nf4j;
import java.util.Objects;
/**
* Import jobs are requests to store, change or delete CityGML models. Every valid import job has an id and a status.
*
......@@ -12,10 +14,23 @@ public class ImportJob extends Job {
*
* @return Returns a new import job instance with unknown state.
*/
public static ImportJob getUnkownInstance() {
public static ImportJob getNewInstance() {
return new ImportJob(JobStatus.UNKOWN);
}
/**
* Initializes a new import job instance with unknown state and connector instance. This is a
* convenient method.
*
* @param The nF connector which answers status requests for this job.
* @return Returns a new import job instance with unknown state.
*/
public static ImportJob getNewInstance(NFConnector<?, ?> nFConnector) {
ImportJob result = getNewInstance();
result.setNFConnector(nFConnector);
return result;
}
/**
* This constructor forces the job to have a defined state.
*
......@@ -24,6 +39,21 @@ public static ImportJob getUnkownInstance() {
public ImportJob(JobStatus status) {
super(status);
}
/**
* Connects to the nF and refreshes the status of this job. If there is no nF connector set,
* this operation will throw a FailedTransmissionException.
*
* @throws FailedTransmissionException If the connection to the nF is broken you will get some of this.
*/
public void updateStatus() throws FailedTransmissionException {
if (Objects.nonNull(getNFConnector())) {
Job job = getNFConnector().requestImportJob(getJobId());
setStatus(job.getStatus());
} else {
throw new FailedTransmissionException();
}
}
/**
* Sets the status of this job depending on the given nF status code. nF status codes will be sent
......
......@@ -3,144 +3,22 @@
import java.io.File;
/**
* Every instance of this class describes an import job for the novaFACTORY. Instances of JobBuilder
* take JobDescriptions and build XML import job files out of it.
* Implementations of this interface are known to implement import job descriptions.
*
* @author Marcel Bruse
*/
public class ImportJobDescriptor implements JobDescriptor {
/** The version of the novaFACTORY XML export job format. */
public static final String IMPORT_JOB_VERSION = "1.0.0";
/** The default level on which your CityGML will be stored within the nF. */
public static final String DEFAULT_LEVEL = "GML";
/** The CityGML file which should be imported through a import job. */
private File cityGMLFile;
/** The nF product (Produkt) which will keep our CityGML. */
private String product;
/** The nF leaf (Blatt) of the nF product. */
private String leaf;
/** The nF level (Ebene) of the nF product. */
private String level;
/** The operation to be performed for the feature objects of the CityGML file. */
private String operation;
/**
* @return Returns the nF product which will keep our CityGML.
*/
public String getProduct() {
return product;
}
/**
* Sets the nF product for this import job.
*
* @param product The product of our import job.
*/
public void setProduct(String product) {
this.product = product;
}
/**
* @return Returns the nF leaf of the nF product.
*/
public String getLeaf() {
return leaf;
}
/**
* Sets the nF leaf for the nF product.
*
* @param leaf The leaf for the nF product.
*/
public void setLeaf(String leaf) {
this.leaf = leaf;
}
/**
* @return Returns the level of the product.
*/
public String getLevel() {
return level;
}
/**
* Sets the nF level for the nF product.
*
* @param level The level for the nF product.
*/
public void setLevel(String level) {
this.level = level;
}
/**
* @return Returns the CityGML file which should be imported through a import job.
*/
public File getCityGMLFile() {
return cityGMLFile;
}
/**
* Sets the CityGML file which should be imported through a import job.
*
* @param cityGMLFile The CityGML file which should be imported through a import job.
*/
public void setCityGMLFile(File cityGMLFile) {
this.cityGMLFile = cityGMLFile;
}
/**
* @return Returns the operation which should be conducted for the features of the CityGML file.
*/
public String getOperation() {
return operation;
}
public interface ImportJobDescriptor extends JobDescriptor {
/**
* Sets the operation which should be conducted for the feature objects of the CityGML file.
* Sets the CityGML file which is supposed to be imported by the nF.
*
* @param operation The operation which should be conducted for the feature object of the CityGML file.
* @param file The CityGML file which is supposed to be imported by the nF.
*/
public void setOperation(String operation) {
this.operation = operation;
}
public void setCityGMLFile(File file);
/**
* @return Returns the supported nF job version. This enables your job builder instance to check if
* the job version is compatible with itself.
* @return Returns the CityGML file which is supposed to be imported by the nF.
*/
@Override
public String supportsJobVersion() {
return IMPORT_JOB_VERSION;
}
public File getCityGMLFile();
/**
* This is just a prototype for presentation purposes.
*/
public static ImportJobDescriptor getDefaultDescriptor() {
ImportJobDescriptor descriptor = new ImportJobDescriptor();
descriptor.setLevel(DEFAULT_LEVEL);
return descriptor;
}
/**
* @return Returns true, if product, leaf, level and CityGML file are present.
*/
public boolean isValid() {
boolean result = true;
if (product.isEmpty()
&& leaf.isEmpty()
&& level.isEmpty()
&& !cityGMLFile.canRead()) {
result = false;
}
return result;
}
}
\ No newline at end of file
}
package eu.simstadt.nf4j;
import java.io.File;
import java.util.ArrayList;
import java.util.Objects;
/**
* Every instance of this class describes an import job for the novaFACTORY. Instances of NFConnector and
* JobBuilder take JobDescriptions and build XML import job files out of it.
*
* @author Marcel Bruse
*/
public class ImportJobDescriptorImpl implements ImportJobDescriptor {
/** The version of the novaFACTORY XML export job format. */
public static final String IMPORT_JOB_VERSION = "1.0.0";
/** The default level on which your CityGML will be stored within the nF. */
public static final String DEFAULT_LEVEL = "GML";
/** List of ADE XML schemata which describe additional elements within the CityGML file. */
private ArrayList<File> adeSchemaFileList = new ArrayList<>();
/** The nF product (Produkt) which will keep our CityGML. */
private String product;
/** The nF leaf (Blatt) of the nF product. */
private String leaf;
/** The nF level (Ebene) of the nF product. */
private String level;
/** The operation to be performed for the feature objects of the CityGML file. */
private Operation operation;
/** The CityGML file to be imported to the nF. */
private File cityGMLFile;
/**
* Sets the CityGML file which should be imported by nF.
*
* @param file The CityGML file to be uploaded to the nF.
*/
@Override
public void setCityGMLFile(File cityGMLFile) {
this.cityGMLFile = cityGMLFile;
}
/**
* @return Returns the CityGML file which should be uploaded to the nF.
*/
@Override
public File getCityGMLFile() {
return cityGMLFile;
}
/**
* @return Returns the nF product which will keep our CityGML.
*/
public String getProduct() {
return product;
}
/**
* Sets the nF product for this import job.
*
* @param product The product of our import job.
*/
public void setProduct(String product) {
this.product = product;
}
/**
* @return Returns the nF leaf of the nF product.
*/
public String getLeaf() {
return leaf;
}
/**
* Sets the nF leaf for the nF product.
*
* @param leaf The leaf for the nF product.
*/
public void setLeaf(String leaf) {
this.leaf = leaf;
}
/**
* @return Returns the level of the product.
*/
public String getLevel() {
return level;
}
/**
* Sets the nF level for the nF product.
*
* @param level The level for the nF product.
*/
public void setLevel(String level) {
this.level = level;
}
/**
* If your CityGML file encodes ADE specific elements then you have to add the corresponding schema
* definition file of the used ADE here.
*
* @param adeSchemaFile The schema definition of the used ADE.
*/
public void addADESchemaFile(File adeSchemaFile) {
adeSchemaFileList.add(adeSchemaFile);
}
/**
* @return Returns the list of ADE schemata which are used within your CityGML file.
*/
public ArrayList<File> getADESchemaFileList() {
return adeSchemaFileList;
}
/**
* @return Returns the operation which should be conducted for the features of the CityGML file.
*/
public Operation getOperation() {
return operation;
}
/**
* Sets the operation which should be conducted for the feature objects of the CityGML file.
*
* @param operation The operation which should be conducted for the feature object of the CityGML file.
*/
public void setOperation(Operation operation) {
this.operation = operation;
}
/**
* @return Returns the supported nF job version. This enables your job builder instance to check if
* the job version is compatible with itself.
*/
@Override
public String supportsJobVersion() {
return IMPORT_JOB_VERSION;
}
/**
* This is just a prototype for presentation purposes.
*/
public static ImportJobDescriptorImpl getDefaultDescriptor() {
ImportJobDescriptorImpl descriptor = new ImportJobDescriptorImpl();
descriptor.setLevel(DEFAULT_LEVEL);
return descriptor;
}
/**
* @return Returns true, if product, leaf, level and CityGML file are present.
*/
public boolean isValid() {
if (product.isEmpty()
|| leaf.isEmpty()
|| level.isEmpty()
|| Objects.isNull(cityGMLFile)
|| !cityGMLFile.canRead()) {
return false;
} else {
return true;
}
}
}
\ No newline at end of file
package eu.simstadt.nf4j;
public class InvalidJobDescriptorException extends Exception {
private static final long serialVersionUID = 2710340003578550634L;
}
package eu.simstadt.nf4j;
import java.util.Objects;
/**
* This job class bundles the three attributes of every nF job: Id, status and last job related nF (error) message.
*
......@@ -13,6 +15,9 @@ public abstract class Job {
/** The id of the job. */
private int jobId;
/** The connection to the nF. */
private NFConnector<?, ?> nFConnector;
/**
* This constructor forces the job to have a defined state.
*
......@@ -56,6 +61,30 @@ public void setJobId(int jobId) {
this.jobId = jobId;
}
/**
* @return Returns the nF connector of this job.
*/
public NFConnector<?, ?> getNFConnector() {
return nFConnector;
}
/**
* Sets the nF connector of this job.
*
* @param nFConnector The connector of this job.
*/
public void setNFConnector(NFConnector<?, ?> nFConnector) {
this.nFConnector = nFConnector;
}
/**
* Connects to the nF and refreshes the status of this job. If there is no nF connector set,
* this operation will throw a FailedTransmissionException.
*
* @throws FailedTransmissionException If the connection to the nF is broken you will get some of this.
*/
public abstract void updateStatus() throws FailedTransmissionException;
/**
* Sets the status of this job depending on the given nF status code. nF status codes will be sent
* to you in http responses. Export jobs and import jobs have different states. Consider this fact
......
......@@ -13,4 +13,9 @@ public interface JobDescriptor {
*/
public String supportsJobVersion();
/**
* @return Returns true, if the job description is complete and correct. False, otherwise.
*/
public boolean isValid();
}
......@@ -7,12 +7,12 @@
* one implementation for each version of novaFACTORY. The supported version should be returned by
* supportsNFVersion().
*
* @param <I> A import JobDescriptor.
* @param <E> JobBuilder takes implementations of JobDescriptor in order to populate the XML export job.
* @param <I> The import job descriptor implementation for this builder.
* @param <E> The export job descriptor implementation for this builder.
*
* @author Marcel Bruse
*/
public interface JobBuilder<I extends JobDescriptor, E extends JobDescriptor> {
public interface JobFileBuilder<I extends ImportJobDescriptor, E extends ExportJobDescriptor> {
/**
* @return Tells the caller the supported version of novaFACTORY.
......@@ -36,7 +36,7 @@
* a valid nF export job DTD.
* @return Returns a XML export job document.
*/
public File buildExportJobFile(E jobDescriptor);
public File buildExportJobFile(E exportJobDescriptor) throws InvalidJobDescriptorException;
/**
* Builds a zipped import job file. This file can be sent to a nF server instance by the caller afterwards.
......@@ -45,6 +45,6 @@
* the nF manual.
* @return Returns a zipped import job file.
*/
public File buildImportJobFile(I jobDescriptor);
public File buildImportJobFile(I importJobDescriptor) throws InvalidJobDescriptorException;
}
......@@ -36,7 +36,7 @@
*
* @author Marcel Bruse
*/
public class JobBuilderImpl implements JobBuilder<ImportJobDescriptor, ExportJobDescriptor> {
public class JobFileBuilderImpl implements JobFileBuilder<ImportJobDescriptorImpl, ExportJobDescriptorImpl> {
/** Supported version of the novaFACTORY. */
public static final String NOVA_FACTORY_VERSION = "6.3.1.1";
......@@ -65,9 +65,10 @@ public String supportsImportJobVersion() {
* @param jobDescriptor A job descriptor which describes the export job with all its attributes according to
* a valid nF export job DTD.
* @return Returns a string representation of the nF export job.
* @throws FailedJobTransmissionException
*/
@Override
public File buildExportJobFile(ExportJobDescriptor jobDescriptor) {
public File buildExportJobFile(ExportJobDescriptorImpl jobDescriptor) throws InvalidJobDescriptorException {
File result = null;
if (Objects.nonNull(jobDescriptor) && jobDescriptor.isValid()) {
try {
......@@ -116,8 +117,19 @@ public File buildExportJobFile(ExportJobDescriptor jobDescriptor) {
extent.setAttribute("merge_mapsheets", jobDescriptor.getMergeMapsheets());
root.appendChild(extent);
Element polygon = appendRegionPolygon(doc, jobDescriptor.regionPolygon);
extent.appendChild(polygon);
if (!jobDescriptor.getUnit().isEmpty()) {
extent.setAttribute("tile1asgn", jobDescriptor.getTile1asgn());
Element unit = doc.createElement("unit");
unit.setAttribute("exterior", jobDescriptor.getExterior());
unit.setAttribute("frame", jobDescriptor.getFrame());
unit.setAttribute("select_mapsheets", jobDescriptor.getSelectMapsheets());
unit.setAttribute("subdivision", jobDescriptor.getSubdivision());
unit.appendChild(doc.createTextNode(jobDescriptor.getUnit()));
extent.appendChild(unit);
} else {
Element polygon = appendRegionPolygon(doc, jobDescriptor.regionPolygon);
extent.appendChild(polygon);
}
Element resolution = doc.createElement("resolution");
resolution.appendChild(doc.createTextNode(jobDescriptor.getResolution()));
......@@ -129,14 +141,13 @@ public File buildExportJobFile(ExportJobDescriptor jobDescriptor) {
Element format = doc.createElement("format");
// TODO
format.setAttribute("alphalinscale", "0.0");
format.setAttribute("alphascale", "1.0");
format.setAttribute("citygml_actfunc", "tolod1");
format.setAttribute("citygml_actfunc", "undef");
format.setAttribute("citygml_apptheme", "");
format.setAttribute("citygml_elemclasses", "true");
format.setAttribute("citygml_lodmode", "all");
format.setAttribute("citygml_lods", "1");
format.setAttribute("citygml_lods", "01234");
format.setAttribute("citygml_metadata", "true");
format.setAttribute("citygml_outmode", "normal");
format.setAttribute("dtm", "false");
......@@ -150,19 +161,7 @@ public File buildExportJobFile(ExportJobDescriptor jobDescriptor) {
format.setAttribute("solar", "false");
format.setAttribute("solargeoplex", "false");
format.setAttribute("tex", "false");
format.setAttribute("tolod1", "true");
format.setAttribute("tolod1_add", "false");
format.setAttribute("tolod1_delrest", "false");
format.setAttribute("tolod1_dstattrabsgrnd", "");
format.setAttribute("tolod1_dstattrabsheight", "");
format.setAttribute("tolod1_dstattrrelheight", "");
format.setAttribute("tolod1_dstattrzmode", "");
format.setAttribute("tolod1_geommode", "lod1solid");
format.setAttribute("tolod1_lodsrcmode", "all");
format.setAttribute("tolod1_triangulate", "false");
format.setAttribute("tolod1_zroofmode", "mid");
format.setAttribute("tolod1_zusegenattrs", "");
format.setAttribute("tolod1_zusemeasuredheight", "false");
format.setAttribute("tolod1", "false");
format.setAttribute("xyz", "false");
format.appendChild(doc.createTextNode("CityGML"));
root.appendChild(format);
......@@ -229,6 +228,8 @@ public File buildExportJobFile(ExportJobDescriptor jobDescriptor) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
} else {
throw new InvalidJobDescriptorException();
}
return result;
}
......@@ -299,33 +300,44 @@ private static Element appendRegionPolygon(Document doc, List<Coord> regionPolyg
* @return Returns a XML import job document.
*/
@Override
public File buildImportJobFile(ImportJobDescriptor jobDescriptor) {
try {
// Write the nF start file which triggers and controls the processing of the CityGML file.
String startFilename = jobDescriptor.getProduct() + "_" + jobDescriptor.getLeaf() + ".start";
File startfile = new File(System.getProperty("java.io.tmpdir"), startFilename);
PrintWriter writer = new PrintWriter(startfile);
writer.print(jobDescriptor.getLevel());
writer.close();
// Zip start file and CityGML file
File zippedCityGMLFile = File.createTempFile("nF_Import_", ".zip");
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zippedCityGMLFile));
File cityGMLFile = jobDescriptor.getCityGMLFile();
writeBytesToZipFile(new FileInputStream(cityGMLFile), zos, jobDescriptor.getProduct() + "_"
+ jobDescriptor.getLeaf() + "_"
+ jobDescriptor.getLevel() + "_"
+ jobDescriptor.getOperation() + ".gml");
writeBytesToZipFile(new FileInputStream(startfile), zos, startFilename);
zos.close();
return zippedCityGMLFile;
} catch (FileNotFoundException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
} catch (IOException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
public File buildImportJobFile(ImportJobDescriptorImpl jobDescriptor)
throws InvalidJobDescriptorException {
if (Objects.nonNull(jobDescriptor) && jobDescriptor.isValid()) {
try {
// Write the nF start file which triggers and controls the processing of the CityGML file.
String startFilename = jobDescriptor.getProduct() + "_" + jobDescriptor.getLeaf() + ".start";
File startfile = new File(System.getProperty("java.io.tmpdir"), startFilename);
PrintWriter writer = new PrintWriter(startfile);
writer.print(jobDescriptor.getLevel());
writer.close();
// Zip start file, CityGML file and ADE schemata
File zippedCityGMLFile = File.createTempFile("nF_Import_", ".zip");
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zippedCityGMLFile));
String zipFileName = jobDescriptor.getProduct() + "_" + jobDescriptor.getLeaf() + "_"
+ jobDescriptor.getLevel();
if (Objects.nonNull(jobDescriptor.getOperation())) {
zipFileName += "_" + jobDescriptor.getOperation();
}
zipFileName += ".gml";
File cityGMLFile = jobDescriptor.getCityGMLFile();
writeBytesToZipFile(new FileInputStream(cityGMLFile), zos, zipFileName);
writeBytesToZipFile(new FileInputStream(startfile), zos, startFilename);
for (File adeSchemaFile : jobDescriptor.getADESchemaFileList()) {
writeBytesToZipFile(new FileInputStream(adeSchemaFile), zos, adeSchemaFile.getName());
}
zos.close();
return zippedCityGMLFile;
} catch (FileNotFoundException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
} catch (IOException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
} else {
throw new InvalidJobDescriptorException();
}
return null;
}
......
......@@ -5,7 +5,6 @@
* all house numbers of all buildings of the product.
*
* @author Marcel Bruse
*
*/
public class Layer {
......@@ -18,6 +17,24 @@ public class Layer {
/** The style of this layer. Should be a color code (?). */
private String style;
/**
* The standard constructor.
*/
public Layer() {}
/**
* A convenience constructor for layers.
*
* @param name The name of the layer. This layer has to exist within the product.
* @param product The name of the product. This product has to exist in the database.
* @param style The purpose of this field is unknown.
*/
public Layer(String name, String product, String style) {
this.name = name;
this.product = product;
this.style = style;
}
/**
* @return Returns the name of the layer.
*/
......
package eu.simstadt.nf4j;
import java.io.File;
public class Main {
public static void main(String[] args) {
NFConnector connector = new NFConnectorImpl("193.196.136.164");
ExportJob job = connector.requestExportJob(584);
System.out.println(job.getJobId() + ": " + job.getStatus() + " - " + job.getStatus().getMessage());
public static void main(String[] args) {
//// ImportJobDescriptorImpl desc = ImportJobDescriptorImpl.getDefaultDescriptor();
//// desc.setProduct("WUDEV");
//// desc.setLeaf("820");
//// desc.setCityGMLFile(new File("WUDEV_820_GML.gml"));
//// desc.addADESchemaFile(new File("energy.xsd"));
//// System.out.println(desc.getCityGMLFile().canRead());
//
// NFConnectorImpl connector = new NFConnectorImpl("193.196.136.164");
//
// try {
//// ImportJob job = connector.sendImportJobFile(desc);
// ImportJob job = connector.requestImportJob(301);
// job.updateStatus();
// System.out.println(job.getJobId() + ": " + job.getStatus());
// } catch (FailedTransmissionException ex) {
// ex.printStackTrace();
// }
}
}
\ No newline at end of file
......@@ -6,8 +6,11 @@
* NFConnector lets you communicate with your novaFACTORY (nF) server instance.
*
* @author Marcel Bruse
*
* @param <I> The import job descriptor implementation for this connector.
* @param <E> The export job descriptor implementation for this connector.
*/
public interface NFConnector {
public interface NFConnector<I extends ImportJobDescriptor, E extends ExportJobDescriptor> {
/**
* Callers of this NFConnector want to know the actual version of the novaFACTORY and the versions of its
......@@ -22,17 +25,20 @@ public interface NFConnector {
public String supportsNFVersion();
/**
* Sends an export job to nF. The job has to be passed and to be described in an appropriate XML format.
* Sends an export job to nF. The job has to be passed to the nF in an appropriate XML job file.
* The DTD of the XML format can be obtained from the nF installation or documentation.
* The contents of the XML job file are detailed in a job descriptor.
*
* @param file The nF export job as a prepared XML file.
* @param jobDescriptor The nF export job description.
* @return The status of the job. Could be pending or failed.
*/
public ExportJob sendExportJobFile(File exportJobFile);
public ExportJob sendExportJobFile(E exportJobDescriptor)
throws InvalidJobDescriptorException, FailedTransmissionException;
/**
* Sends an import job to nF. The given import job file has to be a zip file and has to obey the internal
* structure defined in the nF manuals. Short description:
* Sends an import job to nF. A given import job descriptor has to describe the import job file. This
* method has to build the file and to zip it. The zip file has to obey the internal structure defined
* in the nF manuals. Short description:
*
* Import jobs enable you to add, alter and delete CityGML top level objects (like buildings) in the nF.
* Every import job file has to contain a start file. Start files control the import process through their
......@@ -56,7 +62,8 @@ public interface NFConnector {
* @param file The nF import job as a prepared ZIP file. It has to contain the CityGML file and the start file.
* @return Returns the job id of your import job or -1 if something went wrong.
*/
public ImportJob sendImportJobFile(File importJobFile);
public ImportJob sendImportJobFile(I importJobDescriptor)
throws InvalidJobDescriptorException, FailedTransmissionException;
/**
* Returns the status of any existing export nF job.
......@@ -64,7 +71,7 @@ public interface NFConnector {
* @param jobId The id of the export job for which you want to request the status.
* @return The status of any existing export nF job.
*/
public ExportJob requestExportJob(int jobId);
public ExportJob requestExportJob(int jobId) throws FailedTransmissionException;
/**
* Returns the status of any existing import nF job.
......@@ -72,7 +79,7 @@ public interface NFConnector {
* @param jobId The id of the import job for which you want to request the status.
* @return The status of any existing import nF job.
*/
public ImportJob requestImportJob(int jobId);
public ImportJob requestImportJob(int jobId) throws FailedTransmissionException;
/**
* Downloads the result for a given nF export job and hands over the corresponding file handle.
......@@ -80,6 +87,6 @@ public interface NFConnector {
* @param jobId The id of the export job for which the result should be loaded.
* @return A file handle to the result of the nF export job.
*/
public File requestExportJobResult(int jobId);
public File requestExportJobResult(int jobId) throws FailedTransmissionException;
}
......@@ -31,8 +31,11 @@
* For more technical details about the NFConnector interface @see NFConnector.
*
* @author Marcel Bruse
*
* @param <I> The import job descriptor implementation for this connector.
* @param <E> The export job descriptor implementation for this connector.
*/
public class NFConnectorImpl implements NFConnector {
public class NFConnectorImpl implements NFConnector<ImportJobDescriptorImpl, ExportJobDescriptorImpl> {
/** Supported version of the novaFACTORY. */
public static final String NOVA_FACTORY_VERSION = "6.3.1.1";
......@@ -132,17 +135,20 @@ public String supportsNFVersion() {
* @throws IOException An error occurred during the request. This could be a malformed URL or a network failure.
*/
@Override
public ExportJob requestExportJob(int jobId) {
ExportJob result = ExportJob.getNewInstance();
public ExportJob requestExportJob(int jobId) throws FailedTransmissionException {
ExportJob result = ExportJob.getNewInstance(this);
try {
List<String> parameters = Arrays.asList(buildParameter("jobid", jobId));
getJobFromResponse(result, getResponse(buildURL(REMOTE_STATUS_SERVLET, parameters)));
} catch (MalformedURLException ex) {
result.getStatus().setMessage(MALFORMED_URL);
throw new FailedTransmissionException(ex.getMessage());
} catch (IOException ex) {
result.getStatus().setMessage(IO_EXCEPTION_OCCURRED);
throw new FailedTransmissionException(ex.getMessage());
} catch (ParserConfigurationException | SAXException ex) {
result.getStatus().setMessage(XML_PARSER_ERROR);
throw new FailedTransmissionException(ex.getMessage());
}
return result;
}
......@@ -155,8 +161,8 @@ public ExportJob requestExportJob(int jobId) {
* @throws IOException An error occurred during the request. This could be a malformed URL or a network failure.
*/
@Override
public ImportJob requestImportJob(int jobId) {
ImportJob result = ImportJob.getUnkownInstance();
public ImportJob requestImportJob(int jobId) throws FailedTransmissionException {
ImportJob result = ImportJob.getNewInstance(this);
try {
List<String> parameters = Arrays.asList(
buildParameter("jobid", jobId),
......@@ -164,10 +170,13 @@ public ImportJob requestImportJob(int jobId) {
getJobFromResponse(result, getResponse(buildURL(REMOTE_IMPORT_SERVLET, parameters)));
} catch (MalformedURLException ex) {
result.getStatus().setMessage(MALFORMED_URL);
throw new FailedTransmissionException(ex.getMessage());
} catch (IOException ex) {
result.getStatus().setMessage(IO_EXCEPTION_OCCURRED);
throw new FailedTransmissionException(ex.getMessage());
} catch (ParserConfigurationException | SAXException ex) {
result.getStatus().setMessage(XML_PARSER_ERROR);
throw new FailedTransmissionException(ex.getMessage());
}
return result;
}
......@@ -179,7 +188,7 @@ public ImportJob requestImportJob(int jobId) {
* @return A file handle to the result of the nF export job.
*/
@Override
public File requestExportJobResult(int jobId) {
public File requestExportJobResult(int jobId) throws FailedTransmissionException {
File result = null;
try {
List<String> parameters = Arrays.asList(
......@@ -188,9 +197,9 @@ public File requestExportJobResult(int jobId) {
buildParameter("jobId", jobId));
result = downloadFile(buildURL(REMOTE_ORDER_SERVLET, parameters));
} catch (MalformedURLException ex) {
ex.printStackTrace();
throw new FailedTransmissionException(ex.getMessage());
} catch (IOException ex) {
ex.printStackTrace();
throw new FailedTransmissionException(ex.getMessage());
}
return result;
}
......@@ -351,10 +360,14 @@ private File downloadFile(URL url) throws IOException {
*
* @param file The XML file which describes the nF export job.
* @return Returns the status of the export job you just sent.
* @throws InvalidJobDescriptorException
*/
@Override
public ExportJob sendExportJobFile(File file) {
public ExportJob sendExportJobFile(ExportJobDescriptorImpl jobDescriptor)
throws InvalidJobDescriptorException, FailedTransmissionException {
ExportJob result = ExportJob.getNewInstance();
JobFileBuilderImpl jobFileBuilder = new JobFileBuilderImpl();
File exportJobFile = jobFileBuilder.buildExportJobFile(jobDescriptor);
try {
URL url = buildURL(REMOTE_ORDER_SERVLET, null);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
......@@ -366,7 +379,7 @@ public ExportJob sendExportJobFile(File file) {
connection.connect();
OutputStream os = connection.getOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, DEFAULT_CHARSET), true);
Files.copy(file.toPath(), os);
Files.copy(exportJobFile.toPath(), os);
os.flush();
writer.append(CRLF).flush();
getJobFromResponse(result, getResponse(connection));
......@@ -377,10 +390,13 @@ public ExportJob sendExportJobFile(File file) {
}
} catch (MalformedURLException ex) {
result.getStatus().setMessage(MALFORMED_URL);
throw new FailedTransmissionException(ex.getMessage());
} catch (IOException ex) {
result.getStatus().setMessage(IO_EXCEPTION_OCCURRED);
throw new FailedTransmissionException(ex.getMessage());
} catch (ParserConfigurationException | SAXException ex) {
result.getStatus().setMessage(XML_PARSER_ERROR);
throw new FailedTransmissionException(ex.getMessage());
}
return result;
}
......@@ -394,7 +410,7 @@ public ExportJob sendExportJobFile(File file) {
* file names and their contents. The name of a start file has the following structure
*
* <Product>_<Tile>.start
*
*
* The start file should contain the level to which your manipulated CityGML should be imported. Your CityGML
* file has to be named after the following naming convention:
*
......@@ -410,15 +426,19 @@ public ExportJob sendExportJobFile(File file) {
*
* @param file The nF import job as a prepared ZIP file. It has to contain the CityGML file and the start file.
* @return Returns the job status of your import job.
* @throws FailedTransmissionException
*/
@Override
public ImportJob sendImportJobFile(File importJobFile) {
ImportJob result = ImportJob.getUnkownInstance();
public ImportJob sendImportJobFile(ImportJobDescriptorImpl jobDescriptor)
throws InvalidJobDescriptorException, FailedTransmissionException {
ImportJob result = ImportJob.getNewInstance();
JobFileBuilderImpl jobFileBuilder = new JobFileBuilderImpl();
File importJobFile = jobFileBuilder.buildImportJobFile(jobDescriptor);
try {
List<String> parameters = Arrays.asList(
buildParameter("request", "imp"),
buildParameter("pdctKrz", "LBTEST"),
buildParameter("createjob", "1"));
buildParameter("request", "imp"), // trigger import
buildParameter("pdctKrz", "WUDEV"), // the nF product to import to
buildParameter("createjob", "1")); // force nF to create an import job with a job number
URL url = buildURL(REMOTE_IMPORT_SERVLET, parameters);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
......@@ -436,10 +456,13 @@ public ImportJob sendImportJobFile(File importJobFile) {
getJobFromResponse(result, getResponse(connection));
} catch (MalformedURLException ex) {
result.getStatus().setMessage(MALFORMED_URL);
throw new FailedTransmissionException(ex.getMessage());
} catch (IOException ex) {
result.getStatus().setMessage(IO_EXCEPTION_OCCURRED);
throw new FailedTransmissionException(ex.getMessage());
} catch (SAXException | ParserConfigurationException ex) {
result.getStatus().setMessage(XML_PARSER_ERROR);
throw new FailedTransmissionException(ex.getMessage());
}
return result;
}
......
package eu.simstadt.nf4j;
/**
* These are the known operation modes of the nF import servlet.
*
* @author Marcel Bruse
*/
public enum Operation {
REP, // Replaces whole existing buildings,
REPUPD, // Replaces whole existing buildings and adds new buildings,
UPD, // Update, same as REP,
CHG, // Change, same as REPUPD,
DEL, // Deletes the geometry of a particular LOD,
DELALL // Deletes a whole building
}
......@@ -23,8 +23,8 @@
import com.lynden.gmapsfx.javascript.object.MarkerOptions;
import eu.simstadt.nf4j.Coord;
import eu.simstadt.nf4j.ExportJobDescriptor;
import eu.simstadt.nf4j.JobBuilderImpl;
import eu.simstadt.nf4j.ExportJobDescriptorImpl;
import eu.simstadt.nf4j.JobFileBuilderImpl;
import eu.simstadt.nf4j.JobDescriptor;
import eu.simstadt.nf4j.Layer;
......@@ -116,10 +116,10 @@ protected String call() throws Exception {
layer.setName("GML");
layer.setProduct("LBTEST");
layer.setStyle("#000000");
ExportJobDescriptor jobDescriptor = ExportJobDescriptor.getDefaultDescriptor();
ExportJobDescriptorImpl jobDescriptor = ExportJobDescriptorImpl.getDefaultDescriptor();
jobDescriptor.addLayer(layer);
jobDescriptor.setRegionPolygon(regionPolygon);
JobBuilderImpl jobBuilder = new JobBuilderImpl();
JobFileBuilderImpl jobBuilder = new JobFileBuilderImpl();
return jobBuilder.buildExportJobFile(jobDescriptor).getAbsolutePath();
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment