Skip to content

Commit

Permalink
Merge pull request #23 from 52North/develop
Browse files Browse the repository at this point in the history
Merge develop
  • Loading branch information
bpross-52n authored Nov 21, 2018
2 parents 6af50dc + 148af1e commit 0f6102e
Show file tree
Hide file tree
Showing 302 changed files with 2,811 additions and 2,165 deletions.
29 changes: 13 additions & 16 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ This project includes:
52°North javaPS Webapp under The Apache Software License, Version 2.0
52°North Shetland under The Apache Software License, Version 2.0
52°North Svalbard Core under The Apache Software License, Version 2.0
AOP alliance under Public Domain
Animal Sniffer Annotations under MIT license
Apache Commons Codec under Apache License, Version 2.0
Apache Commons Configuration under Apache License, Version 2.0
Apache Commons Lang under The Apache Software License, Version 2.0
Apache Commons Logging under The Apache Software License, Version 2.0
Apache HttpClient under Apache License, Version 2.0
Apache HttpClient Fluent API under Apache License, Version 2.0
Apache HttpCore under Apache License, Version 2.0
Apache Log4j API under The Apache Software License, Version 2.0
Apache Log4j Core under The Apache Software License, Version 2.0
Expand All @@ -45,36 +44,34 @@ This project includes:
ClassLoader Leak Prevention library under Apache 2
Commons Lang under The Apache Software License, Version 2.0
Cross-Origin Resource Sharing (CORS) Filter under The Apache Software License, Version 2.0
error-prone annotations under Apache 2.0
EXIficient under MIT License
EXIficient-Core under MIT License
EXIficient-Grammars under MIT License
FindBugs-jsr305 under The Apache Software License, Version 2.0
Guava: Google Core Libraries for Java under The Apache Software License, Version 2.0
Hamcrest All under New BSD License
J2ObjC Annotations under The Apache Software License, Version 2.0
Jackson-annotations under The Apache Software License, Version 2.0
Jackson-core under The Apache Software License, Version 2.0
jackson-databind under The Apache Software License, Version 2.0
Java Property Utility under The Apache Software License, Version 2.0
Java Servlet API under CDDL 1.1 or GPL2 w/ CPE
javax.inject under The Apache Software License, Version 2.0
JCL 1.1.1 implemented over SLF4J under MIT License
JCL 1.2 implemented over SLF4J under MIT License
Joda-Time under Apache 2
JTS Topology Suite under Lesser General Public License (LGPL)
JUnit under Eclipse Public License 1.0
org.locationtech.jts:jts-core under Eclipse Publish License, Version 1.0 or Eclipse Distribution License - v 1.0
PJL Compressing Filter under Apache Software License V2.0
SLF4J API Module under MIT License
SLF4J Simple Binding under MIT License
Spring AOP under The Apache Software License, Version 2.0
Spring Beans under The Apache Software License, Version 2.0
Spring Context under The Apache Software License, Version 2.0
Spring Core under The Apache Software License, Version 2.0
Spring Expression Language (SpEL) under The Apache Software License, Version 2.0
Spring Web under The Apache Software License, Version 2.0
Spring Web MVC under The Apache Software License, Version 2.0
Spring AOP under Apache License, Version 2.0
Spring Beans under Apache License, Version 2.0
Spring Commons Logging Bridge under Apache License, Version 2.0
Spring Context under Apache License, Version 2.0
Spring Core under Apache License, Version 2.0
Spring Expression Language (SpEL) under Apache License, Version 2.0
Spring Web under Apache License, Version 2.0
Spring Web MVC under Apache License, Version 2.0
StAX API under The Apache Software License, Version 2.0
Xerces2-j under The Apache Software License, Version 2.0
XML Commons External Components XML APIs under The Apache Software License, Version 2.0 or The SAX License or The W3C License
xml-matchers under Apache License, Version 2.0
XmlBeans under The Apache Software License, Version 2.0
XMLUnit for Java under BSD License

2 changes: 1 addition & 1 deletion docs/documentation_markdown/site/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2017 52°North Initiative for Geospatial Open Source
Copyright 2016-2018 52°North Initiative for Geospatial Open Source
Software GmbH
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
8 changes: 4 additions & 4 deletions engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@

