Skip to content

Commit

Permalink
added ows:Metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
autermann committed Jun 20, 2016
1 parent 7cb3c6e commit edf89fa
Show file tree
Hide file tree
Showing 25 changed files with 308 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.n52.iceland.ogc.ows.OwsCodeType;
import org.n52.javaps.ogc.ows.OwsKeyword;
import org.n52.javaps.ogc.ows.OwsLanguageString;
import org.n52.javaps.ogc.ows.OwsMetadata;


/**
Expand All @@ -39,4 +40,5 @@ public interface Description {

Set<OwsKeyword> getKeywords();

Set<OwsMetadata> getMetadata();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.n52.iceland.ogc.ows.OwsCodeType;
import org.n52.javaps.ogc.ows.OwsKeyword;
import org.n52.javaps.ogc.ows.OwsLanguageString;
import org.n52.javaps.ogc.ows.OwsMetadata;

/**
* TODO JavaDoc
Expand Down Expand Up @@ -86,4 +87,6 @@ default B withKeyword(String keyword) {
return withKeyword(new OwsKeyword(keyword));
}

B withMetadata(OwsMetadata metadata);

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import java.util.Set;

import org.n52.iceland.ogc.ows.OwsCodeType;
import org.n52.javaps.description.Description;
import org.n52.javaps.ogc.ows.OwsKeyword;
import org.n52.javaps.ogc.ows.OwsLanguageString;
import org.n52.javaps.description.Description;
import org.n52.javaps.ogc.ows.OwsMetadata;

/**
* TODO JavaDoc
Expand All @@ -37,13 +38,15 @@ public abstract class AbstractDescription implements Description {
private final OwsLanguageString title;
private final OwsLanguageString abstrakt;
private final Set<OwsKeyword> keywords;
private final Set<OwsMetadata> metadata;

public AbstractDescription(AbstractDescriptionBuilder<?, ?> builder) {
this.id = Objects.requireNonNull(builder.getId(), "id");
this.title = builder.getTitle() != null ? builder.getTitle()
: new OwsLanguageString(builder.getId().getValue());
this.abstrakt = builder.getAbstract();
this.keywords = builder.getKeywords();
this.metadata = builder.getMetadata();
}

@Override
Expand All @@ -53,7 +56,7 @@ public OwsCodeType getId() {

@Override
public OwsLanguageString getTitle() {
return title;
return this.title;
}

@Override
Expand All @@ -65,4 +68,11 @@ public Optional<OwsLanguageString> getAbstract() {
public Set<OwsKeyword> getKeywords() {
return Collections.unmodifiableSet(this.keywords);
}

@Override
public Set<OwsMetadata> getMetadata() {
return Collections.unmodifiableSet(this.metadata);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
import java.util.Set;

import org.n52.iceland.ogc.ows.OwsCodeType;
import org.n52.javaps.ogc.ows.OwsKeyword;
import org.n52.javaps.ogc.ows.OwsLanguageString;
import org.n52.javaps.description.Description;
import org.n52.javaps.description.DescriptionBuilder;
import org.n52.javaps.ogc.ows.OwsKeyword;
import org.n52.javaps.ogc.ows.OwsLanguageString;
import org.n52.javaps.ogc.ows.OwsMetadata;

import com.google.common.collect.ImmutableSet;

Expand All @@ -41,6 +42,7 @@ public abstract class AbstractDescriptionBuilder<T extends Description, B extend
private OwsLanguageString title;
private OwsLanguageString abstrakt;
private final ImmutableSet.Builder<OwsKeyword> keywords = ImmutableSet.builder();
private final ImmutableSet.Builder<OwsMetadata> metadata = ImmutableSet.builder();

@SuppressWarnings(value = "unchecked")
@Override
Expand Down Expand Up @@ -70,19 +72,32 @@ public B withKeyword(OwsKeyword keyword) {
return (B) this;
}

@Override
@SuppressWarnings("unchecked")
public B withMetadata(OwsMetadata metadata) {
this.metadata.add(Objects.requireNonNull(metadata));
return (B) this;
}

OwsCodeType getId() {
return id;
return this.id;
}

OwsLanguageString getTitle() {
return title;
return this.title;
}

OwsLanguageString getAbstract() {
return abstrakt;
return this.abstrakt;
}

Set<OwsKeyword> getKeywords() {
return keywords.build();
return this.keywords.build();
}

Set<OwsMetadata> getMetadata() {
return this.metadata.build();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.n52.javaps.ogc.ows;

import java.net.URI;
import java.util.Objects;
import java.util.Optional;

import org.n52.javaps.ogc.w3c.xlink.XLink;


/**
* TODO JavaDoc
* @author Christian Autermann
*/
public class OwsMetadata extends XLink {
private Optional<URI> about = Optional.empty();

public Optional<URI> getAbout() {
return about;
}

public void setAbout(Optional<URI> about) {
this.about = about;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final OwsMetadata other = (OwsMetadata) obj;

return super.equals(obj) && Objects.equals(getAbout(), other.getAbout());
}

@Override
public int hashCode() {
return 53 * super.hashCode() + Objects.hashCode(getAbout());
}

}
120 changes: 120 additions & 0 deletions processing-api/src/main/java/org/n52/javaps/ogc/w3c/xlink/XLink.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package org.n52.javaps.ogc.w3c.xlink;

