Skip to content

Commit

Permalink
Migrated to Docker community edition, minor bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bauer committed May 21, 2017
1 parent 2b8e596 commit 872868e
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 35 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -14,13 +14,13 @@ If you want to try OpenRemote v2, [read the OpenRemote v2 documentation](https:/

We work with Java, Groovy, JavaScript, Gradle, Docker, and a wide range of APIs and protocol implementations. Clone or checkout this project and send us pull requests.

A demo preview can be started with Docker Compose (install [Docker Toolbox](https://www.docker.com/products/docker-toolbox)):
A demo preview can be started with Docker Compose (install [Docker Community Edition](https://www.docker.com/)):

```
docker-compose -p openremote -f profile/demo.yml up
```

Access the manager UI and API on https://192.168.99.100/ with username `admin` and password `secret`. Configuration options of the images are documented in the compose profiles.
Access the manager UI and API on https://localhost/ with username `admin` and password `secret` (accept the 'insecure' self-signed SSL certificate). Configuration options of the images are documented in the compose profiles.

You can build the Docker images from source with:

Expand Down
Expand Up @@ -47,7 +47,7 @@ public class PersistenceService implements ContainerService {
public static final String DATABASE_PRODUCT = "DATABASE_PRODUCT";
public static final String DATABASE_PRODUCT_DEFAULT = Database.Product.POSTGRES.name();
public static final String DATABASE_CONNECTION_URL = "DATABASE_CONNECTION_URL";
public static final String DATABASE_CONNECTION_URL_DEFAULT = "jdbc:postgresql://192.168.99.100:5432/openremote";
public static final String DATABASE_CONNECTION_URL_DEFAULT = "jdbc:postgresql://localhost:5432/openremote";
public static final String DATABASE_USERNAME = "DATABASE_USERNAME";
public static final String DATABASE_USERNAME_DEFAULT = "openremote";
public static final String DATABASE_PASSWORD = "DATABASE_PASSWORD";
Expand Down
Expand Up @@ -71,7 +71,7 @@ public abstract class IdentityService implements ContainerService {
public static final int IDENTITY_SESSION_TIMEOUT_SECONDS_DEFAULT = 10800; // 3 hours

public static final String KEYCLOAK_HOST = "KEYCLOAK_HOST";
public static final String KEYCLOAK_HOST_DEFAULT = "192.168.99.100";
public static final String KEYCLOAK_HOST_DEFAULT = "localhost";
public static final String KEYCLOAK_PORT = "KEYCLOAK_PORT";
public static final int KEYCLOAK_PORT_DEFAULT = 8081;
public static final String KEYCLOAK_CONNECT_TIMEOUT = "KEYCLOAK_CONNECT_TIMEOUT";
Expand Down
Expand Up @@ -351,7 +351,7 @@ protected AttributeEditor createEditor(AssetAttribute attribute, FormGroup formG
AttributeEditor attributeEditor;
if (attributeType == AttributeType.STRING || attributeType.getValueType() == ValueType.STRING) {
attributeEditor = createStringEditor(attribute, defaultValueItem, style, formGroup);
} else if (attributeType == AttributeType.NUMBER) {
} else if (attributeType == AttributeType.NUMBER || attributeType.getValueType() == ValueType.NUMBER) {
attributeEditor = createNumberEditor(attribute, defaultValueItem, style, formGroup);
} else if (attributeType == AttributeType.BOOLEAN || attributeType.getValueType() == ValueType.BOOLEAN) {
attributeEditor = createBooleanEditor(attribute, defaultValueItem, style, formGroup);
Expand Down
Expand Up @@ -207,7 +207,7 @@ attributeType[FLOW_CMPS]=Flow in cubic metres per second
attributeType[FLOW_SCCM]=Flow in cubic centimetres per minute
attributeType[FLOW_CFPS]=Flow in cubic feet per second
attributeType[FLOW_GPM]=Flow in gallons per minute
attributeType[TEMPLATE_FILTER]=Template filter
attributeType[RULES_TEMPLATE_FILTER]=Rules template filter
emptyMetaItem=Empty item
invalidAssetAttributes=Invalid asset attributes, please correct input.
validationFailed=Validation failed
Expand Down
Expand Up @@ -51,6 +51,7 @@
import org.openremote.manager.server.notification.NotificationService;
import org.openremote.manager.server.security.ManagerIdentityService;
import org.openremote.model.asset.*;
import org.openremote.model.attribute.AttributeType;
import org.openremote.model.rules.AssetRuleset;
import org.openremote.model.rules.GlobalRuleset;
import org.openremote.model.rules.Ruleset;
Expand All @@ -75,6 +76,8 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;

import static org.openremote.model.attribute.Attribute.isAttributeTypeEqualTo;

public class RulesEngine<T extends Ruleset> {

public static final Logger LOG = Logger.getLogger(RulesEngine.class.getName());
Expand Down Expand Up @@ -775,7 +778,7 @@ protected String compileTemplate(String templateAssetId, String rules) {
throw new IllegalStateException("Template asset not found: " + templateAssetId);

List<TemplateFilter> filters = templateAsset.getAttributesStream()
.filter(AssetAttribute::isRuleStateTemplateFilter)
.filter(isAttributeTypeEqualTo(AttributeType.RULES_TEMPLATE_FILTER))
.map(attribute -> new Pair<>(attribute.getName(), attribute.getValue()))
.filter(pair -> pair.key.isPresent() && pair.value.isPresent())
.map(pair -> new Pair<>(pair.key.get(), pair.value.get()))
Expand Down
Expand Up @@ -680,7 +680,7 @@ public void execute() throws Exception {
flightPriorityFilters.setAttributes(
new AssetAttribute(
"originSwitzerland",
TEMPLATE_FILTER,
RULES_TEMPLATE_FILTER,
new TemplateFilter(
new AttributeValueConstraintPattern(
"originCountry", new AttributeValueConstraint(ValueComparator.EQUALS_IGNORE_CASE, Values.create("switzerland"))
Expand All @@ -690,8 +690,7 @@ public void execute() throws Exception {
)
).toModelValue()
).setMeta(
new MetaItem(LABEL, Values.create("Origin Switzerland")),
new MetaItem(RULE_TEMPLATE_FILTER, Values.create(true))
new MetaItem(LABEL, Values.create("Filter Origin Switzerland"))
)
);
flightPriorityFilters = assetStorageService.merge(flightPriorityFilters);
Expand Down
Expand Up @@ -320,15 +320,6 @@ public void setRuleState(boolean ruleState) {
getMeta().removeIf(isMetaNameEqualTo(RULE_STATE));
}
}

public boolean isRuleStateTemplateFilter() {
return getMetaStream()
.filter(isMetaNameEqualTo(RULE_TEMPLATE_FILTER))
.findFirst()
.map(metaItem -> metaItem.getValueAsBoolean().orElse(false))
.orElse(false);
}

public boolean isRuleEvent() {
return getMetaStream()
.filter(isMetaNameEqualTo(RULE_EVENT))
Expand Down
11 changes: 0 additions & 11 deletions model/src/main/java/org/openremote/model/asset/AssetMeta.java
Expand Up @@ -23,8 +23,6 @@
import org.openremote.model.ValidationFailure;
import org.openremote.model.attribute.AttributeExecuteStatus;
import org.openremote.model.attribute.MetaItem;
import org.openremote.model.rules.Ruleset;
import org.openremote.model.rules.template.TemplateFilter;
import org.openremote.model.util.Pair;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
Expand Down Expand Up @@ -149,15 +147,6 @@ public enum AssetMeta implements HasUniqueResourceName {
*/
RULE_EVENT_EXPIRES(ASSET_META_NAMESPACE + ":ruleEventExpires", new Access(true, false, true), ValueType.STRING),

/**
* When {@link Ruleset#templateAssetId} references an asset, use the attribute to customize the template when
* the ruleset is deployed. The attribute name is available in the template as parameter {@link
* TemplateFilter#TEMPLATE_PARAM_FILTER_NAME}, the attribute value is converted into {@link TemplateFilter} and
* available in the template as {@link TemplateFilter#TEMPLATE_PARAM_ASSET_STATE} and
* {@link TemplateFilter#TEMPLATE_PARAM_ASSET_EVENT}.
*/
RULE_TEMPLATE_FILTER(ASSET_META_NAMESPACE + ":ruleTemplateFilter", new Access(true, false, true), ValueType.BOOLEAN),

/**
* Enable flag to be used by asset attributes that could require this functionality (e.g. {@link org.openremote.model.asset.agent.ProtocolConfiguration})
*/
Expand Down
Expand Up @@ -20,6 +20,8 @@
package org.openremote.model.attribute;

import org.openremote.model.ValidationFailure;
import org.openremote.model.rules.Ruleset;
import org.openremote.model.rules.template.TemplateFilter;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
import org.openremote.model.value.Values;
Expand Down Expand Up @@ -47,7 +49,14 @@ public enum AttributeType {

BOOLEAN(ValueType.BOOLEAN, value -> Optional.empty()),

TEMPLATE_FILTER(ValueType.ARRAY, value -> Optional.empty()),
/**
* When {@link Ruleset#templateAssetId} references an asset, use the attribute to customize the
* template when the ruleset is deployed. The attribute name is available in the template as
* parameter {@link TemplateFilter#TEMPLATE_PARAM_FILTER_NAME}, the attribute value is converted
* into {@link TemplateFilter} and available in the template as
* {@link TemplateFilter#TEMPLATE_PARAM_ASSET_STATE} and {@link TemplateFilter#TEMPLATE_PARAM_ASSET_EVENT}.
*/
RULES_TEMPLATE_FILTER(ValueType.ARRAY, value -> Optional.empty()),

PERCENTAGE(ValueType.NUMBER, value -> Values.getNumber(value)
.filter(number -> number < 0 || number > 100)
Expand Down
5 changes: 2 additions & 3 deletions profile/demo.yml
Expand Up @@ -71,9 +71,8 @@ services:
#SETUP_KEYCLOAK_EMAIL_FROM: 'noreply@demo.tld'

# The public host name of this OpenRemote installation. This name is used in bearer tokens
# and must be the name you access the web services under. If you are using Docker Toolbox,
# this is the IP of a virtual machine running the Linux Docker host (see VirtualBox).
IDENTITY_NETWORK_HOST: 192.168.99.100
# and must be the name you access the web services under.
IDENTITY_NETWORK_HOST: localhost

# Set if SSL is enabled on the frontend reverse proxy and all internal proxies should assume https
IDENTITY_NETWORK_SECURE: 'true'
Expand Down
2 changes: 1 addition & 1 deletion profile/manager_dev.yml
Expand Up @@ -12,7 +12,7 @@ services:
environment:
TZ: Europe/Zurich
DEV_MODE: 'true'
IDENTITY_NETWORK_HOST: 192.168.99.100
IDENTITY_NETWORK_HOST: localhost
IDENTITY_NETWORK_WEBSERVER_PORT: 443
IDENTITY_NETWORK_SECURE: 'true'
KEYCLOAK_HOST: keycloak
Expand Down

0 comments on commit 872868e

Please sign in to comment.