0

I want to develope a wps process by 52 north and I shoud use org.n52.wps.server.AbstractSelfDescribingAlgorithm so this class is inherit from net.opengis.wps.x100.ProcessDescriptionType. My question is that which jar file contain this type and please tell me the url for download this jar file?! My code is:

package www.gise.cse.iitb.ac.in;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.n52.wps.io.data.IData;
import org.n52.wps.io.data.binding.literal.LiteralDoubleBinding;
import org.n52.wps.server.AbstractSelfDescribingAlgorithm;

public class AddNumbersAlgo extends org.n52.wps.server.AbstractSelfDescribingAlgorithm {

@Override
public Class getInputDataType(String arg0) {
    // TODO Auto-generated method stub
    if (arg0.equals("Num1")){
        //return GTVectorDataBinding.class;
        return LiteralDoubleBinding.class;
    }
    if (arg0.equals("Num2")){
        //return GTVectorDataBinding.class;
        return LiteralDoubleBinding.class;
    }
    throw new RuntimeException("Error: WrongIdentifier");
}

@Override
public Class getOutputDataType(String arg0) {
    // TODO Auto-generated method stub
    if(arg0.equals("AdditionResult")){
        return LiteralDoubleBinding.class;
    }
    throw new RuntimeException("Error: Wrong identifier");
}
@Override
public Map<String, IData> run(Map<String, List<IData>> arg0) {

    if (arg0 == null || !arg0.containsKey("Num1")){
        throw new RuntimeException("Error: While allocating Input Parameters");
    }
    if (arg0 == null || !arg0.containsKey("Num2")){
        throw new RuntimeException("Error: While allocating Input Parameters");
    }
    List<IData> datalist = arg0.get("Num1");
    if(datalist == null || datalist.size()!=1){
        throw new RuntimeException("Error:While allocating Input Parameters");
    }

    //Checking for correctness of input
    List<IData> datalist1 = arg0.get("Num2");
    if(datalist1 == null || datalist1.size()!=1){
        throw new RuntimeException("Error:While allocating Input Parameters");
    }
    //Extracting input
            IData Num1 = datalist.get(0);
            double firstNum = ((LiteralDoubleBinding)Num1).getPayload();
            System.out.println(Num1);
            System.out.println(firstNum);

            IData Num2 = datalist1.get(0);
            double secondNum = ((LiteralDoubleBinding)Num2).getPayload();
            System.out.println(Num2);
            System.out.println(secondNum);

            double Result = firstNum + secondNum;
            //double AdditionResult;
            //create the response. In this case a GenericFileDataBinding is used (see this.getOutputDataType(...)
            IData AdditionResult = new LiteralDoubleBinding(Result);

            //new Map created
            Map<String, IData> resultMap = new HashMap<String, IData>();
            //created response added to corresponding identifier (see this.getOutputIdentifiers())
            resultMap.put("AdditionResult", AdditionResult);

            return resultMap;
}

@Override
public List<String> getInputIdentifiers() {
    // TODO Auto-generated method stub
    List<String> identifiers = new ArrayList<String>();
    identifiers.add("Num1");
    identifiers.add("Num2");
    return identifiers;
}

@Override
public List<String> getOutputIdentifiers() {
    // TODO Auto-generated method stub
    List<String> identifiers = new ArrayList<String>();
    identifiers.add("AdditionResult");
    return identifiers;
}

and error is:

Multiple markers at this line

  • The type net.opengis.wps.x100.ProcessDescriptionType cannot be resolved. It is indirectly referenced from required .class files

  • The type net.opengis.wps.x100.ProcessDescriptionType cannot be resolved. It is indirectly referenced from required .class files

vip
  • 1,707
  • 2
  • 16
  • 46
iman.tv
  • 97
  • 4
  • 12

2 Answers2

2

I would recommend using a maven-managed project. All required artifacts to create such a project are on the public 52north maven repository (including the XML bindings library you mentioned). The following pom.xml should serve well as a project skeleton. It already has the aforementioned maven repository included.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my.test.wps-project</groupId>
    <artifactId>wps</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.n52.wps</groupId>
            <artifactId>52n-wps-io</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.n52.wps</groupId>
            <artifactId>52n-wps-algorithm</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>n52-releases</id>
            <name>n52-releases</name>
            <url>http://52north.org/maven/repo/releases/</url>
        </repository>
    </repositories>
</project>

In general, artifacts of a maven-managed open source project should be accessible on a dedicated or central repository. Otherwise the projects build setup would not be satisfied. So, a general advice would be to first do some investigation on the project structure.

matthes
  • 2,972
  • 3
  • 15
  • 18
1

It is hard to find any jars containing what you are searching for.

I found a subversion repository with the files in it. So I

Now you have the jar file:

target/wps-1.0.0.jar

It is not optimal that you'll have to build it yourself but it solves the problem.

Your code may depend on other jar files as well but I guess that those are in the same repo.

maba
  • 47,113
  • 10
  • 108
  • 118
  • tnx but I download it before and there is not type like: >net.opengis.wps.x100.ProcessDescriptionType but there is something like >net.opengis.wps10.ProcessDescriptionType and I use it but it didnt solve error – iman.tv Apr 17 '13 at 15:36
  • thanks but by running _mvn package_ this responce occured: [ERROR] FATAL ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error building POM (may not be this project's POM). Project ID: net.opengeospatial.wps:wps:jar:1.0.0 Reason: Cannot find parent: cn.geodata.models:references for project: net.openg ospatial.wps:wps:jar:1.0.0 for project net.opengeospatial.wps:wps:jar:1.0.0 – iman.tv Apr 17 '13 at 19:30
  • @iman.tv I see. Checkout everything from trunk level. Build from that level using 'mvn install'. It will probably fail after a while (did for me). Then move down to reference directory and build from there. – maba Apr 17 '13 at 19:47
  • in fact, the above mentioned google code project does serve the net.opengis.wps.* java files. As these are obviously generated XMLBeans bindings, I would recommend to use pre-compiled .jar libraries and not the sources of these. You will never have to change a bit of them and the source code even does not provide valuable insights. – matthes Apr 18 '13 at 08:05
  • @matthes You're right. I prefer your solution. The problem was that is was very hard to find any repositories serving the files. I have never worked with any of these projects so I tried to help him to solve the problem at hand. I often search on mvnrepository.com and your code is not present there. – maba Apr 18 '13 at 08:17
  • @maba of course, I would have followed your approach as well if I would not have known the project. So, I just wanted to add the _insder_ knowledge ;) makes life a bit easier. – matthes Apr 18 '13 at 08:21
  • @iman.tv You should accept matthes answer instead of mine. His solution is the prefered and correct answer. – maba Apr 18 '13 at 08:21