Add traccar configuration on p2.inf and updated mysql.sql

feature/traccar-sync
Rushdi Mohamed 3 years ago
parent f61ab0ae69
commit e88d5e9c3b

@ -159,13 +159,16 @@ public class TraccarClientImpl implements TraccarClient {
JSONArray fetchAllUsers = new JSONArray(allUsers); //loop users JSONArray fetchAllUsers = new JSONArray(allUsers); //loop users
for(int i=0; i<fetchAllUsers.length();i++){ for(int i=0; i<fetchAllUsers.length();i++){
// if login is null then check the name or if login is not null then check the login // if login is null then check the name or if login is not null then check the login
if((!fetchAllUsers.getJSONObject(i).isNull("login") && if(fetchAllUsers.getJSONObject(i).isNull("login")){
fetchAllUsers.getJSONObject(i).getString("login").equals(userName)) || if(Objects.equals(fetchAllUsers.getJSONObject(i).getString("name"), userName)){
(fetchAllUsers.getJSONObject(i).isNull("login") &&
fetchAllUsers.getJSONObject(i).getString("name").equals(userName)) ){
return fetchAllUsers.getJSONObject(i).toString(); return fetchAllUsers.getJSONObject(i).toString();
} }
}else{
if(Objects.equals(fetchAllUsers.getJSONObject(i).getString("login"), userName) ||
Objects.equals(fetchAllUsers.getJSONObject(i).getString("name"), userName)){
return fetchAllUsers.getJSONObject(i).toString();
}
}
} }
return TraccarHandlerConstants.Types.USER_NOT_FOUND; return TraccarHandlerConstants.Types.USER_NOT_FOUND;
@ -183,6 +186,7 @@ public class TraccarClientImpl implements TraccarClient {
if(Objects.equals(result, TraccarHandlerConstants.Types.USER_NOT_FOUND)){ if(Objects.equals(result, TraccarHandlerConstants.Types.USER_NOT_FOUND)){
//create user //create user
log.info("Creating a user");
traccarUser.setName(userName); traccarUser.setName(userName);
traccarUser.setLogin(userName); traccarUser.setLogin(userName);
traccarUser.setEmail(userName); traccarUser.setEmail(userName);
@ -193,6 +197,7 @@ public class TraccarClientImpl implements TraccarClient {
DeviceAPIClientServiceImpl.createUser(traccarUser); DeviceAPIClientServiceImpl.createUser(traccarUser);
}else{ }else{
//update user //update user
log.info("Updating the user");
JSONObject obj = new JSONObject(result); JSONObject obj = new JSONObject(result);
traccarUser.setId(obj.getInt("id")); traccarUser.setId(obj.getInt("id"));

@ -812,3 +812,32 @@ CREATE TABLE IF NOT EXISTS DM_GEOFENCE_EVENT_MAPPING (
) ENGINE=InnoDB; ) ENGINE=InnoDB;
-- END OF DM_GEOFENCE_GROUP_MAPPING TABLE-- -- END OF DM_GEOFENCE_GROUP_MAPPING TABLE--
-- DM_EXT_GROUP_MAPPING TABLE--
CREATE TABLE IF NOT EXISTS DM_EXT_GROUP_MAPPING (
ID INT NOT NULL AUTO_INCREMENT,
TRACCAR_GROUP_ID INT DEFAULT 0,
GROUP_ID INT NOT NULL,
TENANT_ID INT NOT NULL,
STATUS INT DEFAULT 0,
PRIMARY KEY (ID)
);
-- END OF DM_EXT_GROUP_MAPPING TABLE--
-- END OF DM_EXT_DEVICE_MAPPING TABLE--
CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING (
ID INT NOT NULL AUTO_INCREMENT,
TRACCAR_DEVICE_ID INT DEFAULT 0,
DEVICE_ID INT NOT NULL,
TENANT_ID INT NOT NULL,
STATUS INT DEFAULT 0,
PRIMARY KEY (ID)
);
-- END OF DM_EXT_DEVICE_MAPPING TABLE--
-- END OF DM_EXT_PERMISSION_MAPPING TABLE--
CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING (
TRACCAR_DEVICE_ID INT DEFAULT 0,
TRACCAR_USER_ID INT DEFAULT 0
);
-- END OF DM_EXT_PERMISSION_MAPPING TABLE--

@ -11,3 +11,4 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/email-templates);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/email-templates);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf/traccar-config.xml,target:${installFolder}/../../conf/traccar-config.xml,overwrite:true);\

Loading…
Cancel
Save