This commit is contained in:
Dulitha Wijewantha 2015-01-20 13:42:44 +05:30
commit cbec06cd35
750 changed files with 1445 additions and 612 deletions

View File

@ -23,29 +23,17 @@ import java.util.List;
public class Device { public class Device {
private int id; private int id;
private String type; private String type;
private String description; private String description;
private String name; private String name;
private Long dateOfEnrolment; private Long dateOfEnrolment;
private Long dateOfLastUpdate; private Long dateOfLastUpdate;
private String ownership; private String ownership;
private boolean status; private boolean status;
private int deviceTypeId; private int deviceTypeId;
private String deviceIdentifier; private String deviceIdentifier;
private String owner; private String owner;
private List<Feature> features; private List<Feature> features;
private List<Device.Property> properties; private List<Device.Property> properties;
@XmlElement @XmlElement
@ -56,6 +44,7 @@ public class Device {
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@XmlElement @XmlElement
public String getDescription() { public String getDescription() {
return description; return description;
@ -64,6 +53,7 @@ public class Device {
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
@XmlElement @XmlElement
public String getName() { public String getName() {
return name; return name;
@ -72,6 +62,7 @@ public class Device {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@XmlElement @XmlElement
public Long getDateOfEnrolment() { public Long getDateOfEnrolment() {
return dateOfEnrolment; return dateOfEnrolment;
@ -80,6 +71,7 @@ public class Device {
public void setDateOfEnrolment(Long dateOfEnrolment) { public void setDateOfEnrolment(Long dateOfEnrolment) {
this.dateOfEnrolment = dateOfEnrolment; this.dateOfEnrolment = dateOfEnrolment;
} }
@XmlElement @XmlElement
public Long getDateOfLastUpdate() { public Long getDateOfLastUpdate() {
return dateOfLastUpdate; return dateOfLastUpdate;
@ -88,6 +80,7 @@ public class Device {
public void setDateOfLastUpdate(Long dateOfLastUpdate) { public void setDateOfLastUpdate(Long dateOfLastUpdate) {
this.dateOfLastUpdate = dateOfLastUpdate; this.dateOfLastUpdate = dateOfLastUpdate;
} }
@XmlElement @XmlElement
public String getOwnership() { public String getOwnership() {
return ownership; return ownership;
@ -96,6 +89,7 @@ public class Device {
public void setOwnership(String ownership) { public void setOwnership(String ownership) {
this.ownership = ownership; this.ownership = ownership;
} }
@XmlElement @XmlElement
public boolean isStatus() { public boolean isStatus() {
return status; return status;
@ -104,6 +98,7 @@ public class Device {
public void setStatus(boolean status) { public void setStatus(boolean status) {
this.status = status; this.status = status;
} }
@XmlElement @XmlElement
public int getDeviceTypeId() { public int getDeviceTypeId() {
return deviceTypeId; return deviceTypeId;
@ -112,6 +107,7 @@ public class Device {
public void setDeviceTypeId(int deviceTypeId) { public void setDeviceTypeId(int deviceTypeId) {
this.deviceTypeId = deviceTypeId; this.deviceTypeId = deviceTypeId;
} }
@XmlElement @XmlElement
public String getDeviceIdentifier() { public String getDeviceIdentifier() {
return deviceIdentifier; return deviceIdentifier;
@ -120,6 +116,7 @@ public class Device {
public void setDeviceIdentifier(String deviceIdentifier) { public void setDeviceIdentifier(String deviceIdentifier) {
this.deviceIdentifier = deviceIdentifier; this.deviceIdentifier = deviceIdentifier;
} }
@XmlElement @XmlElement
public String getOwner() { public String getOwner() {
return owner; return owner;
@ -128,6 +125,7 @@ public class Device {
public void setOwner(String owner) { public void setOwner(String owner) {
this.owner = owner; this.owner = owner;
} }
@XmlElement @XmlElement
public List<Feature> getFeatures() { public List<Feature> getFeatures() {
return features; return features;
@ -136,6 +134,7 @@ public class Device {
public void setFeatures(List<Feature> features) { public void setFeatures(List<Feature> features) {
this.features = features; this.features = features;
} }
@XmlElement @XmlElement
public String getType() { public String getType() {
return type; return type;
@ -144,6 +143,7 @@ public class Device {
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
@XmlElement @XmlElement
public List<Device.Property> getProperties() { public List<Device.Property> getProperties() {
return properties; return properties;

View File

@ -0,0 +1,53 @@
/*
*
* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* * WSO2 Inc. licenses this file to you under the Apache License,
* * Version 2.0 (the "License"); you may not use this file except
* * in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing,
* * software distributed under the License is distributed on an
* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* * KIND, either express or implied. See the License for the
* * specific language governing permissions and limitations
* * under the License.
* /
*/
package org.wso2.carbon.device.mgt.common;
public class License {
private String licenseName;
private String licenseText;
private String licenseVersion;
public String getLicenseName() {
return licenseName;
}
public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}
public String getLicenseText() {
return licenseText;
}
public void setLicenseText(String licenseText) {
this.licenseText = licenseText;
}
public String getLicenseVersion() {
return licenseVersion;
}
public void setLicenseVersion(String licenseVersion) {
this.licenseVersion = licenseVersion;
}
}

View File

@ -45,6 +45,7 @@ public class DeviceManagementRepository {
public void removeDeviceManagementProvider(DeviceManagerService provider) { public void removeDeviceManagementProvider(DeviceManagerService provider) {
String deviceType = provider.getProviderType(); String deviceType = provider.getProviderType();
try { try {
DeviceManagerUtil.unregisterDeviceType(deviceType); DeviceManagerUtil.unregisterDeviceType(deviceType);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
@ -56,5 +57,4 @@ public class DeviceManagementRepository {
public DeviceManagerService getDeviceManagementProvider(String type) { public DeviceManagerService getDeviceManagementProvider(String type) {
return providers.get(type); return providers.get(type);
} }
} }

View File

@ -147,7 +147,7 @@ public class DeviceManagementDAOTests {
DeviceType deviceType = new DeviceType(); DeviceType deviceType = new DeviceType();
deviceType.setId(Long.parseLong("1")); deviceType.setId(Long.parseLong("1"));
device.setDeviceType(deviceType.getId().intValue()); device.setDeviceTypeId(deviceType.getId().intValue());
device.setOwnerShip(OwnerShip.BYOD.toString()); device.setOwnerShip(OwnerShip.BYOD.toString());
device.setOwnerId("111"); device.setOwnerId("111");
device.setTenantId(-1234); device.setTenantId(-1234);

View File

@ -48,20 +48,20 @@ public interface FeaturePropertyDAO {
/** /**
* Delete a given feature property from feature property table. * Delete a given feature property from feature property table.
* *
* @param propertyId Id of the feature property to be deleted. * @param property Property of the feature property to be deleted.
* @return The status of the operation. If the operationId was successful or not. * @return The status of the operation. If the operationId was successful or not.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteFeatureProperty(int propertyId) throws MobileDeviceManagementDAOException; boolean deleteFeatureProperty(String property) throws MobileDeviceManagementDAOException;
/** /**
* Retrieve a given feature property from feature property table. * Retrieve a given feature property from feature property table.
* *
* @param propertyId Id of the feature property to be retrieved. * @param property Property of the feature property to be retrieved.
* @return Feature property object that holds data of the feature property represented by propertyId. * @return Feature property object that holds data of the feature property represented by propertyId.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
FeatureProperty getFeatureProperty(int propertyId) throws MobileDeviceManagementDAOException; FeatureProperty getFeatureProperty(String property) throws MobileDeviceManagementDAOException;
/** /**
* Retrieve a list of feature property corresponds to a feature id . * Retrieve a list of feature property corresponds to a feature id .

View File

@ -25,14 +25,14 @@ import java.util.List;
*/ */
public interface MobileDeviceDAO { public interface MobileDeviceDAO {
MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException; MobileDevice getMobileDevice(String deviceId) throws MobileDeviceManagementDAOException;
boolean addDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
boolean updateDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException; boolean deleteMobileDevice(String deviceId) throws MobileDeviceManagementDAOException;
List<MobileDevice> getAllDevices() throws MobileDeviceManagementDAOException; List<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException;
} }

View File

@ -53,16 +53,16 @@ public class MobileDeviceManagementDAOFactory implements DataSourceListener {
return new MobileDeviceDAOImpl(dataSource); return new MobileDeviceDAOImpl(dataSource);
} }
public static OperationDAO getOperationDAO() { public static MobileOperationDAO getMobileOperationDAO() {
return new OperationDAOImpl(dataSource); return new MobileOperationDAOImpl(dataSource);
} }
public static OperationPropertyDAO geOperationPropertyDAO() { public static MobileOperationPropertyDAO getMobileOperationPropertyDAO() {
return new OperationPropertyDAOImpl(dataSource); return new MobileOperationPropertyDAOImpl(dataSource);
} }
public static DeviceOperationDAO getDeviceOperationDAO() { public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() {
return new DeviceOperationDAOImpl(dataSource); return new MobileDeviceOperationDAOImpl(dataSource);
} }
public static FeatureDAO getFeatureDAO() { public static FeatureDAO getFeatureDAO() {

View File

@ -16,14 +16,14 @@
package org.wso2.carbon.device.mgt.mobile.dao; package org.wso2.carbon.device.mgt.mobile.dao;
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation; import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
import java.util.List; import java.util.List;
/** /**
* This class represents the mapping between device and operations. * This class represents the mapping between device and operations.
*/ */
public interface DeviceOperationDAO { public interface MobileDeviceOperationDAO {
/** /**
* Add a new mapping to plugin device_operation table. * Add a new mapping to plugin device_operation table.
* *
@ -32,7 +32,7 @@ public interface DeviceOperationDAO {
* @return The status of the operation. If the insert was successful or not. * @return The status of the operation. If the insert was successful or not.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean addDeviceOperation(DeviceOperation deviceOperation) boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
/** /**
@ -42,7 +42,7 @@ public interface DeviceOperationDAO {
* @return The status of the operation. If the update was successful or not. * @return The status of the operation. If the update was successful or not.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateDeviceOperation(DeviceOperation deviceOperation) boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
/** /**
@ -53,7 +53,7 @@ public interface DeviceOperationDAO {
* @return The status of the operation. If the deletion was successful or not. * @return The status of the operation. If the deletion was successful or not.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteDeviceOperation(String deviceId, int operationId) boolean deleteMobileDeviceOperation(String deviceId, int operationId)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
/** /**
@ -65,7 +65,7 @@ public interface DeviceOperationDAO {
* deviceId and operationId. * deviceId and operationId.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
DeviceOperation getDeviceOperation(String deviceId, int operationId) MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
/** /**
@ -74,6 +74,6 @@ public interface DeviceOperationDAO {
* @return Device operation mapping object list. * @return Device operation mapping object list.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
List<DeviceOperation> getAllDeviceOperationOfDevice(String deviceId) List<MobileDeviceOperation> getAllMobileDeviceOperationsOfDevice(String deviceId)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
} }

View File

@ -16,46 +16,44 @@
package org.wso2.carbon.device.mgt.mobile.dao; package org.wso2.carbon.device.mgt.mobile.dao;
import org.wso2.carbon.device.mgt.mobile.dto.Operation; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
import java.util.List;
/** /**
* This class represents the key operations associated with persisting operation related * This class represents the key operations associated with persisting operation related
* information. * information.
*/ */
public interface OperationDAO { public interface MobileOperationDAO {
/** /**
* Add a new operation to plugin operation table. * Add a new Mobile operation to plugin operation table.
* @param operation Operation object that holds data related to the operation to be inserted. * @param operation Operation object that holds data related to the operation to be inserted.
* @return The last inserted Id is returned, if the insertion was unsuccessful -1 is returned. * @return The last inserted Id is returned, if the insertion was unsuccessful -1 is returned.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
int addOperation(Operation operation) throws MobileDeviceManagementDAOException; int addMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException;
/** /**
* Update a operation in the operation table. * Update a Mobile operation in the operation table.
* @param operation Operation object that holds data has to be updated. * @param operation Operation object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not. * @return The status of the operation. If the update was successful or not.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateOperation(Operation operation) throws MobileDeviceManagementDAOException; boolean updateMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException;
/** /**
* Delete a given operation from plugin database. * Delete a given Mobile operation from plugin database.
* @param operationId Operation code of the operation to be deleted. * @param operationId Operation code of the operation to be deleted.
* @return The status of the operation. If the operationId was successful or not. * @return The status of the operation. If the operationId was successful or not.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteOperation(int operationId) throws MobileDeviceManagementDAOException; boolean deleteMobileOperation(int operationId) throws MobileDeviceManagementDAOException;
/** /**
* Retrieve a given operation from plugin database. * Retrieve a given Mobile operation from plugin database.
* @param operationId Operation id of the operation to be retrieved. * @param operationId Operation id of the operation to be retrieved.
* @return Operation object that holds data of the feature represented by operationId. * @return Operation object that holds data of the feature represented by operationId.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
Operation getOperation(int operationId) throws MobileDeviceManagementDAOException; MobileOperation getMobileOperation(int operationId) throws MobileDeviceManagementDAOException;
} }

View File

@ -16,7 +16,7 @@
package org.wso2.carbon.device.mgt.mobile.dao; package org.wso2.carbon.device.mgt.mobile.dao;
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
import java.util.List; import java.util.List;
@ -24,15 +24,16 @@ import java.util.List;
* This class represents the key operations associated with persisting operation property related * This class represents the key operations associated with persisting operation property related
* information. * information.
*/ */
public interface OperationPropertyDAO { public interface MobileOperationPropertyDAO {
/** /**
* Add a new mapping to plugin operation property table. * Add a new mapping to plugin operation property table.
* *
* @param operationProperty OperationProperty object that holds data related to the operation property to be inserted. * @param operationProperty OperationProperty object that holds data related to the operation
* property to be inserted.
* @return The status of the operation. If the insert was successful or not. * @return The status of the operation. If the insert was successful or not.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean addOperationProperty(OperationProperty operationProperty) boolean addMobileOperationProperty(MobileOperationProperty operationProperty)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
/** /**
@ -42,36 +43,38 @@ public interface OperationPropertyDAO {
* @return The status of the operation. If the update was successful or not. * @return The status of the operation. If the update was successful or not.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateOperationProperty(OperationProperty operationProperty) boolean updateMobileOperationProperty(MobileOperationProperty operationProperty)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
/** /**
* Delete a given device operation from plugin database. * Deletes mobile operation properties of a given operation id from the plugin database.
* *
* @param operationPropertyId Device id of the mapping to be deleted. * @param operationId Operation id of the mapping to be deleted.
* @return The status of the operation. If the deletion was successful or not. * @return The status of the operation. If the deletion was successful or not.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteOperationProperty(int operationPropertyId) boolean deleteMobileOperationProperties(int operationId)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
/** /**
* Retrieve a given device operation from plugin database. * Retrieve a given mobile operation property from plugin database.
* *
* @param deviceId Device id of the mapping to be retrieved.
* @param operationId Operation id of the mapping to be retrieved. * @param operationId Operation id of the mapping to be retrieved.
* @return DeviceOperation object that holds data of the device operation mapping represented by deviceId and operationId. * @param property Property of the mapping to be retrieved.
* @return DeviceOperation object that holds data of the device operation mapping represented by
* deviceId and operationId.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
OperationProperty getOperationProperty(String deviceId, int operationId) MobileOperationProperty getMobileOperationProperty(int operationId, String property)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
/** /**
* Retrieve all the device operation mapping from plugin database. * Retrieve all the mobile operation properties related to the a operation id.
* *
* @param operationId Operation id of the mapping to be retrieved.
* @return Device operation mapping object list. * @return Device operation mapping object list.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
List<OperationProperty> getAllDeviceOperationOfDevice(String deviceId) List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(int operationId)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
} }

View File

@ -32,7 +32,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* Implementation of FeatureDAO * Implementation of FeatureDAO.
*/ */
public class FeatureDAOImpl implements FeatureDAO { public class FeatureDAOImpl implements FeatureDAO {

View File

@ -32,7 +32,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* Implementation of FeaturePropertyDAO * Implementation of FeaturePropertyDAO.
*/ */
public class FeaturePropertyDAOImpl implements FeaturePropertyDAO { public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
@ -81,18 +81,17 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String updateDBQuery = String updateDBQuery =
"UPDATE MBL_FEATURE_PROPERTY SET PROPERTY = ?, FEATURE_ID = ? WHERE PROPERTY_ID = ?"; "UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?";
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, featureProperty.getProperty()); stmt.setString(1, featureProperty.getFeatureID());
stmt.setString(2, featureProperty.getFeatureID()); stmt.setString(2, featureProperty.getProperty());
stmt.setInt(3, featureProperty.getPropertyId());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating the feature property with property id - '" + String msg = "Error occurred while updating the feature property with property - '" +
featureProperty.getPropertyId() + "'"; featureProperty.getProperty() + "'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -102,7 +101,7 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
} }
@Override @Override
public boolean deleteFeatureProperty(int propertyId) public boolean deleteFeatureProperty(String property)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -110,16 +109,16 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String deleteDBQuery = String deleteDBQuery =
"DELETE FROM MBL_FEATURE_PROPERTY WHERE PROPERTY_ID = ?"; "DELETE FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, propertyId); stmt.setString(1, property);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while deleting feature property with property Id - " + String msg = "Error occurred while deleting feature property with property - " +
propertyId; property;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -129,7 +128,7 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
} }
@Override @Override
public FeatureProperty getFeatureProperty(int propertyId) public FeatureProperty getFeatureProperty(String property)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -137,9 +136,9 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY_ID = ?"; "SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, propertyId); stmt.setString(1, property);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
featureProperty = new FeatureProperty(); featureProperty = new FeatureProperty();
@ -148,8 +147,8 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
break; break;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching property Id - '" + String msg = "Error occurred while fetching property - '" +
propertyId + "'"; property + "'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -168,15 +167,14 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT PROPERTY_ID,PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; "SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, featureId); stmt.setString(1, featureId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
featureProperty = new FeatureProperty(); featureProperty = new FeatureProperty();
featureProperty.setPropertyId(resultSet.getInt(1)); featureProperty.setProperty(resultSet.getString(1));
featureProperty.setProperty(resultSet.getString(2)); featureProperty.setFeatureID(resultSet.getString(2));
featureProperty.setFeatureID(resultSet.getString(3));
FeatureProperties.add(featureProperty); FeatureProperties.add(featureProperty);
} }
return FeatureProperties; return FeatureProperties;

View File

@ -44,7 +44,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
} }
@Override @Override
public MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException { public MobileDevice getMobileDevice(String deviceId) throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileDevice mobileDevice = null; MobileDevice mobileDevice = null;
@ -80,7 +80,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
} }
@Override @Override
public boolean addDevice(MobileDevice mobileDevice) public boolean addMobileDevice(MobileDevice mobileDevice)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -106,8 +106,8 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
status = true; status = true;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while enrolling mobile device '" + String msg = "Error occurred while adding the mobile device '" +
mobileDevice.getMobileDeviceId() + "'"; mobileDevice.getMobileDeviceId() + "' to the mobile db.";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -117,7 +117,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
} }
@Override @Override
public boolean updateDevice(MobileDevice mobileDevice) public boolean updateMobileDevice(MobileDevice mobileDevice)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -153,7 +153,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
} }
@Override @Override
public boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException { public boolean deleteMobileDevice(String deviceId) throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -178,7 +178,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
} }
@Override @Override
public List<MobileDevice> getAllDevices() throws MobileDeviceManagementDAOException { public List<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileDevice mobileDevice; MobileDevice mobileDevice;

View File

@ -18,10 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.DeviceOperationDAO; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceOperationDAO;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation; import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
@ -32,19 +32,19 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* Implementation of DeviceOperationDAO * Implementation of MobileDeviceOperationDAO.
*/ */
public class DeviceOperationDAOImpl implements DeviceOperationDAO { public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO {
private DataSource dataSource; private DataSource dataSource;
private static final Log log = LogFactory.getLog(DeviceOperationDAOImpl.class); private static final Log log = LogFactory.getLog(MobileDeviceOperationDAOImpl.class);
public DeviceOperationDAOImpl(DataSource dataSource) { public MobileDeviceOperationDAOImpl(DataSource dataSource) {
this.dataSource = dataSource; this.dataSource = dataSource;
} }
@Override @Override
public boolean addDeviceOperation(DeviceOperation deviceOperation) public boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -66,7 +66,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while adding device id - '" + String msg = "Error occurred while adding device id - '" +
deviceOperation.getDeviceId() + " and operation id - " + deviceOperation.getDeviceId() + " and operation id - " +
deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION"; deviceOperation.getOperationId() +
" to mapping table MBL_DEVICE_OPERATION";
; ;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
@ -77,7 +78,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
} }
@Override @Override
public boolean updateDeviceOperation(DeviceOperation deviceOperation) public boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -85,7 +86,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String updateDBQuery = String updateDBQuery =
"UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? and OPERATION_ID=?"; "UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?";
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setLong(1, deviceOperation.getSentDate()); stmt.setLong(1, deviceOperation.getSentDate());
stmt.setLong(2, deviceOperation.getReceivedDate()); stmt.setLong(2, deviceOperation.getReceivedDate());
@ -98,7 +99,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating device id - '" + String msg = "Error occurred while updating device id - '" +
deviceOperation.getDeviceId() + " and operation id - " + deviceOperation.getDeviceId() + " and operation id - " +
deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION"; deviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -108,7 +109,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
} }
@Override @Override
public boolean deleteDeviceOperation(String deviceId, int operationId) public boolean deleteMobileDeviceOperation(String deviceId, int operationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -116,7 +117,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String deleteDBQuery = String deleteDBQuery =
"DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? and OPERATION_ID=?"; "DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, deviceId);
stmt.setInt(2, operationId); stmt.setInt(2, operationId);
@ -126,7 +127,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while deleting mapping table MBL_DEVICE_OPERATION with device id - '" + "Error occurred while deleting the table entry MBL_DEVICE_OPERATION with device id - '" +
deviceId + " and operation id - " + operationId; deviceId + " and operation id - " + operationId;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
@ -137,21 +138,21 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
} }
@Override @Override
public DeviceOperation getDeviceOperation(String deviceId, int operationId) public MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
DeviceOperation deviceOperation = null; MobileDeviceOperation deviceOperation = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? and OPERATION_ID=?"; "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, deviceId);
stmt.setInt(2, operationId); stmt.setInt(2, operationId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
deviceOperation = new DeviceOperation(); deviceOperation = new MobileDeviceOperation();
deviceOperation.setDeviceId(resultSet.getString(1)); deviceOperation.setDeviceId(resultSet.getString(1));
deviceOperation.setOperationId(resultSet.getInt(2)); deviceOperation.setOperationId(resultSet.getInt(2));
deviceOperation.setSentDate(resultSet.getInt(3)); deviceOperation.setSentDate(resultSet.getInt(3));
@ -160,7 +161,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" + "Error occurred while fetching table MBL_DEVICE_OPERATION entry with device id - '" +
deviceId + " and operation id - " + operationId; deviceId + " and operation id - " + operationId;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
@ -171,12 +172,12 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
} }
@Override @Override
public List<DeviceOperation> getAllDeviceOperationOfDevice(String deviceId) public List<MobileDeviceOperation> getAllMobileDeviceOperationsOfDevice(String deviceId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
DeviceOperation deviceOperation = null; MobileDeviceOperation deviceOperation = null;
List<DeviceOperation> deviceOperations = new ArrayList<DeviceOperation>(); List<MobileDeviceOperation> deviceOperations = new ArrayList<MobileDeviceOperation>();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
@ -185,17 +186,16 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
stmt.setString(1, deviceId); stmt.setString(1, deviceId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
deviceOperation = new DeviceOperation(); deviceOperation = new MobileDeviceOperation();
deviceOperation.setDeviceId(resultSet.getString(1)); deviceOperation.setDeviceId(resultSet.getString(1));
deviceOperation.setOperationId(resultSet.getInt(2)); deviceOperation.setOperationId(resultSet.getInt(2));
deviceOperation.setSentDate(resultSet.getInt(3)); deviceOperation.setSentDate(resultSet.getInt(3));
deviceOperation.setReceivedDate(resultSet.getInt(4)); deviceOperation.setReceivedDate(resultSet.getInt(4));
deviceOperations.add(deviceOperation); deviceOperations.add(deviceOperation);
break;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" + "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of device id - '" +
deviceId; deviceId;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);

View File

@ -19,9 +19,9 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.OperationDAO; import org.wso2.carbon.device.mgt.mobile.dao.MobileOperationDAO;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.dto.Operation; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
@ -30,19 +30,19 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
/** /**
* Implementation of OperationDAO * Implementation of MobileOperationDAO.
*/ */
public class OperationDAOImpl implements OperationDAO { public class MobileOperationDAOImpl implements MobileOperationDAO {
private DataSource dataSource; private DataSource dataSource;
private static final Log log = LogFactory.getLog(OperationDAOImpl.class); private static final Log log = LogFactory.getLog(MobileOperationDAOImpl.class);
public OperationDAOImpl(DataSource dataSource) { public MobileOperationDAOImpl(DataSource dataSource) {
this.dataSource = dataSource; this.dataSource = dataSource;
} }
@Override @Override
public int addOperation(Operation operation) public int addMobileOperation(MobileOperation operation)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
int status = -1; int status = -1;
Connection conn = null; Connection conn = null;
@ -51,7 +51,6 @@ public class OperationDAOImpl implements OperationDAO {
conn = this.getConnection(); conn = this.getConnection();
String createDBQuery = String createDBQuery =
"INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)"; "INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)";
stmt = conn.prepareStatement(createDBQuery, new String[] { "OPERATION_ID" }); stmt = conn.prepareStatement(createDBQuery, new String[] { "OPERATION_ID" });
stmt.setString(1, operation.getFeatureCode()); stmt.setString(1, operation.getFeatureCode());
stmt.setLong(2, operation.getCreatedDate()); stmt.setLong(2, operation.getCreatedDate());
@ -63,8 +62,8 @@ public class OperationDAOImpl implements OperationDAO {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while adding feature code - '" + String msg = "Error occurred while adding the operation - '" +
operation.getFeatureCode() + "' to operations table"; operation.getFeatureCode() + "' to MBL_OPERATION table";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -74,7 +73,7 @@ public class OperationDAOImpl implements OperationDAO {
} }
@Override @Override
public boolean updateOperation(Operation operation) public boolean updateMobileOperation(MobileOperation operation)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -92,7 +91,7 @@ public class OperationDAOImpl implements OperationDAO {
status = true; status = true;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating the operation with operation id - '" + String msg = "Error occurred while updating the MBL_OPERATION table entry with operation id - '" +
operation.getOperationId() + "'"; operation.getOperationId() + "'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
@ -103,7 +102,7 @@ public class OperationDAOImpl implements OperationDAO {
} }
@Override @Override
public boolean deleteOperation(int operationId) public boolean deleteMobileOperation(int operationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -119,7 +118,7 @@ public class OperationDAOImpl implements OperationDAO {
status = true; status = true;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while deleting operation with operation Id - "; String msg = "Error occurred while deleting MBL_OPERATION entry with operation Id - ";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -129,11 +128,11 @@ public class OperationDAOImpl implements OperationDAO {
} }
@Override @Override
public Operation getOperation(int operationId) public MobileOperation getMobileOperation(int operationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
Operation operation = null; MobileOperation operation = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
@ -142,13 +141,13 @@ public class OperationDAOImpl implements OperationDAO {
stmt.setInt(1, operation.getOperationId()); stmt.setInt(1, operation.getOperationId());
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
operation = new Operation(); operation = new MobileOperation();
operation.setOperationId(resultSet.getInt(1)); operation.setOperationId(resultSet.getInt(1));
break; break;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching operationId - '" + String msg = "Error occurred while fetching operationId - '" +
operationId + "'"; operationId + "' from MBL_OPERATION";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {

View File

@ -0,0 +1,212 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileOperationPropertyDAO;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* Implementation of MobileOperationPropertyDAO.
*/
public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(MobileOperationPropertyDAOImpl.class);
public MobileOperationPropertyDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public boolean addMobileOperationProperty(MobileOperationProperty operationProperty)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) VALUES ( ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setInt(1, operationProperty.getOperationId());
stmt.setString(2, operationProperty.getProperty());
stmt.setString(3, operationProperty.getValue());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg =
"Error occurred while adding mobile operation property to MBL_OPERATION_PROPERTY table";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean updateMobileOperationProperty(
MobileOperationProperty operationProperty)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND PROPERTY = ?";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, operationProperty.getValue());
stmt.setInt(2, operationProperty.getOperationId());
stmt.setString(3, operationProperty.getProperty());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg =
"Error occurred while updating the mobile operation property in MBL_OPERATION_PROPERTY table.";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean deleteMobileOperationProperties(int operationId)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, operationId);
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg =
"Error occurred while deleting MBL_OPERATION_PROPERTY entry with operation Id - ";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public MobileOperationProperty getMobileOperationProperty(int operationId,
String property)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
MobileOperationProperty mobileOperationProperty = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ? AND PROPERTY = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, operationId);
stmt.setString(2, property);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
mobileOperationProperty = new MobileOperationProperty();
mobileOperationProperty.setOperationId(resultSet.getInt(1));
mobileOperationProperty.setProperty(resultSet.getString(2));
mobileOperationProperty.setValue(resultSet.getString(3));
break;
}
} catch (SQLException e) {
String msg =
"Error occurred while fetching the mobile operation property of Operation_id : " +
operationId + " and Property : " + property;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return mobileOperationProperty;
}
@Override
public List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(
int operationId) throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
MobileOperationProperty mobileOperationProperty = null;
List<MobileOperationProperty> properties = new ArrayList<MobileOperationProperty>();
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, operationId);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
mobileOperationProperty = new MobileOperationProperty();
mobileOperationProperty.setOperationId(resultSet.getInt(1));
mobileOperationProperty.setProperty(resultSet.getString(2));
mobileOperationProperty.setValue(resultSet.getString(3));
properties.add(mobileOperationProperty);
}
} catch (SQLException e) {
String msg =
"Error occurred while fetching the mobile operation properties of Operation_id " +
operationId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return properties;
}
private Connection getConnection() throws MobileDeviceManagementDAOException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
String msg = "Error occurred while obtaining a connection from the mobile device " +
"management metadata repository datasource.";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
}
}
}

View File

@ -1,103 +0,0 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.OperationPropertyDAO;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
/**
* Implementation of OperationPropertyDAO
*/
public class OperationPropertyDAOImpl implements OperationPropertyDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(OperationPropertyDAOImpl.class);
public OperationPropertyDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public boolean addOperationProperty(OperationProperty operationProperty)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY_ID, VALUE) VALUES ( ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setInt(1, operationProperty.getOperationId());
stmt.setInt(2, operationProperty.getPropertyId());
stmt.setString(3, operationProperty.getValue());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while adding feature property to operation property table";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override public boolean updateOperationProperty(OperationProperty operationProperty)
throws MobileDeviceManagementDAOException {
return false;
}
@Override public boolean deleteOperationProperty(int operationPropertyId)
throws MobileDeviceManagementDAOException {
return false;
}
@Override public OperationProperty getOperationProperty(String deviceId, int operationId)
throws MobileDeviceManagementDAOException {
return null;
}
@Override public List<OperationProperty> getAllDeviceOperationOfDevice(String deviceId)
throws MobileDeviceManagementDAOException {
return null;
}
private Connection getConnection() throws MobileDeviceManagementDAOException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
String msg = "Error occurred while obtaining a connection from the mobile device " +
"management metadata repository datasource.";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
}
}
}

View File

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.mobile.dto;
*/ */
public class FeatureProperty { public class FeatureProperty {
private int propertyId;
private String property; private String property;
private String featureID; private String featureID;
@ -33,14 +32,6 @@ public class FeatureProperty {
this.featureID = featureID; this.featureID = featureID;
} }
public int getPropertyId() {
return propertyId;
}
public void setPropertyId(int propertyId) {
this.propertyId = propertyId;
}
public String getProperty() { public String getProperty() {
return property; return property;
} }

View File

@ -17,9 +17,9 @@
package org.wso2.carbon.device.mgt.mobile.dto; package org.wso2.carbon.device.mgt.mobile.dto;
/** /**
* DTO of Operations. * DTO of Mobile Device Operations.
*/ */
public class DeviceOperation { public class MobileDeviceOperation {
private String deviceId; private String deviceId;
private int operationId; private int operationId;

View File

@ -19,14 +19,14 @@ package org.wso2.carbon.device.mgt.mobile.dto;
import java.util.List; import java.util.List;
/** /**
* DTO of operation. * DTO of MobileOperation.
*/ */
public class Operation { public class MobileOperation {
private int operationId; private int operationId;
private String featureCode; private String featureCode;
private long createdDate; private long createdDate;
private List<OperationProperty> properties; private List<MobileOperationProperty> properties;
public int getOperationId() { public int getOperationId() {
return operationId; return operationId;
@ -36,11 +36,11 @@ public class Operation {
this.operationId = operationId; this.operationId = operationId;
} }
public List<OperationProperty> getProperties() { public List<MobileOperationProperty> getProperties() {
return properties; return properties;
} }
public void setProperties(List<OperationProperty> properties) { public void setProperties(List<MobileOperationProperty> properties) {
this.properties = properties; this.properties = properties;
} }

View File

@ -17,13 +17,12 @@
package org.wso2.carbon.device.mgt.mobile.dto; package org.wso2.carbon.device.mgt.mobile.dto;
/** /**
* DTO of operation property. * DTO of Mobile Operation property.
*/ */
public class OperationProperty { public class MobileOperationProperty {
private int operationPropertyId;
private int operationId; private int operationId;
private int propertyId; private String property;
private String value; private String value;
public String getValue() { public String getValue() {
@ -34,14 +33,6 @@ public class OperationProperty {
this.value = value; this.value = value;
} }
public int getOperationPropertyId() {
return operationPropertyId;
}
public void setOperationPropertyId(int operationPropertyId) {
this.operationPropertyId = operationPropertyId;
}
public int getOperationId() { public int getOperationId() {
return operationId; return operationId;
} }
@ -50,12 +41,12 @@ public class OperationProperty {
this.operationId = operationId; this.operationId = operationId;
} }
public int getPropertyId() { public String getProperty() {
return propertyId; return property;
} }
public void setPropertyId(int propertyId) { public void setProperty(String property) {
this.propertyId = propertyId; this.property = property;
} }
} }

View File

@ -50,7 +50,8 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
boolean status; boolean status;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try { try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addDevice(mobileDevice); status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
mobileDevice);
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while enrolling the Android device : " + String msg = "Error while enrolling the Android device : " +
device.getDeviceIdentifier(); device.getDeviceIdentifier();
@ -66,7 +67,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try { try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO() status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.updateDevice(mobileDevice); .updateMobileDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while updating the enrollment of the Android device : " + String msg = "Error while updating the enrollment of the Android device : " +
device.getDeviceIdentifier(); device.getDeviceIdentifier();
@ -81,7 +82,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
boolean status; boolean status;
try { try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO() status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.deleteDevice(deviceId.getId()); .deleteMobileDevice(deviceId.getId());
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while removing the Android device : " + deviceId.getId(); String msg = "Error while removing the Android device : " + deviceId.getId();
log.error(msg, e); log.error(msg, e);
@ -95,7 +96,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
boolean isEnrolled = false; boolean isEnrolled = false;
try { try {
MobileDevice mobileDevice = MobileDevice mobileDevice =
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getDevice( MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
deviceId.getId()); deviceId.getId());
if (mobileDevice != null) { if (mobileDevice != null) {
isEnrolled = true; isEnrolled = true;
@ -125,7 +126,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
Device device; Device device;
try { try {
MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO(). MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
getDevice(deviceId.getId()); getMobileDevice(deviceId.getId());
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice); device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while fetching the Android device : " + deviceId.getId(); String msg = "Error while fetching the Android device : " + deviceId.getId();
@ -147,7 +148,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try { try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO() status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.updateDevice(mobileDevice); .updateMobileDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while updating the Android device : " + device.getDeviceIdentifier(); String msg = "Error while updating the Android device : " + device.getDeviceIdentifier();
log.error(msg, e); log.error(msg, e);
@ -162,7 +163,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
try { try {
List<MobileDevice> mobileDevices = List<MobileDevice> mobileDevices =
MobileDeviceManagementDAOFactory.getMobileDeviceDAO(). MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
getAllDevices(); getAllMobileDevices();
if (mobileDevices != null) { if (mobileDevices != null) {
devices = new ArrayList<Device>(); devices = new ArrayList<Device>();
for (MobileDevice mobileDevice : mobileDevices) { for (MobileDevice mobileDevice : mobileDevices) {

View File

@ -18,15 +18,17 @@ package org.wso2.carbon.device.mgt.mobile.impl.android;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.Operation; import org.wso2.carbon.device.mgt.common.Operation;
import org.wso2.carbon.device.mgt.common.OperationManagementException; import org.wso2.carbon.device.mgt.common.OperationManagementException;
import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager; import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation; import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class AndroidMobileOperationManager extends AbstractMobileOperationManager { public class AndroidMobileOperationManager extends AbstractMobileOperationManager {
@ -36,26 +38,67 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
@Override @Override
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
OperationManagementException { OperationManagementException {
boolean status = false;
try { try {
MobileDeviceManagementDAOFactory.getOperationDAO().addOperation( MobileDeviceOperation mobileDeviceOperation = null;
new org.wso2.carbon.device.mgt.mobile.dto.Operation()); MobileOperation mobileOperation =
MobileDeviceManagementDAOFactory.geOperationPropertyDAO() MobileDeviceManagementUtil.convertToMobileOperation(operation);
.addOperationProperty(new OperationProperty()); int operationId = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
MobileDeviceManagementDAOFactory.getDeviceOperationDAO() .addMobileOperation(mobileOperation);
.addDeviceOperation(new DeviceOperation()); if (operationId > 0) {
for (MobileOperationProperty operationProperty : mobileOperation.getProperties()) {
operationProperty.setOperationId(operationId);
status = MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO()
.addMobileOperationProperty(
operationProperty);
}
for (DeviceIdentifier deviceIdentifier : devices) {
mobileDeviceOperation = new MobileDeviceOperation();
mobileDeviceOperation.setOperationId(operationId);
mobileDeviceOperation.setDeviceId(deviceIdentifier.getId());
status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
.addMobileDeviceOperation(
new MobileDeviceOperation());
}
}
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while updating the enrollment of the Android device : " + String msg =
devices.get(0).getId(); "Error while adding an operation " + operation.getCode() + "to Android devices";
log.error(msg, e); log.error(msg, e);
throw new OperationManagementException(msg, e); throw new OperationManagementException(msg, e);
} }
return false; return status;
} }
@Override @Override
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
throws OperationManagementException { throws OperationManagementException {
return null; List<Operation> operations = new ArrayList<Operation>();
List<MobileDeviceOperation> mobileDeviceOperations = null;
MobileOperation mobileOperation = null;
try {
mobileDeviceOperations = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
.getAllMobileDeviceOperationsOfDevice(
deviceIdentifier
.getId());
if (mobileDeviceOperations.size() > 0) {
List<Integer> operationIds = MobileDeviceManagementUtil
.getMobileOperationIdsFromMobileDeviceOperations(mobileDeviceOperations);
for (Integer operationId : operationIds) {
mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
.getMobileOperation(
operationId);
operations.add(MobileDeviceManagementUtil
.convertMobileOperationToOperation(mobileOperation));
}
}
} catch (MobileDeviceManagementDAOException e) {
String msg =
"Error while fetching the operations for the android device " +
deviceIdentifier.getId();
log.error(msg, e);
throw new OperationManagementException(msg, e);
}
return operations;
} }
} }

View File

@ -21,9 +21,11 @@ import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.Operation;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.dto.Operation; import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -114,15 +116,41 @@ public class MobileDeviceManagementUtil {
return device; return device;
} }
public static Operation convertToOperation(org.wso2.carbon.device.mgt.common.Operation operation){ public static MobileOperation convertToMobileOperation(
Operation mobileOperation = new Operation(); org.wso2.carbon.device.mgt.common.Operation operation) {
List<OperationProperty> properties = new LinkedList<OperationProperty>(); MobileOperation mobileOperation = new MobileOperation();
MobileOperationProperty operationProperty = null;
List<MobileOperationProperty> properties = new LinkedList<MobileOperationProperty>();
mobileOperation.setFeatureCode(operation.getCode()); mobileOperation.setFeatureCode(operation.getCode());
mobileOperation.setCreatedDate(new Date().getTime()); mobileOperation.setCreatedDate(new Date().getTime());
Properties operationProperties = operation.getProperties(); Properties operationProperties = operation.getProperties();
for (String key : operationProperties.stringPropertyNames()) { for (String key : operationProperties.stringPropertyNames()) {
String value = operationProperties.getProperty(key); operationProperty = new MobileOperationProperty();
operationProperty.setProperty(key);
operationProperty.setValue(operationProperties.getProperty(key));
properties.add(operationProperty);
} }
mobileOperation.setProperties(properties);
return mobileOperation; return mobileOperation;
} }
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
List<MobileDeviceOperation> mobileDeviceOperations) {
List<Integer> mobileOperationIds = new ArrayList<Integer>();
for(MobileDeviceOperation mobileDeviceOperation:mobileDeviceOperations){
mobileOperationIds.add(mobileDeviceOperation.getOperationId());
}
return mobileOperationIds;
}
public static Operation convertMobileOperationToOperation(MobileOperation mobileOperation){
Operation operation = new Operation();
Properties properties = new Properties();
operation.setCode(mobileOperation.getFeatureCode());
for(MobileOperationProperty mobileOperationProperty:mobileOperation.getProperties()){
properties.put(mobileOperationProperty.getProperty(),mobileOperationProperty.getValue());
}
operation.setProperties(properties);
return operation;
}
} }

View File

@ -78,6 +78,10 @@
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>org.wso2.carbon.logging</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.evaluator;
import org.wso2.carbon.policy.mgt.common.Feature;
import org.wso2.carbon.policy.mgt.common.Policy;
import java.util.List;
import java.util.Map;
public interface FeatureFilter {
List<Feature> evaluate(List<Policy> policyList, List<FeatureRules> featureRulesList);
List<Feature> extractFeatures(List<Policy> policyList);
List<Feature> evaluateFeatures(List<Feature> featureList, List<FeatureRules> featureRulesList);
void getDenyOverridesFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
void getPermitOverridesFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
void getFirstApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
void getLastApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
void getAllApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
void getHighestApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
void getLowestApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
}

View File

@ -0,0 +1,250 @@
/*
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.evaluator;
import org.wso2.carbon.policy.evaluator.utils.Constants;
import org.wso2.carbon.policy.mgt.common.Feature;
import org.wso2.carbon.policy.mgt.common.Policy;
import java.util.ArrayList;
import java.util.List;
/**
* This class is responsible for evaluating the policy (Configurations sets) and returning
* the effective features set.
*/
public class FeatureFilterImpl implements FeatureFilter {
/**
* This method returns the effective feature list when policy list and feature aggregation rules are supplied.
* @param policyList
* @param featureRulesList
* @return
*/
@Override
public List<Feature> evaluate(List<Policy> policyList, List<FeatureRules> featureRulesList) {
return evaluateFeatures(extractFeatures(policyList), featureRulesList);
}
/**
* This method extract the features from the given policy list in the order they are provided in the list.
* @param policyList
* @return
*/
public List<Feature> extractFeatures(List<Policy> policyList) {
List<Feature> featureList = new ArrayList<Feature>();
for (Policy policy : policyList) {
featureList.addAll(policy.getFeaturesList());
}
return featureList;
}
/**
* This method is responsible for supplying tasks to other methods to evaluate given features.
* @param featureList
* @param featureRulesList
* @return
*/
public List<Feature> evaluateFeatures(List<Feature> featureList, List<FeatureRules> featureRulesList) {
List<Feature> effectiveFeatureList = new ArrayList<Feature>();
for (FeatureRules rule : featureRulesList) {
String ruleName = rule.getEvaluationCriteria();
String featureName = rule.getName();
if (ruleName.equalsIgnoreCase(Constants.DENY_OVERRIDES)) {
getDenyOverridesFeatures(featureName, featureList, effectiveFeatureList);
}
if (ruleName.equalsIgnoreCase(Constants.PERMIT_OVERRIDES)) {
getPermitOverridesFeatures(featureName, featureList, effectiveFeatureList);
}
if (ruleName.equalsIgnoreCase(Constants.FIRST_APPLICABLE)) {
getFirstApplicableFeatures(featureName, featureList, effectiveFeatureList);
}
if (ruleName.equalsIgnoreCase(Constants.LAST_APPLICABLE)) {
getLastApplicableFeatures(featureName, featureList, effectiveFeatureList);
}
if (ruleName.equalsIgnoreCase(Constants.ALL_APPLICABLE)) {
getAllApplicableFeatures(featureName, featureList, effectiveFeatureList);
}
if (ruleName.equalsIgnoreCase(Constants.HIGHEST_APPLICABLE)) {
getHighestApplicableFeatures(featureName, featureList, effectiveFeatureList);
}
if (ruleName.equalsIgnoreCase(Constants.LOWEST_APPLICABLE)) {
getLowestApplicableFeatures(featureName, featureList, effectiveFeatureList);
}
}
return effectiveFeatureList;
}
/**
* This method picks up denied features, if there is no denied features it will add to the list, the final permitted feature.
* But if given policies do not have features of given type, it will not add anything.
*
* @param featureName
* @param featureList
* @param effectiveFeatureList
*/
public void getDenyOverridesFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
Feature evaluatedFeature = null;
for (Feature feature : featureList) {
if (feature.getName().equalsIgnoreCase(featureName)) {
if (feature.getRuleValue().equalsIgnoreCase("Deny")) {
evaluatedFeature = feature;
effectiveFeatureList.add(evaluatedFeature);
return;
} else {
evaluatedFeature = feature;
}
}
}
if (evaluatedFeature != null) {
effectiveFeatureList.add(evaluatedFeature);
}
}
/**
* This method picks up permitted features, if there is no permitted features it will add to the list, the final denied feature.
* But if given policies do not have features of given type, it will not add anything.
*
* @param featureName
* @param featureList
* @param effectiveFeatureList
*/
public void getPermitOverridesFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
Feature evaluatedFeature = null;
for (Feature feature : featureList) {
if (feature.getName().equalsIgnoreCase(featureName)) {
if (feature.getRuleValue().equalsIgnoreCase("Permit")) {
evaluatedFeature = feature;
effectiveFeatureList.add(evaluatedFeature);
return;
} else {
evaluatedFeature = feature;
}
}
}
if (evaluatedFeature != null) {
effectiveFeatureList.add(evaluatedFeature);
}
}
/**
* This method picks the first features of the give type.
* But if given policies do not have features of given type, it will not add anything.
*
* @param featureName
* @param featureList
* @param effectiveFeatureList
*/
public void getFirstApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
for (Feature feature : featureList) {
if (feature.getName().equalsIgnoreCase(featureName)) {
effectiveFeatureList.add(feature);
return;
}
}
}
/**
* This method picks the last features of the give type.
* But if given policies do not have features of given type, it will not add anything.
*
* @param featureName
* @param featureList
* @param effectiveFeatureList
*/
public void getLastApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
Feature evaluatedFeature = null;
for (Feature feature : featureList) {
if (feature.getName().equalsIgnoreCase(featureName)) {
evaluatedFeature = feature;
}
}
if (evaluatedFeature != null) {
effectiveFeatureList.add(evaluatedFeature);
}
}
/**
* This method picks the all features of the give type.
* But if given policies do not have features of given type, it will not add anything.
*
* @param featureName
* @param featureList
* @param effectiveFeatureList
*/
public void getAllApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
for (Feature feature : featureList) {
if (feature.getName().equalsIgnoreCase(featureName)) {
effectiveFeatureList.add(feature);
}
}
}
/**
* This method picks the feature with the highest value of given type.
* But if given policies do not have features of given type, it will not add anything.
*
* @param featureName
* @param featureList
* @param effectiveFeatureList
*/
public void getHighestApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
Feature evaluatedFeature = null;
int intValve = 0;
for (Feature feature : featureList) {
if (feature.getName().equalsIgnoreCase(featureName)) {
if (Integer.parseInt(feature.getRuleValue()) > intValve) {
intValve = Integer.parseInt(feature.getRuleValue());
evaluatedFeature = feature;
}
}
}
if (evaluatedFeature != null) {
effectiveFeatureList.add(evaluatedFeature);
}
}
/**
* This method picks the feature with the lowest value of given type.
* But if given policies do not have features of given type, it will not add anything.
*
* @param featureName
* @param featureList
* @param effectiveFeatureList
*/
public void getLowestApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
Feature evaluatedFeature = null;
int intValve = 0;
for (Feature feature : featureList) {
if (feature.getName().equalsIgnoreCase(featureName)) {
if (Integer.parseInt(feature.getRuleValue()) < intValve) {
intValve = Integer.parseInt(feature.getRuleValue());
evaluatedFeature = feature;
}
}
}
if (evaluatedFeature != null) {
effectiveFeatureList.add(evaluatedFeature);
}
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.evaluator;
public class FeatureRules {
private String name;
private String evaluationCriteria;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEvaluationCriteria() {
return evaluationCriteria;
}
public void setEvaluationCriteria(String evaluationCriteria) {
this.evaluationCriteria = evaluationCriteria;
}
}

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.evaluator;
import org.wso2.carbon.policy.evaluator.spi.PDPService;
import org.wso2.carbon.policy.mgt.common.Feature;
import org.wso2.carbon.policy.mgt.common.Policy;
import java.util.List;
public class PDPServiceImpl implements PDPService {
@Override
public List<Policy> getEffectivePolicyList(List<Policy> policies, List<String> roles, String deviceType) {
return null;
}
@Override
public List<Feature> getEffectiveFeatureList(List<Policy> policies, List<FeatureRules> featureRulesList) {
return null;
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.evaluator;
import org.wso2.carbon.policy.mgt.common.Policy;
import java.util.List;
public interface PolicyFilter {
/**
* This method will extract the policies related a given roles list from the policy list available.
* @param policyList
* @param roles
* @return
*/
public List<Policy> extractPoliciesRelatedToRoles(List<Policy> policyList, List<String> roles);
/**
* This mehtod extract the policies related to a given device type from policy list.
* @param policyList
* @param deviceType
* @return
*/
public List<Policy> extractPoliciesRelatedToDeviceType(List<Policy> policyList, String deviceType);
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.evaluator;
import org.wso2.carbon.policy.mgt.common.Policy;
import java.util.ArrayList;
import java.util.List;
public class PolicyFilterImpl implements PolicyFilter {
/**
* This method will extract the policies related a given roles list from the policy list available.
*
* @param policyList
* @param roles
* @return
*/
@Override
public List<Policy> extractPoliciesRelatedToRoles(List<Policy> policyList, List<String> roles) {
List<Policy> policies = new ArrayList<Policy>();
for (Policy policy : policyList) {
List<String> roleList = policy.getRoleList();
for (String role : roleList) {
if (roles.contains(role)) {
policies.add(policy);
break;
}
}
}
return policies;
}
/**
* This mehtod extract the policies related to a given device type from policy list.
*
* @param policyList
* @param deviceType
* @return
*/
@Override
public List<Policy> extractPoliciesRelatedToDeviceType(List<Policy> policyList, String deviceType) {
List<Policy> policies = new ArrayList<Policy>();
for (Policy policy : policyList) {
if (policy.getDeviceType().equalsIgnoreCase(deviceType)) {
policies.add(policy);
}
}
return policies;
}
}

View File

@ -1,21 +1,34 @@
/* /*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * WSO2 Inc. licenses this file to you under the Apache License,
* you may not use this file except in compliance with the License. * Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing,
* distributed under the License is distributed on an "AS IS" BASIS, * software distributed under the License is distributed on an
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* See the License for the specific language governing permissions and * KIND, either express or implied. See the License for the
* limitations under the License. * specific language governing permissions and limitations
* under the License.
*/ */
package org.wso2.carbon.policy.evaluator.spi; package org.wso2.carbon.policy.evaluator.spi;
import org.wso2.carbon.policy.evaluator.FeatureRules;
import org.wso2.carbon.policy.mgt.common.Feature;
import org.wso2.carbon.policy.mgt.common.Policy;
import java.util.List;
public interface PDPService { public interface PDPService {
List<Policy> getEffectivePolicyList(List<Policy> policies, List<String> roles, String deviceType);
List<Feature> getEffectiveFeatureList(List<Policy> policies, List<FeatureRules> featureRulesList);
} }

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.evaluator.utils;
public class Constants {
public static final String DENY_OVERRIDES="deny_overrides";
public static final String PERMIT_OVERRIDES="permit_overrides";
public static final String FIRST_APPLICABLE="first_applicable";
public static final String LAST_APPLICABLE="last_applicable";
public static final String ALL_APPLICABLE="all_applicable";
public static final String HIGHEST_APPLICABLE="highest_applicable";
public static final String LOWEST_APPLICABLE="lowest_applicable";
}

View File

@ -22,6 +22,15 @@ public class Feature {
private String code; private String code;
private String name; private String name;
private Object attribute; private Object attribute;
private String ruleValue;
public String getRuleValue() {
return ruleValue;
}
public void setRuleValue(String ruleValue) {
this.ruleValue = ruleValue;
}
public int getId() { public int getId() {
return id; return id;

View File

@ -23,6 +23,33 @@ public class Policy {
private String policyName; private String policyName;
private List<Feature> featuresList; private List<Feature> featuresList;
private boolean generic; private boolean generic;
private List<String> roleList;
private List<String> DeviceList;
private String deviceType;
public List<String> getRoleList() {
return roleList;
}
public void setRoleList(List<String> roleList) {
this.roleList = roleList;
}
public List<String> getDeviceList() {
return DeviceList;
}
public void setDeviceList(List<String> deviceList) {
DeviceList = deviceList;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public boolean isGeneric() { public boolean isGeneric() {
return generic; return generic;

10
pom.xml
View File

@ -133,15 +133,7 @@
<artifactId>org.eclipse.equinox.common</artifactId> <artifactId>org.eclipse.equinox.common</artifactId>
<version>${eclipse.equinox.common.version}</version> <version>${eclipse.equinox.common.version}</version>
</dependency> </dependency>
<!--Test dependencies-->
<!--
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12-beta-3</version>
<scope>test</scope>
</dependency>
-->
<dependency> <dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
<artifactId>testng</artifactId> <artifactId>testng</artifactId>

View File

@ -251,7 +251,7 @@
<files> <files>
<file> <file>
<source>../agents/android/jax-rs/target/cdm-android-api.war</source> <source>../mobileservices/agents/android/jax-rs/target/cdm-android-api.war</source>
<outputDirectory>wso2cdm-${pom.version}/repository/deployment/server/webapps <outputDirectory>wso2cdm-${pom.version}/repository/deployment/server/webapps
</outputDirectory> </outputDirectory>
<fileMode>755</fileMode> <fileMode>755</fileMode>

View File

@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` ( CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT , `FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
`CODE` VARCHAR(45) NULL , `CODE` VARCHAR(45) NOT NULL ,
`NAME` VARCHAR(100) NULL , `NAME` VARCHAR(100) NULL ,
`DESCRIPTION` VARCHAR(200) NULL , `DESCRIPTION` VARCHAR(200) NULL ,
PRIMARY KEY (`FEATURE_ID`) ); PRIMARY KEY (`FEATURE_ID`) );
@ -30,7 +30,7 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` ( CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT , `OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
`FEATURE_CODE` VARCHAR(45) NULL , `FEATURE_CODE` VARCHAR(45) NOT NULL ,
`CREATED_DATE` INT NULL , `CREATED_DATE` INT NULL ,
PRIMARY KEY (`OPERATION_ID`) , PRIMARY KEY (`OPERATION_ID`) ,
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1` CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
@ -40,9 +40,9 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
ON UPDATE NO ACTION); ON UPDATE NO ACTION);
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `MBL_DEVICE_OPERATION_MAPING` -- Table `MBL_DEVICE_OPERATION_MAPPING`
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` ( CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL , `DEVICE_ID` VARCHAR(45) NOT NULL ,
`OPERATION_ID` INT NOT NULL , `OPERATION_ID` INT NOT NULL ,
`SENT_DATE` INT NULL , `SENT_DATE` INT NULL ,
@ -63,11 +63,10 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
-- Table `MBL_OPERATION_PROPERTY` -- Table `MBL_OPERATION_PROPERTY`
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` ( CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
`OPERATION_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT , `OPERATION_ID` INT NOT NULL ,
`OPERATION_ID` INT NULL , `PROPERTY` VARCHAR(45) NOT NULL ,
`PROPERTY_ID` INT NULL ,
`VALUE` TEXT NULL , `VALUE` TEXT NULL ,
PRIMARY KEY (`OPERATION_PROPERTY_ID`) , PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) ,
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1` CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
FOREIGN KEY (`OPERATION_ID` ) FOREIGN KEY (`OPERATION_ID` )
REFERENCES `MBL_OPERATION` (`OPERATION_ID` ) REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
@ -78,13 +77,11 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
-- Table `MBL_FEATURE_PROPERTY` -- Table `MBL_FEATURE_PROPERTY`
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` ( CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
`PROPERTY_ID` INT NOT NULL AUTO_INCREMENT , `PROPERTY` VARCHAR(45) NOT NULL ,
`PROPERTY` VARCHAR(100) NULL , `FEATURE_ID` VARCHAR(45) NOT NULL ,
`FEATURE_ID` VARCHAR(45) NULL , PRIMARY KEY (`PROPERTY`) ,
PRIMARY KEY (`PROPERTY_ID`) ,
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1` CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
FOREIGN KEY (`FEATURE_ID` ) FOREIGN KEY (`FEATURE_ID` )
REFERENCES `MBL_FEATURE` (`FEATURE_ID` ) REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION); ON UPDATE NO ACTION);

View File

@ -3,12 +3,14 @@
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL, `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL,
`REG_ID` VARCHAR(45) NULL, `REG_ID` VARCHAR(45) NULL DEFAULT NULL,
`IMEI` VARCHAR(45) NULL, `IMEI` VARCHAR(45) NULL DEFAULT NULL,
`IMSI` VARCHAR(45) NULL, `IMSI` VARCHAR(45) NULL DEFAULT NULL,
`OS_VERSION` VARCHAR(45) NULL, `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL,
`DEVICE_MODEL` VARCHAR(45) NULL, `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL,
`VENDOR` VARCHAR(45) NULL, `VENDOR` VARCHAR(45) NULL DEFAULT NULL,
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`)) PRIMARY KEY (`MOBILE_DEVICE_ID`))
ENGINE = InnoDB; ENGINE = InnoDB;
@ -32,20 +34,14 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT, `OPERATION_ID` INT NOT NULL AUTO_INCREMENT,
`FEATURE_CODE` VARCHAR(45) NULL, `FEATURE_CODE` VARCHAR(45) NULL,
`CREATED_DATE` INT NULL, `CREATED_DATE` INT NULL,
PRIMARY KEY (`OPERATION_ID`) , PRIMARY KEY (`OPERATION_ID`))
INDEX `fk_MBL_OPERATION_MBL_FEATURES1_idx` (`FEATURE_CODE` ASC) ,
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
FOREIGN KEY (`FEATURE_CODE` )
REFERENCES `MBL_FEATURE` (`CODE` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB; ENGINE = InnoDB;
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `MBL_DEVICE_OPERATION_MAPING` -- Table `MBL_DEVICE_OPERATION_MAPING`
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` ( CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL, `DEVICE_ID` VARCHAR(45) NOT NULL,
`OPERATION_ID` INT NOT NULL, `OPERATION_ID` INT NOT NULL,
`SENT_DATE` INT NULL, `SENT_DATE` INT NULL,

View File

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<artifactType type="application/vnd.wso2-license+xml" shortName="license" singularLabel="License" pluralLabel="Licenses"
hasNamespace="false" iconSet="10">
<storagePath>/license/@{overview_provider}/@{overview_name}/@{overview_version}</storagePath>
<nameAttribute>overview_name</nameAttribute>
<ui>
<list>
<column name="Provider">
<data type="path" value="overview_provider" href="@{storagePath}"/>
</column>
<column name="Name">
<data type="path" value="overview_name" href="@{storagePath}"/>
</column>
<column name="Version">
<data type="path" value="overview_version" href="@{storagePath}"/>
</column>
</list>
</ui>
<content>
<table name="Overview">
<field type="text" required="true">
<name>Provider</name>
</field>
<field type="text" required="true">
<name>Name</name>
</field>
<field type="text" required="true">
<name>Version</name>
</field>
<field type="text">
<name>Createdtime</name>
</field>
<field type="text-area">
<name>License</name>
</field>
</table>
</content>
</artifactType>

Some files were not shown because too many files have changed in this diff Show More