import java.net.URI;
import java.util.Objects;
import java.util.Optional;

import com.google.common.base.Strings;

/**
* TODO JavaDoc
*
* @author Christian Autermann
*/
public class XLink {
private Optional<URI> href = Optional.empty();
private Optional<URI> role = Optional.empty();
private Optional<URI> arcrole = Optional.empty();
private Optional<String> title = Optional.empty();
private Optional<Show> show = Optional.empty();
private Optional<Actuate> actuate = Optional.empty();

public Optional<URI> getHref() {
return this.href;
}

public void setHref(URI href) {
this.href = Optional.ofNullable(href);
}

public Optional<URI> getRole() {
return role;
}

public void setRole(URI role) {
this.role = Optional.ofNullable(role);
}

public Optional<URI> getArcrole() {
return arcrole;
}

public void setArcrole(URI arcrole) {
this.arcrole = Optional.ofNullable(arcrole);
}

public Optional<String> getTitle() {
return title;
}

public void setTitle(String title) {
this.title = Optional.ofNullable(Strings.emptyToNull(title));
}

public Optional<Show> getShow() {
return show;
}

public void setShow(Show show) {
this.show = Optional.ofNullable(show);
}

public Optional<Actuate> getActuate() {
return actuate;
}

public void setActuate(Actuate actuate) {
this.actuate = Optional.ofNullable(actuate);
}

@Override
public int hashCode() {
return Objects.hash(getHref(), getRole(), getArcrole(),
getTitle(), getShow(), getActuate());
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final XLink other = (XLink) obj;
return Objects.equals(this.getHref(), other.getHref()) &&
Objects.equals(this.getRole(), other.getRole()) &&
Objects.equals(this.getArcrole(), other.getArcrole()) &&
Objects.equals(this.getTitle(), other.getTitle()) &&
Objects.equals(this.getShow(), other.getShow()) &&
Objects.equals(this.getActuate(), other.getActuate());
}

public enum Type {
SIMPLE,
EXTENDED,
LOCATOR,
ARC,
RESOURCE,
TITLE,
NONE
}

public enum Show {
NEW,
REPLACE,
EMBED,
OTHER,
NONE;
}

public enum Actuate {
ON_LOAD,
ON_REQUEST,
OTHER,
NONE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import org.n52.iceland.util.KvpHelper;
import org.n52.javaps.ogc.wps.WPS100Constants;
import org.n52.javaps.ogc.wps.WPSConstants;
import org.n52.javaps.request.DescribeProcessRequest;
import org.n52.javaps.request.WpsDescribeProcessRequest;

public class DescribeProcessKvpDecoder extends AbstractKvpDecoder<DescribeProcessRequest> {
public class DescribeProcessKvpDecoder extends AbstractKvpDecoder<WpsDescribeProcessRequest> {
private static final DecoderKey KEY
= createKey(WPSConstants.SERVICE,
WPS100Constants.SERVICEVERSION,
Expand All @@ -39,12 +39,12 @@ public Set<DecoderKey> getKeys() {
}

@Override
protected DescribeProcessRequest createRequest() {
return new DescribeProcessRequest();
protected WpsDescribeProcessRequest createRequest() {
return new WpsDescribeProcessRequest();
}

@Override
protected void decodeParameter(DescribeProcessRequest request, String name,
protected void decodeParameter(WpsDescribeProcessRequest request, String name,
String value)
throws OwsExceptionReport {
switch (name.toLowerCase()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
package org.n52.javaps.coding.stream.xml;

import java.io.OutputStream;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Iterator;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

import javax.xml.namespace.QName;
Expand Down Expand Up @@ -70,6 +73,19 @@ protected void attr(QName name, String value)
this.context.dispatch(this.eventFactory.createAttribute(name, value));
}

protected void attr(QName name, Optional<String> value)
throws XMLStreamException {
if (value.isPresent()) {
attr(name, value.get());

}
}

protected void attr(String name, Optional<String> value)
throws XMLStreamException {
attr(new QName(name), value);
}

protected void attr(String name, String value)
throws XMLStreamException {
attr(new QName(name), value);
Expand All @@ -83,7 +99,8 @@ protected void attr(String namespace, String localName, String value)
protected void namespace(String prefix, String namespace)
throws XMLStreamException {
if (this.context.declareNamespace(prefix, namespace)) {
this.context.dispatch(this.eventFactory.createNamespace(prefix, namespace));
this.context.dispatch(this.eventFactory
.createNamespace(prefix, namespace));
}
}

Expand Down Expand Up @@ -116,7 +133,8 @@ protected void chars(String chars)

protected void chars(String chars, boolean escape)
throws XMLStreamException {
this.context.dispatch(this.eventFactory.createCharacters(escape ? escaper()
this.context.dispatch(this.eventFactory.createCharacters(escape
? escaper()
.escape(chars) : chars));
}

Expand Down Expand Up @@ -202,6 +220,11 @@ protected void element(QName name, String value)
end(name);
}

protected void element(QName name, OffsetDateTime time)
throws XMLStreamException {
element(name, DateTimeFormatter.ISO_DATE_TIME.format(time));
}

protected <T> void delegate(T object)
throws XMLStreamException {
this.context.write(object);
Expand Down
Loading

0 comments on commit edf89fa

Please sign in to comment.