<dependencies>
<dependency>
<groupId>org.n52.janmayen</groupId>
<groupId>org.n52.arctic-sea</groupId>
<artifactId>janmayen</artifactId>
</dependency>
<dependency>
<groupId>org.n52.shetland</groupId>
<groupId>org.n52.arctic-sea</groupId>
<artifactId>shetland</artifactId>
</dependency>
<dependency>
<groupId>org.n52.faroe</groupId>
<groupId>org.n52.arctic-sea</groupId>
<artifactId>faroe-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.n52.iceland</groupId>
<groupId>org.n52.arctic-sea</groupId>
<artifactId>iceland</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,11 +22,10 @@

import org.n52.javaps.description.TypedProcessDescription;

public abstract class AbstractAlgorithm
extends AbstractObservable implements IAlgorithm {
public abstract class AbstractAlgorithm extends AbstractObservable implements IAlgorithm {

private final List<String> errorList = Collections.synchronizedList(new LinkedList<>());

private final List<String> errorList = Collections
.synchronizedList(new LinkedList<>());
private TypedProcessDescription description;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -30,7 +30,8 @@
public abstract class AbstractObservable implements ISubject {

private final List<IObserver> observers = Collections.synchronizedList(new LinkedList<>());
private Object state = null;

private Object state;

@Override
public void addObserver(IObserver o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -30,7 +30,7 @@
*/
public interface AlgorithmRepository extends Constructable, Destroyable {

public Set<OwsCode> getAlgorithmNames();
Set<OwsCode> getAlgorithmNames();

Optional<IAlgorithm> getAlgorithm(OwsCode id);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -35,13 +35,13 @@ public class ContextAlgorithmRegistrator implements Constructable {
private static final Logger LOG = LoggerFactory.getLogger(ContextAlgorithmRegistrator.class);

private LocalAlgorithmRepository repository;

private Context context;

@Override
public void init() {
Stream.concat(interfaceImplementations(), annotatedInstances())
.peek(algorithm -> LOG.info("Registering {}", algorithm))
.forEach(this.repository::addAlgorithm);
Stream.concat(interfaceImplementations(), annotatedInstances()).peek(algorithm -> LOG.info("Registering {}",
algorithm)).forEach(this.repository::addAlgorithm);
}

@Inject
Expand All @@ -62,6 +62,4 @@ private Stream<Object> annotatedInstances() {
return this.context.getAnnotatedInstances(Algorithm.class).stream();
}



}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,6 +18,7 @@

/**
* TODO JavaDoc
*
* @author Christian Autermann
*/
public class ExecutionException extends Exception {
Expand All @@ -38,9 +39,8 @@ public ExecutionException(Throwable cause) {
super(cause);
}

protected ExecutionException(String message, Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
protected ExecutionException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -51,17 +51,23 @@ public class LocalAlgorithmRepository implements AlgorithmRepository {
private static final Logger LOG = LoggerFactory.getLogger(LocalAlgorithmRepository.class);

private final Map<OwsCode, TypedProcessDescription> descriptions = new HashMap<>();

private final Map<OwsCode, Supplier<IAlgorithm>> algorithms = new HashMap<>();

private final InputHandlerRepository parserRepository;

private final OutputHandlerRepository generatorRepository;

private final LiteralTypeRepository literalTypeRepository;

private final AutowireCapableBeanFactory beanFactory;

private final String duplicateAlgorithmId = "Duplicate algorithm identifier: {}";

@Inject
public LocalAlgorithmRepository(InputHandlerRepository parserRepository,
OutputHandlerRepository generatorRepository,
LiteralTypeRepository literalTypeRepository,
ApplicationContext applicationContext) {
OutputHandlerRepository generatorRepository, LiteralTypeRepository literalTypeRepository,
ApplicationContext applicationContext) {
this.parserRepository = Objects.requireNonNull(parserRepository);
this.generatorRepository = Objects.requireNonNull(generatorRepository);
this.literalTypeRepository = Objects.requireNonNull(literalTypeRepository);
Expand Down Expand Up @@ -102,7 +108,7 @@ public void addAlgorithm(Class<?> clazz) {
instantiate(clazz).ifPresent(instance -> {
TypedProcessDescription description = instance.getDescription();
if (this.descriptions.put(description.getId(), description) != null) {
LOG.warn("Duplicate algorithm identifier: {}", description.getId());
LOG.warn(duplicateAlgorithmId, description.getId());
}
Supplier<Error> error = () -> new Error("Could not instantiate algorithm " + description.getId());
this.algorithms.put(description.getId(), () -> instantiate(clazz).orElseThrow(error));
Expand All @@ -115,7 +121,7 @@ public void addAlgorithm(IAlgorithm instance) {
Objects.requireNonNull(instance, "instance");
TypedProcessDescription description = instance.getDescription();
if (this.descriptions.put(description.getId(), description) != null) {
LOG.warn("Duplicate algorithm identifier: {}", description.getId());
LOG.warn(duplicateAlgorithmId, description.getId());
}
this.algorithms.put(description.getId(), () -> instance);
LOG.info("Algorithm {} with id {} registered", instance, description.getId());
Expand All @@ -127,13 +133,31 @@ public void addAlgorithm(Object object) {
addAlgorithm((IAlgorithm) object);
} else if (object instanceof Class<?>) {
addAlgorithm((Class<?>) object);
} else if (object!=null && object.getClass().isAnnotationPresent(Algorithm.class)) {
} else if (object.getClass().isAnnotationPresent(Algorithm.class)) {
addAlgorithm(new AnnotatedAlgorithm(parserRepository, generatorRepository, literalTypeRepository, object));
} else {
LOG.error("Could not add algorithm {}", object);
}
}

public boolean removeAlgorithm(String identifier) {

OwsCode owsCode = new OwsCode(identifier);

return removeAlgorithm(owsCode);
}

public boolean removeAlgorithm(OwsCode identifier) {

Supplier<IAlgorithm> removedAlgorithm = this.algorithms.remove(identifier);

if (removedAlgorithm != null) {
return true;
}

return false;
}

private Optional<IAlgorithm> instantiate(Class<?> clazz) {
Object instance;
try {
Expand All @@ -144,7 +168,8 @@ private Optional<IAlgorithm> instantiate(Class<?> clazz) {
}

if (clazz.isAnnotationPresent(Algorithm.class) && !(instance instanceof AnnotatedAlgorithm)) {
return Optional.of(new AnnotatedAlgorithm(parserRepository, generatorRepository, literalTypeRepository, instance));
return Optional.of(new AnnotatedAlgorithm(parserRepository, generatorRepository, literalTypeRepository,
instance));
} else if (instance instanceof IAlgorithm) {
return Optional.of((IAlgorithm) instance);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 52°North Initiative for Geospatial Open Source
* Copyright 2016-2018 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -31,13 +31,13 @@
import org.n52.javaps.description.TypedProcessInputDescription;
import org.n52.javaps.description.TypedProcessOutputDescription;


/**
* @author Bastian Schaeffer, University of Muenster
*
*/
public class RepositoryManager {
private final Set<OwsCode> globalProcessIDs = Collections.synchronizedSet(new HashSet<>());

private Set<AlgorithmRepository> repositories;

private Stream<AlgorithmRepository> getRepositories() {
Expand Down Expand Up @@ -73,16 +73,19 @@ public Optional<AlgorithmRepository> getRepositoryForAlgorithm(OwsCode id) {
return getRepositories().filter(repo -> repo.containsAlgorithm(id)).findFirst();
}

public Optional<TypedProcessInputDescription<?>> getInputForAlgorithm(OwsCode process, OwsCode input) {
public Optional<TypedProcessInputDescription<?>> getInputForAlgorithm(OwsCode process,
OwsCode input) {
return getProcessDescription(process).map(x -> x.getInput(input));

}

public Optional<TypedProcessOutputDescription<?>> getOutputForAlgorithm(OwsCode process, OwsCode output) {
public Optional<TypedProcessOutputDescription<?>> getOutputForAlgorithm(OwsCode process,
OwsCode output) {
return getProcessDescription(process).map(x -> x.getOutput(output));
}

public boolean registerAlgorithm(OwsCode id, AlgorithmRepository repository) {
public boolean registerAlgorithm(OwsCode id,
AlgorithmRepository repository) {
return globalProcessIDs.add(id);
}

Expand Down
Loading

0 comments on commit 0f6102e

Please sign in to comment.