-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed endpoints from ControllerApiBackend (edge --> backend): - UpdateUserLanguage (Threw error NotImplemented) - UpdateUserSettings (Threw error NotImplemented) Added endpoint to RestApi: - queryHistoricTimeseriesEnergyPerPeriod - queryHistoricTimeseriesExportXlxs Reviewed-by: Hueseyin Sahutoglu <[email protected]> Co-authored-by: Michael Grill <[email protected]>
- Loading branch information
1 parent
c78334d
commit 348f59d
Showing
167 changed files
with
6,463 additions
and
2,459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
io.openems.common/src/io/openems/common/exceptions/OpenemsRuntimeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.openems.common.exceptions; | ||
|
||
public class OpenemsRuntimeException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = -4509666272212124910L; | ||
|
||
public OpenemsRuntimeException() { | ||
super(); | ||
} | ||
|
||
public OpenemsRuntimeException(String message, Throwable cause, boolean enableSuppression, | ||
boolean writableStackTrace) { | ||
super(message, cause, enableSuppression, writableStackTrace); | ||
} | ||
|
||
public OpenemsRuntimeException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public OpenemsRuntimeException(String message) { | ||
super(message); | ||
} | ||
|
||
public OpenemsRuntimeException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
io.openems.common/src/io/openems/common/jsonrpc/serialization/JsonArrayPath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.openems.common.jsonrpc.serialization; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
public interface JsonArrayPath extends JsonPath { | ||
|
||
/** | ||
* Gets the elements as a list parsed to the object. | ||
* | ||
* @param <T> the type of the objects | ||
* @param mapper the {@link JsonElement} to object mapper | ||
* @return the list with the parsed values | ||
*/ | ||
public <T> List<T> getAsList(Function<JsonElementPath, T> mapper); | ||
|
||
/** | ||
* Gets the elements as a list parsed to the object. | ||
* | ||
* @param <T> the type of the objects | ||
* @param serializer the {@link JsonSerializer} to deserialize the elements | ||
* @return the list with the parsed values | ||
*/ | ||
public default <T> List<T> getAsList(JsonSerializer<T> serializer) { | ||
return this.getAsList(serializer::deserializePath); | ||
} | ||
|
||
/** | ||
* Gets the current element of the path. | ||
* | ||
* @return the {@link JsonObject} | ||
*/ | ||
public JsonArray get(); | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
io.openems.common/src/io/openems/common/jsonrpc/serialization/JsonArrayPathActual.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.openems.common.jsonrpc.serialization; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
|
||
import io.openems.common.exceptions.OpenemsRuntimeException; | ||
import io.openems.common.utils.JsonUtils; | ||
|
||
public class JsonArrayPathActual implements JsonArrayPath { | ||
|
||
private final JsonArray object; | ||
|
||
public JsonArrayPathActual(JsonElement object) { | ||
if (!object.isJsonArray()) { | ||
throw new OpenemsRuntimeException(object + " is not a JsonArray!"); | ||
} | ||
this.object = object.getAsJsonArray(); | ||
} | ||
|
||
@Override | ||
public <T> List<T> getAsList(Function<JsonElementPath, T> mapper) { | ||
return JsonUtils.stream(this.object) // | ||
.map(JsonElementPathActual::new) // | ||
.map(mapper) // | ||
.toList(); | ||
} | ||
|
||
@Override | ||
public JsonArray get() { | ||
return this.object; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
io.openems.common/src/io/openems/common/jsonrpc/serialization/JsonArrayPathDummy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.openems.common.jsonrpc.serialization; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
|
||
import io.openems.common.utils.JsonUtils; | ||
|
||
public class JsonArrayPathDummy implements JsonArrayPath, JsonPathDummy { | ||
|
||
private JsonPathDummy elementType; | ||
|
||
@Override | ||
public <T> List<T> getAsList(Function<JsonElementPath, T> mapper) { | ||
final var path = new JsonElementPathDummy(); | ||
mapper.apply(path); | ||
this.elementType = path; | ||
return emptyList(); | ||
} | ||
|
||
@Override | ||
public JsonArray get() { | ||
return new JsonArray(); | ||
} | ||
|
||
@Override | ||
public JsonElement buildPath() { | ||
return JsonUtils.buildJsonObject() // | ||
.addProperty("type", "array") // | ||
.onlyIf(this.elementType != null, t -> t.add("elementType", this.elementType.buildPath())) // | ||
.build(); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
io.openems.common/src/io/openems/common/jsonrpc/serialization/JsonElementPath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.openems.common.jsonrpc.serialization; | ||
|
||
import com.google.gson.JsonElement; | ||
|
||
public interface JsonElementPath extends JsonPath { | ||
|
||
/** | ||
* Gets the current {@link JsonElementPath} as a {@link JsonObjectPath}. | ||
* | ||
* @return the current element as a {@link JsonObjectPath} | ||
*/ | ||
public JsonObjectPath getAsJsonObjectPath(); | ||
|
||
/** | ||
* Gets the current {@link JsonElementPath} as a {@link JsonArrayPath}. | ||
* | ||
* @return the current element as a {@link JsonArrayPath} | ||
*/ | ||
public JsonArrayPath getAsJsonArrayPath(); | ||
|
||
/** | ||
* Gets the current {@link JsonElementPath} as a {@link StringPath}. | ||
* | ||
* @return the current element as a {@link StringPath} | ||
*/ | ||
public StringPath getAsStringPath(); | ||
|
||
/** | ||
* Gets the current {@link JsonElementPath} as a {@link String}. | ||
* | ||
* @return the current element as a {@link String} | ||
*/ | ||
public default String getAsString() { | ||
return this.getAsStringPath().get(); | ||
} | ||
|
||
/** | ||
* Gets the current {@link JsonElementPath} as a Object serialized with the | ||
* provided {@link JsonSerializer}. | ||
* | ||
* @param <O> the type of the final object | ||
* @param serializer the {@link JsonSerializer} to deserialize the | ||
* {@link JsonElement} to the object | ||
* @return the current element as a {@link StringPath} | ||
*/ | ||
public <O> O getAsObject(JsonSerializer<O> serializer); | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
io.openems.common/src/io/openems/common/jsonrpc/serialization/JsonElementPathActual.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.openems.common.jsonrpc.serialization; | ||
|
||
import com.google.gson.JsonElement; | ||
|
||
public class JsonElementPathActual implements JsonElementPath { | ||
private final JsonElement element; | ||
|
||
public JsonElementPathActual(JsonElement element) { | ||
this.element = element; | ||
} | ||
|
||
@Override | ||
public JsonArrayPath getAsJsonArrayPath() { | ||
return new JsonArrayPathActual(this.element); | ||
} | ||
|
||
@Override | ||
public JsonObjectPath getAsJsonObjectPath() { | ||
return new JsonObjectPathActual(this.element); | ||
} | ||
|
||
@Override | ||
public StringPath getAsStringPath() { | ||
return new StringPathActual(this.element); | ||
} | ||
|
||
@Override | ||
public <O> O getAsObject(JsonSerializer<O> deserializer) { | ||
return deserializer.deserializePath(new JsonElementPathActual(this.element)); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
io.openems.common/src/io/openems/common/jsonrpc/serialization/JsonElementPathDummy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.openems.common.jsonrpc.serialization; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonNull; | ||
|
||
public class JsonElementPathDummy implements JsonElementPath, JsonPathDummy { | ||
|
||
private JsonPathDummy dummyPath; | ||
|
||
@Override | ||
public JsonArrayPath getAsJsonArrayPath() { | ||
return this.withDummyPath(new JsonArrayPathDummy()); | ||
} | ||
|
||
@Override | ||
public JsonObjectPath getAsJsonObjectPath() { | ||
return this.withDummyPath(new JsonObjectPathDummy()); | ||
} | ||
|
||
@Override | ||
public StringPath getAsStringPath() { | ||
return this.withDummyPath(new StringPathDummy()); | ||
} | ||
|
||
@Override | ||
public <O> O getAsObject(JsonSerializer<O> deserializer) { | ||
final var dummyPath = new JsonElementPathDummy(); | ||
this.withDummyPath(dummyPath); | ||
return deserializer.deserializePath(dummyPath); | ||
} | ||
|
||
private <T extends JsonPathDummy> T withDummyPath(T path) { | ||
if (this.dummyPath != null) { | ||
throw new RuntimeException("Path already set"); | ||
} | ||
this.dummyPath = path; | ||
return path; | ||
} | ||
|
||
public JsonPathDummy getDummyPath() { | ||
return this.dummyPath; | ||
} | ||
|
||
@Override | ||
public JsonElement buildPath() { | ||
return this.dummyPath == null ? JsonNull.INSTANCE : this.dummyPath.buildPath(); | ||
} | ||
|
||
} |
Oops, something went wrong.