Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
removed outdated classes form 52n-wps-ags module; restructured internal
Browse files Browse the repository at this point in the history
classes
  • Loading branch information
matthias-mueller committed Jan 27, 2015
1 parent dc1b0fd commit b87ae79
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 365 deletions.
Expand Up @@ -43,10 +43,10 @@
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.n52.wps.ags.feed.movingcode.AlgorithmParameterType;
import org.n52.wps.ags.feed.movingcode.CommandLineParameter;
import org.n52.wps.ags.feed.movingcode.MovingCodeObject;
import org.n52.wps.ags.feed.movingcode.MovingCodeUtils;
import org.n52.wps.ags.algorithmpackage.AlgorithmPackage;
import org.n52.wps.ags.algorithmpackage.AlgorithmParameterType;
import org.n52.wps.ags.algorithmpackage.CommandLineParameter;
import org.n52.wps.ags.algorithmpackage.PackageUtils;
import org.n52.wps.ags.workspace.AGSWorkspace;
import org.n52.wps.io.data.GenericFileDataWithGT;
import org.n52.wps.io.data.GenericFileDataConstants;
Expand All @@ -66,13 +66,13 @@ public class ArcToolboxProcessDelegator implements IAlgorithm{
private final File toolWorkspace;
private final File workspaceBase;

private MovingCodeObject mco;
private AlgorithmPackage mco;
protected List<String> errors;

private String[] toolParameters;


protected ArcToolboxProcessDelegator(MovingCodeObject templateMCO, File workspaceBase) throws IOException{
protected ArcToolboxProcessDelegator(AlgorithmPackage templateMCO, File workspaceBase) throws IOException{
this.workspaceBase = workspaceBase;
errors = new ArrayList<String>();
mco = templateMCO.createChild(workspaceBase);
Expand Down Expand Up @@ -117,7 +117,7 @@ public Map<String, IData> run(Map<String, List<IData>> inputData) {
while (it.hasNext()){
IData currentItem = it.next();
// load as file and add to CommanLineParameter
cmdParam.addValue((MovingCodeUtils.loadSingleDataItem(currentItem, toolWorkspace)));
cmdParam.addValue((PackageUtils.loadSingleDataItem(currentItem, toolWorkspace)));
}
}
} else if (!wpsOutputID.equalsIgnoreCase("")){ // output only parameters !!ONLY SINGLE OUTPUT ITEMS SUPPORTED BY WPS!!
Expand Down Expand Up @@ -201,11 +201,11 @@ public boolean processDescriptionIsValid() {
}

public Class<?> getInputDataType(String id) {
return MovingCodeUtils.getInputDataType(mco, id);
return PackageUtils.getInputDataType(mco, id);
}

public Class<?> getOutputDataType(String id) {
return MovingCodeUtils.getOutputDataType(mco, id);
return PackageUtils.getOutputDataType(mco, id);
}

//delete the current workspace
Expand Down
Expand Up @@ -41,8 +41,7 @@
import net.opengis.wps.x100.ProcessDescriptionType;

import org.n52.wps.PropertyDocument.Property;
import org.n52.wps.ags.feed.FeedRepository;
import org.n52.wps.ags.feed.movingcode.MovingCodeObject;
import org.n52.wps.ags.algorithmpackage.AlgorithmPackage;
import org.n52.wps.commons.WPSConfig;
import org.n52.wps.server.IAlgorithm;
import org.n52.wps.server.IAlgorithmRepository;
Expand All @@ -62,7 +61,7 @@ public class ArcToolboxProcessRepository implements IAlgorithmRepository{
private static final String PROPERTY_BACKEND_URN = "BACKEND_URN";
private static final String PROPERTY_WORKSPACEBASE = "WORKSPACEBASE";

private HashMap<String, MovingCodeObject> registeredAlgorithms;
private HashMap<String, AlgorithmPackage> registeredAlgorithms;
private URI[] supportedContainers;
private URI[] supportedBackends;
private File workspaceBase = null;
Expand All @@ -75,19 +74,18 @@ public ArcToolboxProcessRepository() {
LOGGER.info("Initializing ArcToolbox Process Repository ...");

//initialize local variables
registeredAlgorithms = new HashMap<String, MovingCodeObject>();
registeredAlgorithms = new HashMap<String, AlgorithmPackage>();
try{
loadConfiguration();
loadLocalProcesses();
loadFeedProcesses();
} catch (Exception e){
LOGGER.error("Could not initialize ArcToolbox Process Repository.");
}

// check if workspaceBase is specified
if (workspaceBase == null){
LOGGER.error("Workspace base is missing: Clearing my Process Inventory");
registeredAlgorithms = new HashMap<String, MovingCodeObject>();
registeredAlgorithms = new HashMap<String, AlgorithmPackage>();
}

// log active Processes ...
Expand Down Expand Up @@ -149,7 +147,7 @@ private void loadLocalProcesses(){
// create new MovingCodeObjects
for (String currentFileName : describeProcessFiles){
File currentFile = new File (inventoryDir.getAbsolutePath() + File.separator + currentFileName);
MovingCodeObject currentMCO = new MovingCodeObject(currentFile, inventoryDir);
AlgorithmPackage currentMCO = new AlgorithmPackage(currentFile, inventoryDir);
if (isSupportedScript(currentMCO)){
registeredAlgorithms.put(currentMCO.getProcessID(), currentMCO);
} else {
Expand All @@ -159,16 +157,7 @@ private void loadLocalProcesses(){
}
}

private void loadFeedProcesses(){
// retrieve supported MCOs from the feed
MovingCodeObject[] feedMCOs = FeedRepository.getInstance().getMovingCodeObjects(supportedContainers, supportedBackends);
for (MovingCodeObject currentMCO : feedMCOs){
// add those algorithms to this Repository
registeredAlgorithms.put(currentMCO.getProcessID(), currentMCO);
}
}

private boolean isSupportedScript(MovingCodeObject mco){
private boolean isSupportedScript(AlgorithmPackage mco){
boolean rightContainer = false;
boolean rightBackends = false;
for (URI currentContainer : supportedContainers){
Expand Down
Expand Up @@ -34,7 +34,7 @@
//


package org.n52.wps.ags.feed.movingcode;
package org.n52.wps.ags.algorithmpackage;

import java.util.ArrayList;
import java.util.List;
Expand Down
Expand Up @@ -26,7 +26,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*/
package org.n52.wps.ags.feed.movingcode;
package org.n52.wps.ags.algorithmpackage;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -62,15 +62,15 @@
* @author Matthias Mueller, TU Dresden
*
*/
public class MovingCodeObject {
public class AlgorithmPackage {
private final File algorithmWorkspace;

private ProcessDescriptionType processDescription;
private AlgorithmDescription algorithmDescription;

static Logger LOGGER = LoggerFactory.getLogger(MovingCodeObject.class);
static Logger LOGGER = LoggerFactory.getLogger(AlgorithmPackage.class);

public MovingCodeObject (ProcessDescriptionType pd, AlgorithmDescription ad, File algorithmWorkspace){
public AlgorithmPackage (ProcessDescriptionType pd, AlgorithmDescription ad, File algorithmWorkspace){

// create descriptions
algorithmDescription = ad;
Expand All @@ -81,7 +81,7 @@ public MovingCodeObject (ProcessDescriptionType pd, AlgorithmDescription ad, Fil

}

public MovingCodeObject (File processDescriptionXML, File workspaceTemplateRoot){
public AlgorithmPackage (File processDescriptionXML, File workspaceTemplateRoot){

// create descriptions
processDescription = createProcessDescription(processDescriptionXML);
Expand All @@ -99,10 +99,10 @@ public MovingCodeObject (File processDescriptionXML, File workspaceTemplateRoot)
algorithmWorkspace = new File(wsDirString);
}

public MovingCodeObject createChild (File destinationRoot) throws IOException{
public AlgorithmPackage createChild (File destinationRoot) throws IOException{
FileUtils.copyDirectoryToDirectory(algorithmWorkspace, destinationRoot);
File wsDir = new File(destinationRoot.getAbsolutePath() + File.separator + getWorkspacePathFragment());
MovingCodeObject child = new MovingCodeObject(processDescription, algorithmDescription, wsDir);
AlgorithmPackage child = new AlgorithmPackage(processDescription, algorithmDescription, wsDir);
return child;
}

Expand Down
Expand Up @@ -34,7 +34,7 @@
//


package org.n52.wps.ags.feed.movingcode;
package org.n52.wps.ags.algorithmpackage;

import java.math.BigInteger;
import javax.xml.bind.annotation.XmlAccessType;
Expand Down
Expand Up @@ -26,7 +26,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*/
package org.n52.wps.ags.feed.movingcode;
package org.n52.wps.ags.algorithmpackage;

import java.net.URI;

Expand Down
Expand Up @@ -26,7 +26,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*/
package org.n52.wps.ags.feed.movingcode;
package org.n52.wps.ags.algorithmpackage;

import java.util.LinkedList;

Expand Down
Expand Up @@ -26,7 +26,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*/
package org.n52.wps.ags.feed.movingcode;
package org.n52.wps.ags.algorithmpackage;

import java.io.File;

Expand All @@ -46,9 +46,9 @@
* @author Matthias Mueller, TU Dresden
*
*/
public class MovingCodeUtils {
public class PackageUtils {

public static Class getInputDataType(MovingCodeObject mco, String id) {
public static Class getInputDataType(AlgorithmPackage mco, String id) {
InputDescriptionType[] inputs = mco.getProcessDescription().getDataInputs().getInputArray();

for(InputDescriptionType input : inputs){
Expand Down Expand Up @@ -88,7 +88,7 @@ public static Class getInputDataType(MovingCodeObject mco, String id) {
return null;
}

public static Class getOutputDataType(MovingCodeObject mco, String id) {
public static Class getOutputDataType(AlgorithmPackage mco, String id) {
OutputDescriptionType[] outputs = mco.getProcessDescription().getProcessOutputs().getOutputArray();

for(OutputDescriptionType output : outputs){
Expand Down

0 comments on commit b87ae79

Please sign in to comment.