Skip to content

Commit

Permalink
Add Device Model Name field
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
  • Loading branch information
Claudio Mezzasalma authored and Coduz committed Oct 11, 2018
1 parent cc4d5b3 commit 5e82b84
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ public User call() throws Exception {
pairs.add(new GwtGroupedNVPair("devAttributesInfo", "devCustomAttribute4", device.getCustomAttribute4()));
pairs.add(new GwtGroupedNVPair("devAttributesInfo", "devCustomAttribute5", device.getCustomAttribute5()));

pairs.add(new GwtGroupedNVPair("devHw", "devModelName", device.getModelId()));
pairs.add(new GwtGroupedNVPair("devHw", "devModelId", device.getModelId()));
pairs.add(new GwtGroupedNVPair("devHw", "devModelName", device.getModelName()));
pairs.add(new GwtGroupedNVPair("devHw", "devSerialNumber", device.getSerialNumber()));

pairs.add(new GwtGroupedNVPair("devSw", "devFirmwareVersion", device.getFirmwareVersion()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public abstract class DeviceExporter {
"IMSI",
"ICCID",
"Model ID",
"Model Name",
"Bios Version",
"Firmware Version",
"OS Version",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public Account call() throws Exception {
// Model Id
cols.add(device.getModelId() != null ? device.getModelId() : BLANK);

// Model Name
cols.add(device.getModelName() != null ? device.getModelName() : BLANK);

// Bios version
cols.add(device.getBiosVersion() != null ? device.getBiosVersion() : BLANK);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static GwtDevice convertDevice(Device device)
gwtDevice.setClientId(device.getClientId());
gwtDevice.setDisplayName(device.getDisplayName());
gwtDevice.setModelId(device.getModelId());
gwtDevice.setModelName(device.getModelName());
gwtDevice.setSerialNumber(device.getSerialNumber());
if (device.getGroupId() != null) {
gwtDevice.setGroupDevice(GwtGroupDevice.NO_GROUP.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void checkDeviceInformation() throws Exception {
Assert.assertNotNull(device);

Assert.assertEquals("Kura Simulator (Display Name)", device.getDisplayName());
// Assert.assertEquals("Kura Simulator (Model Name)", device.getModelName());
Assert.assertEquals("Kura Simulator (Model Name)", device.getModelName());
Assert.assertEquals("kura-simulator-" + clientId, device.getModelId());
// Assert.assertEquals("ksim-part-123456-" + clientId, device.getPartNumber());
Assert.assertEquals("ksim-serial-123456-" + clientId, device.getSerialNumber());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"lastEvent",
"serialNumber",
"modelId",
"modelName",
"imei",
"imsi",
"iccid",
Expand Down Expand Up @@ -238,6 +239,21 @@ default String getType() {
*/
void setModelId(String modelId);

/**
* Get the model name
*
* @return
*/
@XmlElement(name = "modelName")
String getModelName();

/**
* Set the model name
*
* @param modelName
*/
void setModelName(String modelName);

/**
* Get the imei
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"displayName",
"serialNumber",
"modelId",
"modelName",
"imei",
"imsi",
"iccid",
Expand Down Expand Up @@ -193,6 +194,21 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator<Device> {
*/
void setModelId(String modelId);

/**
* Get the model name
*
* @return
*/
@XmlElement(name = "modelName")
String getModelName();

/**
* Set the model name
*
* @param modelName
*/
void setModelName(String modelName);

/**
* Get the imei
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class DeviceCreatorImpl extends AbstractKapuaUpdatableEntityCreator<Devic
private String displayName;
private String serialNumber;
private String modelId;
private String modelName;
private String imei;
private String imsi;
private String iccid;
Expand Down Expand Up @@ -143,6 +144,16 @@ public void setModelId(String modelId) {
this.modelId = modelId;
}

@Override
public String getModelName() {
return modelName;
}

@Override
public void setModelName(String modelName) {
this.modelName = modelName;
}

@Override
public String getImei() {
return imei;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static Device create(EntityManager em, DeviceCreator deviceCreator) {
device.setDisplayName(deviceCreator.getDisplayName());
device.setSerialNumber(deviceCreator.getSerialNumber());
device.setModelId(deviceCreator.getModelId());
device.setModelName(deviceCreator.getModelName());
device.setImei(deviceCreator.getImei());
device.setImsi(deviceCreator.getImsi());
device.setIccid(deviceCreator.getIccid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public class DeviceImpl extends AbstractKapuaUpdatableEntity implements Device,
@Column(name = "model_id")
private String modelId;

@Basic
@Column(name = "model_name")
private String modelName;

@Basic
@Column(name = "imei")
private String imei;
Expand Down Expand Up @@ -317,6 +321,16 @@ public void setModelId(String modelId) {
this.modelId = modelId;
}

@Override
public String getModelName() {
return modelName;
}

@Override
public void setModelName(String modelName) {
this.modelName = modelName;
}

@Override
public String getImei() {
return imei;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void birth(KapuaId connectionId, KapuaBirthMessage message)
deviceCreator.setDisplayName(payload.getDisplayName());
deviceCreator.setSerialNumber(payload.getSerialNumber());
deviceCreator.setModelId(payload.getModelId());
deviceCreator.setModelName(payload.getModelName());
deviceCreator.setImei(payload.getModemImei());
deviceCreator.setImsi(payload.getModemImsi());
deviceCreator.setIccid(payload.getModemIccid());
Expand All @@ -87,6 +88,7 @@ public void birth(KapuaId connectionId, KapuaBirthMessage message)
device.setDisplayName(payload.getDisplayName());
device.setSerialNumber(payload.getSerialNumber());
device.setModelId(payload.getModelId());
device.setModelName(payload.getModelName());
device.setImei(payload.getModemImei());
device.setImsi(payload.getModemImsi());
device.setIccid(payload.getModemIccid());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018 Eurotech and/or its affiliates and others
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Eurotech - initial API and implementation
-->
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd"
logicalFilePath="KapuaDB/changelog-device-1.1.0.xml">

<include relativeToChangelogFile="true" file="./device-add-model-name.xml"/>

</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018 Eurotech and/or its affiliates and others
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Eurotech - initial API and implementation
-->
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd"
logicalFilePath="KapuaDB/device-add-model-name.xml">

<changeSet id="device-add-model-name" author="eurotech">
<addColumn tableName="dvc_device">
<column name="model_name" type="varchar(255)" />
</addColumn>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
<include relativeToChangelogFile="true" file="./0.3.0/changelog-device-0.3.0.xml"/>
<include relativeToChangelogFile="true" file="./0.3.1/changelog-device-0.3.1.xml"/>
<include relativeToChangelogFile="true" file="./1.0.0/changelog-device-1.0.0.xml"/>
<include relativeToChangelogFile="true" file="./1.1.0/changelog-device-1.1.0.xml"/>

</databaseChangeLog>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ public void checkCreatedDeviceAgainstCreatorParameters()
assertEquals(deviceCreator.getDisplayName(), device.getDisplayName());
assertEquals(deviceCreator.getSerialNumber(), device.getSerialNumber());
assertEquals(deviceCreator.getModelId(), device.getModelId());
assertEquals(deviceCreator.getModelName(), device.getModelName());
assertEquals(deviceCreator.getImei(), device.getImei());
assertEquals(deviceCreator.getImsi(), device.getImsi());
assertEquals(deviceCreator.getIccid(), device.getIccid());
Expand Down Expand Up @@ -484,6 +485,7 @@ public void checkUpdatedDeviceAgainstOriginal()
assertEquals(tmpDevice.getDisplayName(), device.getDisplayName());
assertEquals(tmpDevice.getSerialNumber(), device.getSerialNumber());
assertEquals(tmpDevice.getModelId(), device.getModelId());
assertEquals(tmpDevice.getModelName(), device.getModelName());
assertEquals(tmpDevice.getImei(), device.getImei());
assertEquals(tmpDevice.getImsi(), device.getImsi());
assertEquals(tmpDevice.getIccid(), device.getIccid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ public void setModelId(String modelId) {

}

@Override
public String getModelName() {
return null;
}

@Override
public void setModelName(String modelName) {

}

@Override
public String getImei() {
// TODO Auto-generated method stub
Expand Down
10 changes: 10 additions & 0 deletions test/src/main/java/org/eclipse/kapua/test/device/DeviceMock.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ public void setModelId(String modelId) {

}

@Override
public String getModelName() {
return null;
}

@Override
public void setModelName(String modelName) {

}

@Override
public String getImei() {
// TODO Auto-generated method stub
Expand Down

0 comments on commit 5e82b84

Please sign in to comment.