Skip to content

Commit

Permalink
Add item id to generated items
Browse files Browse the repository at this point in the history
  • Loading branch information
LumnitzF authored and seaside1 committed Oct 4, 2022
1 parent d8fdd44 commit 2f28a40
Show file tree
Hide file tree
Showing 27 changed files with 36 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleCallItem extends JRuleItem {
public abstract class JRuleCallItem extends JRuleItem {

protected JRuleCallItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @author Joseph (Seaside) Hagberg - Initial contribution
*/
public class JRuleColorItem extends JRuleItem {
public abstract class JRuleColorItem extends JRuleItem {

protected JRuleColorItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Timo Litzius - Initial contribution
*/
public class JRuleContactItem extends JRuleItem implements JRuleContactTrigger {
public abstract class JRuleContactItem extends JRuleItem implements JRuleContactTrigger {

protected JRuleContactItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @author Joseph (Seaside) Hagberg - Initial contribution
*/
public class JRuleDateTimeItem extends JRuleItem {
public abstract class JRuleDateTimeItem extends JRuleItem {

protected JRuleDateTimeItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @author Joseph (Seaside) Hagberg - Initial contribution
*/
public class JRuleDimmerItem extends JRuleItem implements JRuleDimmerTrigger {
public abstract class JRuleDimmerItem extends JRuleItem implements JRuleDimmerTrigger {

protected JRuleDimmerItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupCallItem extends JRuleGroupItem {
public abstract class JRuleGroupCallItem extends JRuleGroupItem {

protected JRuleGroupCallItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupColorItem extends JRuleGroupItem {
public abstract class JRuleGroupColorItem extends JRuleGroupItem {

protected JRuleGroupColorItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupContactItem extends JRuleGroupItem {
public abstract class JRuleGroupContactItem extends JRuleGroupItem {

protected JRuleGroupContactItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupDateTimeItem extends JRuleGroupItem {
public abstract class JRuleGroupDateTimeItem extends JRuleGroupItem {

protected JRuleGroupDateTimeItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupDimmerItem extends JRuleGroupItem implements JRuleDimmerTrigger {
public abstract class JRuleGroupDimmerItem extends JRuleGroupItem implements JRuleDimmerTrigger {

private static final String LOG_NAME = "JRuleGroupDimmerItem";
private static final Logger logger = LoggerFactory.getLogger(JRuleGroupDimmerItem.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupImageItem extends JRuleGroupItem {
public abstract class JRuleGroupImageItem extends JRuleGroupItem {

protected JRuleGroupImageItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupLocationItem extends JRuleGroupItem {
public abstract class JRuleGroupLocationItem extends JRuleGroupItem {

protected JRuleGroupLocationItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupNumberItem extends JRuleGroupItem {
public abstract class JRuleGroupNumberItem extends JRuleGroupItem {

private static final String LOG_NAME = "JRuleGroupNumberItem";
private static final Logger logger = LoggerFactory.getLogger(JRuleGroupNumberItem.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupPlayerItem extends JRuleGroupItem implements JRulePlayerTrigger {
public abstract class JRuleGroupPlayerItem extends JRuleGroupItem implements JRulePlayerTrigger {

protected JRuleGroupPlayerItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupRollershutterItem extends JRuleGroupItem {
public abstract class JRuleGroupRollershutterItem extends JRuleGroupItem {

protected JRuleGroupRollershutterItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupStringItem extends JRuleGroupItem {
public abstract class JRuleGroupStringItem extends JRuleGroupItem {

protected JRuleGroupStringItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleGroupSwitchItem extends JRuleGroupItem implements JRuleSwitchTrigger {
public abstract class JRuleGroupSwitchItem extends JRuleGroupItem implements JRuleSwitchTrigger {

protected JRuleGroupSwitchItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleImageItem extends JRuleItem {
public abstract class JRuleImageItem extends JRuleItem {

protected JRuleImageItem(String itemName) {
super(itemName);
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/openhab/automation/jrule/items/JRuleItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ public String getName() {
return itemName;
}

public String getLabel() {
return null; // Method overridden by generated item
}
public abstract String getLabel();

public String getType() {
return null; // Method overridden by generated item
}
public abstract String getType();

public abstract String getId();

public ZonedDateTime lastUpdated() {
return lastUpdated(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public boolean generateItemsSource(Collection<Item> items) {

private Map<String, Object> createItemModel(Item item) {
Map<String, Object> itemModel = new HashMap<>();
itemModel.put("id", item.getUID());
itemModel.put("name", item.getName());
itemModel.put("package", jRuleConfig.getGeneratedItemPackage());
itemModel.put("class", jRuleConfig.getGeneratedItemPrefix() + item.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* @author Arne Seime - Initial contribution
*/
public class JRuleLocationItem extends JRuleItem {
public abstract class JRuleLocationItem extends JRuleItem {

protected JRuleLocationItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @author Joseph (Seaside) Hagberg - Initial contribution
*/
public class JRuleNumberItem extends JRuleItem {
public abstract class JRuleNumberItem extends JRuleItem {

protected JRuleNumberItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Joseph (Seaside) Hagberg - Initial contribution
*/
public class JRulePlayerItem extends JRuleItem implements JRulePlayerTrigger {
public abstract class JRulePlayerItem extends JRuleItem implements JRulePlayerTrigger {

protected JRulePlayerItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Timo Litzius - Initial contribution
*/
public class JRuleRollershutterItem extends JRuleItem {
public abstract class JRuleRollershutterItem extends JRuleItem {

protected JRuleRollershutterItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Joseph (Seaside) Hagberg - Initial contribution
*/
public class JRuleStringItem extends JRuleItem {
public abstract class JRuleStringItem extends JRuleItem {

protected JRuleStringItem(String itemName) {
super(itemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Joseph (Seaside) Hagberg - Initial contribution
*/
public class JRuleSwitchItem extends JRuleItem implements JRuleSwitchTrigger {
public abstract class JRuleSwitchItem extends JRuleItem implements JRuleSwitchTrigger {

protected JRuleSwitchItem(String itemName) {
super(itemName);
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/templates/CommonMethods.ftlh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

public static final String TYPE = "${item.type}";

public static final String ID = "${item.id}";

@Override
public String getLabel() {
return LABEL;
Expand All @@ -14,6 +16,11 @@
return TYPE;
}

@Override
public String getId() {
return ID;
}

@Override
public String toString() {
return "'"+LABEL+"'/"+ITEM+"/"+TYPE;
Expand Down

0 comments on commit 2f28a40

Please sign in to comment.