Adding the changes for device Info bean to stop returing null values and changes done for Device search unit classes

revert-70aa11f8
geethkokila 9 years ago
parent 41ba2f4f0a
commit 73a82f743f

@ -79,7 +79,11 @@ public class DeviceInfo implements Serializable{
} }
public String getIMEI() { public String getIMEI() {
if (IMEI != null) {
return IMEI; return IMEI;
} else {
return "";
}
} }
public void setIMEI(String IMEI) { public void setIMEI(String IMEI) {
@ -87,7 +91,11 @@ public class DeviceInfo implements Serializable{
} }
public String getIMSI() { public String getIMSI() {
if (IMSI != null) {
return IMSI; return IMSI;
} else {
return "";
}
} }
public void setIMSI(String IMSI) { public void setIMSI(String IMSI) {
@ -95,7 +103,11 @@ public class DeviceInfo implements Serializable{
} }
public String getDeviceModel() { public String getDeviceModel() {
if (deviceModel != null) {
return deviceModel; return deviceModel;
} else {
return "";
}
} }
public void setDeviceModel(String deviceModel) { public void setDeviceModel(String deviceModel) {
@ -103,7 +115,11 @@ public class DeviceInfo implements Serializable{
} }
public String getVendor() { public String getVendor() {
if (vendor != null) {
return vendor; return vendor;
} else {
return "";
}
} }
public void setVendor(String vendor) { public void setVendor(String vendor) {
@ -111,7 +127,11 @@ public class DeviceInfo implements Serializable{
} }
public String getOsVersion() { public String getOsVersion() {
if (osVersion != null) {
return osVersion; return osVersion;
} else {
return "";
}
} }
public void setOsVersion(String osVersion) { public void setOsVersion(String osVersion) {
@ -119,7 +139,11 @@ public class DeviceInfo implements Serializable{
} }
public Double getBatteryLevel() { public Double getBatteryLevel() {
if (batteryLevel != null) {
return batteryLevel; return batteryLevel;
} else {
return 0.0;
}
} }
public void setBatteryLevel(Double batteryLevel) { public void setBatteryLevel(Double batteryLevel) {
@ -127,7 +151,11 @@ public class DeviceInfo implements Serializable{
} }
public Double getInternalTotalMemory() { public Double getInternalTotalMemory() {
if (internalTotalMemory != null) {
return internalTotalMemory; return internalTotalMemory;
} else {
return 0.0;
}
} }
public void setInternalTotalMemory(Double internalTotalMemory) { public void setInternalTotalMemory(Double internalTotalMemory) {
@ -135,7 +163,11 @@ public class DeviceInfo implements Serializable{
} }
public Double getInternalAvailableMemory() { public Double getInternalAvailableMemory() {
if (internalAvailableMemory != null) {
return internalAvailableMemory; return internalAvailableMemory;
} else {
return 0.0;
}
} }
public void setInternalAvailableMemory(Double internalAvailableMemory) { public void setInternalAvailableMemory(Double internalAvailableMemory) {
@ -143,7 +175,11 @@ public class DeviceInfo implements Serializable{
} }
public Double getExternalTotalMemory() { public Double getExternalTotalMemory() {
if (externalTotalMemory != null) {
return externalTotalMemory; return externalTotalMemory;
} else {
return 0.0;
}
} }
public void setExternalTotalMemory(Double externalTotalMemory) { public void setExternalTotalMemory(Double externalTotalMemory) {
@ -151,7 +187,11 @@ public class DeviceInfo implements Serializable{
} }
public Double getExternalAvailableMemory() { public Double getExternalAvailableMemory() {
if (externalAvailableMemory != null) {
return externalAvailableMemory; return externalAvailableMemory;
} else {
return 0.0;
}
} }
public void setExternalAvailableMemory(Double externalAvailableMemory) { public void setExternalAvailableMemory(Double externalAvailableMemory) {
@ -159,7 +199,11 @@ public class DeviceInfo implements Serializable{
} }
public String getOperator() { public String getOperator() {
if (operator != null) {
return operator; return operator;
} else {
return "";
}
} }
public void setOperator(String operator) { public void setOperator(String operator) {
@ -167,7 +211,11 @@ public class DeviceInfo implements Serializable{
} }
public String getConnectionType() { public String getConnectionType() {
if (connectionType != null) {
return connectionType; return connectionType;
} else {
return "";
}
} }
public void setConnectionType(String connectionType) { public void setConnectionType(String connectionType) {
@ -175,7 +223,11 @@ public class DeviceInfo implements Serializable{
} }
public Double getMobileSignalStrength() { public Double getMobileSignalStrength() {
if (mobileSignalStrength != null) {
return mobileSignalStrength; return mobileSignalStrength;
} else {
return 0.0;
}
} }
public void setMobileSignalStrength(Double mobileSignalStrength) { public void setMobileSignalStrength(Double mobileSignalStrength) {
@ -183,7 +235,11 @@ public class DeviceInfo implements Serializable{
} }
public String getSsid() { public String getSsid() {
if (ssid != null) {
return ssid; return ssid;
} else {
return "";
}
} }
public void setSsid(String ssid) { public void setSsid(String ssid) {
@ -191,7 +247,11 @@ public class DeviceInfo implements Serializable{
} }
public Double getCpuUsage() { public Double getCpuUsage() {
if (cpuUsage != null) {
return cpuUsage; return cpuUsage;
} else {
return 0.0;
}
} }
public void setCpuUsage(Double cpuUsage) { public void setCpuUsage(Double cpuUsage) {
@ -199,7 +259,11 @@ public class DeviceInfo implements Serializable{
} }
public Double getTotalRAMMemory() { public Double getTotalRAMMemory() {
if (totalRAMMemory != null) {
return totalRAMMemory; return totalRAMMemory;
} else {
return 0.0;
}
} }
public void setTotalRAMMemory(Double totalRAMMemory) { public void setTotalRAMMemory(Double totalRAMMemory) {
@ -207,7 +271,11 @@ public class DeviceInfo implements Serializable{
} }
public Double getAvailableRAMMemory() { public Double getAvailableRAMMemory() {
if (availableRAMMemory != null) {
return availableRAMMemory; return availableRAMMemory;
} else {
return 0.0;
}
} }
public void setAvailableRAMMemory(Double availableRAMMemory) { public void setAvailableRAMMemory(Double availableRAMMemory) {

@ -101,6 +101,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
public void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException { public void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException {
try { try {
Device device = DeviceManagementDataHolder.getInstance().
getDeviceManagementProvider().getDevice(deviceLocation.getDeviceIdentifier());
deviceLocation.setDeviceId(device.getId());
DeviceManagementDAOFactory.beginTransaction(); DeviceManagementDAOFactory.beginTransaction();
deviceDetailsDAO.deleteDeviceLocation(deviceLocation.getDeviceId()); deviceDetailsDAO.deleteDeviceLocation(deviceLocation.getDeviceId());
deviceDetailsDAO.addDeviceLocation(deviceLocation); deviceDetailsDAO.addDeviceLocation(deviceLocation);
@ -111,6 +114,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
} catch (DeviceDetailsMgtDAOException e) { } catch (DeviceDetailsMgtDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction(); DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceDetailsMgtException("Error occurred while adding the device location information."); throw new DeviceDetailsMgtException("Error occurred while adding the device location information.");
} catch (DeviceManagementException e) {
DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceDetailsMgtException("Error occurred while getting the device information.");
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }

@ -27,8 +27,11 @@ import org.wso2.carbon.device.mgt.common.device.details.DeviceWrapper;
import org.wso2.carbon.device.mgt.common.search.Condition; import org.wso2.carbon.device.mgt.common.search.Condition;
import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest; import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl; import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -40,7 +43,8 @@ public class SearchDevice extends BaseDeviceManagementTest {
@BeforeClass @BeforeClass
@Override @Override
public void init() throws Exception { public void init() throws Exception {
DeviceManagementProviderService deviceManagementProviderService = new DeviceManagementProviderServiceImpl();
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProviderService);
} }
@Test @Test

@ -34,13 +34,7 @@ public class Utils {
DeviceInfo deviceInfo = new DeviceInfo(); DeviceInfo deviceInfo = new DeviceInfo();
deviceInfo.setDeviceIdentifier(Utils.getDeviceIdentifier());
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setType(TestDataHolder.TEST_DEVICE_TYPE);
deviceIdentifier.setId("12345");
deviceInfo.setDeviceIdentifier(deviceIdentifier);
deviceInfo.setDeviceId(1); deviceInfo.setDeviceId(1);
deviceInfo.setIMSI("e6f236ac82537a8e"); deviceInfo.setIMSI("e6f236ac82537a8e");
@ -88,6 +82,7 @@ public class Utils {
DeviceLocation deviceLocation = new DeviceLocation(); DeviceLocation deviceLocation = new DeviceLocation();
deviceLocation.setDeviceIdentifier(Utils.getDeviceIdentifier());
deviceLocation.setLatitude(76.2422); deviceLocation.setLatitude(76.2422);
deviceLocation.setLongitude(81.43); deviceLocation.setLongitude(81.43);
deviceLocation.setStreet1("4"); deviceLocation.setStreet1("4");
@ -100,6 +95,14 @@ public class Utils {
return deviceLocation; return deviceLocation;
} }
private static DeviceIdentifier getDeviceIdentifier(){
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setType(TestDataHolder.TEST_DEVICE_TYPE);
deviceIdentifier.setId("12345");
return deviceIdentifier;
}
} }

Loading…
Cancel
Save