Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Update to 2.4.0-SNAPSHOT
Browse files Browse the repository at this point in the history
Minor adaptations following API changes
Add checkstyle config

Signed-off-by: Yannick Schaus <[email protected]>
  • Loading branch information
ghys committed Jun 13, 2018
1 parent a8658da commit c3de12d
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ deploy:
provider: releases
api_key:
secure: uQyT7TeUHi73kvyqBcjhcIW/hJ6iAjR/wFXnx9QX3u5w3UaMA2sToEkIAQV4ATpikaHjgnYOiJPdZgOZ/dfdj0y65XTEjF07YUv3XaI+JeHKTvdX5kEeLzfXSDIXIQZ/k7espIWST9DK0TEZcQZYq/6iFHLB/3RzpXJFycs0bWT7DF4ZdACTBdf4CPDu1FBXTKW84r7CGYPKGrwv5M1xNIqKNYkd0iPp0YTmDjMSfSGFFPi8htqy8afIOBzeVW4xLhMU0PBrvmxnra/DxMyiVlyaXU7BfRaIEi0ODvMuEejeL5P/sSr8yEuJoGPeqm3s19LesdCoamr0f3rtks9KLEUKu827o8V+6c9TIzB6OzPs3MNFSw3E0YyxB520Ae7f9bSM5zUxRMlryYpvzK/MXPS+Gw2KrGQlVNkd9LYm2iRjQu43ljF0Rtt9Y/IyJWZ+70ehK7Ln11Da/b79JMbEXw+Refue7xjWncZNFKWybeHblCFKsxghSj970uNuhPT9rOEY2WwWhgR5+BOGvxMmCCJptv1HJSm1+8cMlx/3oTg7OMSEHuk2Pb/O0NVdGPMCj28GeC4nTmsAORS1xziVNMM5lQ5Cj4+hFLVrX+qJZ81rTvAK6WQb3dx70Nyl7OcqifS1+AIVFq/HBChZCfpkstxEv+51lnhLRpFm824r9yQ=
file: target/org.openhab.ui.habot-2.3.0-SNAPSHOT.jar
file: target/org.openhab.ui.habot-2.4.0-SNAPSHOT.jar
skip_cleanup: true
on:
repo: ghys/habot
2 changes: 1 addition & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: HABot Interactive Bot
Bundle-SymbolicName: org.openhab.ui.habot
Bundle-Version: 2.3.0.qualifier
Bundle-Version: 2.4.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .,
lib/opennlp-tools-1.8.3.jar,
Expand Down
27 changes: 18 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>org.openhab</groupId>
<artifactId>pom-tycho</artifactId>
<version>2.3.0-SNAPSHOT</version>
<version>2.4.0-SNAPSHOT</version>
</parent>
<groupId>org.openhab.ui</groupId>
<artifactId>org.openhab.ui.habot</artifactId>
<version>2.3.0-SNAPSHOT</version>
<version>2.4.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>HABot Interactive Bot</name>
<description>HABot Interactive Bot for openHAB</description>
Expand All @@ -18,7 +18,23 @@
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.openhab.tools.sat</groupId>
<artifactId>sat-plugin</artifactId>
<version>{sat.version}</version>
<configuration>
<checkstyleProperties>tools/checkstyle.properties</checkstyleProperties>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
Expand Down Expand Up @@ -144,13 +160,6 @@
</snapshots>
</repository>

<!-- SmartHome p2 repository -->
<repository>
<id>p2-smarthome</id>
<url>https://openhab.jfrog.io/openhab/eclipse-smarthome-stable</url>
<layout>p2</layout>
</repository>

<!-- openHAB dependencies p2 repository -->
<repository>
<id>p2-openhab-deps-repo</id>
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/openhab/ui/habot/card/CardBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.smarthome.core.items.Item;
import org.eclipse.smarthome.core.items.ItemRegistry;
import org.eclipse.smarthome.core.library.CoreItemFactory;
import org.eclipse.smarthome.core.transform.TransformationException;
import org.eclipse.smarthome.core.transform.TransformationHelper;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.StateDescription;
Expand Down Expand Up @@ -165,7 +166,12 @@ public Card buildCard(Intent intent, Collection<Item> matchedItems) {
* Try to get a formatted state to determine whether it's small enough to display
* in the "right" slot - otherwise add it to the "main" slot
*/
String formattedState = formatState(item, item.getState());
String formattedState;
try {
formattedState = formatState(item, item.getState());
} catch (TransformationException e1) {
formattedState = item.getState().toString();
}
Component singleItemComponent = new Component("HbSingleItemValue");
singleItemComponent.addConfig("item", item.getName());
if (formattedState.length() < 10) {
Expand Down Expand Up @@ -253,7 +259,7 @@ private String getCardTitleFromGroupLabels(Set<String> tags) {
}
}

private String formatState(Item item, State state) {
private String formatState(Item item, State state) throws TransformationException {
if (item.getStateDescription() != null) {
StateDescription stateDescription = item.getStateDescription();
if (stateDescription != null && stateDescription.getPattern() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.smarthome.core.items.Item;
import org.eclipse.smarthome.core.items.ItemRegistry;
import org.eclipse.smarthome.core.persistence.HistoricItem;
import org.eclipse.smarthome.core.transform.TransformationException;
import org.eclipse.smarthome.core.transform.TransformationHelper;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.StateDescription;
Expand Down Expand Up @@ -120,7 +121,7 @@ private String formatState(Item item, State state) {
} else {
return transformedState;
}
} catch (NoClassDefFoundError ex) {
} catch (NoClassDefFoundError | TransformationException ex) {
// TransformationHelper is optional dependency, so ignore if class not found
// return state as it is without transformation
return state.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ public void unsetCardRegistry(CardRegistry cardRegistry) {
@ApiResponse(code = 500, message = "There is no support for the configured language") })
public Response greet(
@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language (will use the default if omitted)") String language) {
final Locale locale = (this.localeProvider != null && this.localeProvider.getLocale() != null)
? this.localeProvider.getLocale()
final Locale locale = (this.localeProvider != null) ? this.localeProvider.getLocale()
: LocaleUtil.getLocale(language);

AnswerFormatter answerFormatter = new AnswerFormatter(locale);
Expand All @@ -149,8 +148,7 @@ public Response greet(
@ApiResponse(code = 500, message = "An interpretation error occured") })
public Response chat(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language,
@ApiParam(value = "human language query", required = true) String query) throws Exception {
final Locale locale = (this.localeProvider != null && this.localeProvider.getLocale() != null)
? this.localeProvider.getLocale()
final Locale locale = (this.localeProvider != null) ? this.localeProvider.getLocale()
: LocaleUtil.getLocale(language);

// interpret
Expand Down
3 changes: 3 additions & 0 deletions tools/checkstyle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
checkstyle.headerCheck.content=^/\\*\\*$\\n^ \\* Copyright \\(c\\) {0}-{1} by the respective copyright holders\\.$\\n^ \\*$\\n^ \\* All rights reserved\\. This program and the accompanying materials$\\n^ \\* are made available under the terms of the Eclipse Public License v1\\.0$\\n^ \\* which accompanies this distribution, and is available at$\\n^ \\* http://www.eclipse.org/legal/epl\\-v10\\.html$
checkstyle.headerCheck.values=2010,2018
checkstyle.pomXmlCheck.currentVersionRegex=^2\.4\.0
Loading

0 comments on commit c3de12d

Please sign in to comment.