diff --git a/WebContent/WEB-INF/classes/messages_de.properties b/WebContent/WEB-INF/classes/messages_de.properties index 51b1c94e70..924f9a741b 100644 --- a/WebContent/WEB-INF/classes/messages_de.properties +++ b/WebContent/WEB-INF/classes/messages_de.properties @@ -3154,5 +3154,14 @@ menu.point_hierarchy.refresh.tooltip=Refresh menu.point_hierarchy.info.tooltip=Info menu.point_hierarchy.info.tooltip=Info header.changeTheme= +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description + diff --git a/WebContent/WEB-INF/classes/messages_en.properties b/WebContent/WEB-INF/classes/messages_en.properties index 86b0156623..8d218bd1fe 100644 --- a/WebContent/WEB-INF/classes/messages_en.properties +++ b/WebContent/WEB-INF/classes/messages_en.properties @@ -3157,4 +3157,12 @@ menu.point_hierarchy.info.tooltip=Info error.view_hierarchy.add.error1=Name is not validat -header.changeTheme=Change ScadaLTS application theme \ No newline at end of file +header.changeTheme=Change ScadaLTS application theme +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=\ With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description \ No newline at end of file diff --git a/WebContent/WEB-INF/classes/messages_es.properties b/WebContent/WEB-INF/classes/messages_es.properties index b8c364e376..6956a84c67 100644 --- a/WebContent/WEB-INF/classes/messages_es.properties +++ b/WebContent/WEB-INF/classes/messages_es.properties @@ -3083,4 +3083,11 @@ menu.point_hierarchy.add.tooltip=Add folder menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root menu.point_hierarchy.refresh.tooltip=Refresh menu.point_hierarchy.info.tooltip=Info - +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description \ No newline at end of file diff --git a/WebContent/WEB-INF/classes/messages_fi.properties b/WebContent/WEB-INF/classes/messages_fi.properties index e856446adf..6a56c47a7c 100644 --- a/WebContent/WEB-INF/classes/messages_fi.properties +++ b/WebContent/WEB-INF/classes/messages_fi.properties @@ -2903,4 +2903,11 @@ menu.point_hierarchy.add.tooltip=Add folder menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root menu.point_hierarchy.refresh.tooltip=Refresh menu.point_hierarchy.info.tooltip=Info - +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description \ No newline at end of file diff --git a/WebContent/WEB-INF/classes/messages_fr.properties b/WebContent/WEB-INF/classes/messages_fr.properties index c7df0fb091..f6c856122b 100644 --- a/WebContent/WEB-INF/classes/messages_fr.properties +++ b/WebContent/WEB-INF/classes/messages_fr.properties @@ -3159,4 +3159,11 @@ menu.point_hierarchy.add.tooltip=Add folder menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root menu.point_hierarchy.refresh.tooltip=Refresh menu.point_hierarchy.info.tooltip=Info - +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description \ No newline at end of file diff --git a/WebContent/WEB-INF/classes/messages_lu.properties b/WebContent/WEB-INF/classes/messages_lu.properties index 5e87f00f2a..6c48e7027c 100644 --- a/WebContent/WEB-INF/classes/messages_lu.properties +++ b/WebContent/WEB-INF/classes/messages_lu.properties @@ -3169,4 +3169,11 @@ menu.point_hierarchy.add.tooltip=Add folder menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root menu.point_hierarchy.refresh.tooltip=Refresh menu.point_hierarchy.info.tooltip=Info - +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description \ No newline at end of file diff --git a/WebContent/WEB-INF/classes/messages_nl.properties b/WebContent/WEB-INF/classes/messages_nl.properties index ba5fb168f8..4ddcfacebf 100644 --- a/WebContent/WEB-INF/classes/messages_nl.properties +++ b/WebContent/WEB-INF/classes/messages_nl.properties @@ -2709,4 +2709,11 @@ menu.point_hierarchy.add.tooltip=Add folder menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root menu.point_hierarchy.refresh.tooltip=Refresh menu.point_hierarchy.info.tooltip=Info - +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description \ No newline at end of file diff --git a/WebContent/WEB-INF/classes/messages_pl.properties b/WebContent/WEB-INF/classes/messages_pl.properties index 9e9f1f9ca5..1bb9c37996 100644 --- a/WebContent/WEB-INF/classes/messages_pl.properties +++ b/WebContent/WEB-INF/classes/messages_pl.properties @@ -3070,4 +3070,12 @@ graphic.chartWidth=Długość (każdy wykres) graphic.chartHeight=Wysokość (każdy wykres) error.view_hierarchy.add.error1=Name is not validate -header.changeTheme=Zmień motyw aplikacji ScadaLTS \ No newline at end of file +header.changeTheme=Zmień motyw aplikacji ScadaLTS +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description \ No newline at end of file diff --git a/WebContent/WEB-INF/classes/messages_pt.properties b/WebContent/WEB-INF/classes/messages_pt.properties index 81ee07db5e..fd2938b7fd 100644 --- a/WebContent/WEB-INF/classes/messages_pt.properties +++ b/WebContent/WEB-INF/classes/messages_pt.properties @@ -3149,4 +3149,11 @@ menu.point_hierarchy.add.tooltip=Add folder menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root menu.point_hierarchy.refresh.tooltip=Refresh menu.point_hierarchy.info.tooltip=Info - +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description diff --git a/WebContent/WEB-INF/classes/messages_ru.properties b/WebContent/WEB-INF/classes/messages_ru.properties index b5438d492f..af512dc5a9 100644 --- a/WebContent/WEB-INF/classes/messages_ru.properties +++ b/WebContent/WEB-INF/classes/messages_ru.properties @@ -3120,4 +3120,11 @@ menu.point_hierarchy.add.tooltip=Add folder menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root menu.point_hierarchy.refresh.tooltip=Refresh menu.point_hierarchy.info.tooltip=Info - +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description \ No newline at end of file diff --git a/WebContent/WEB-INF/classes/messages_zh.properties b/WebContent/WEB-INF/classes/messages_zh.properties index 81f1085475..b5b563a95a 100644 --- a/WebContent/WEB-INF/classes/messages_zh.properties +++ b/WebContent/WEB-INF/classes/messages_zh.properties @@ -2023,4 +2023,11 @@ menu.point_hierarchy.add.tooltip=Add folder menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root menu.point_hierarchy.refresh.tooltip=Refresh menu.point_hierarchy.info.tooltip=Info - +ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed +ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped +ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource +ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed +ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed +ds.state.scryptChangeEnable=The script has changed the on/off status of datasource +ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default +dsList.statusDescribe=Status description \ No newline at end of file diff --git a/WebContent/WEB-INF/jsp/dataSourceList.jsp b/WebContent/WEB-INF/jsp/dataSourceList.jsp index 368a0a7d8c..25b11e4a34 100644 --- a/WebContent/WEB-INF/jsp/dataSourceList.jsp +++ b/WebContent/WEB-INF/jsp/dataSourceList.jsp @@ -28,16 +28,22 @@ }); } + function updateStateDescription(idDs, description) { + var idStateDesc = "stateDes"+idDs; + jQuery("#"+idStateDesc).html(description); + } + function toggleDataSource(dataSourceId) { var imgNode = $("dsImg"+ dataSourceId); if (!hasImageFader(imgNode)) { DataSourceListDwr.toggleDataSource(dataSourceId, function(result) { updateStatusImg($("dsImg"+ result.id), result.enabled, true); + updateStateDescription(result.id, result.state); }); startImageFader(imgNode); } } - + function toggleDataPoint(dataPointId) { var imgNode = $("dpImg"+ dataPointId); if (!hasImageFader(imgNode)) { @@ -117,6 +123,7 @@ + @@ -138,6 +145,9 @@ + + ${listParent.parent.state.describe} + @@ -187,7 +197,6 @@ - diff --git a/src/br/org/scadabr/api/dao/MangoDaoImpl.java b/src/br/org/scadabr/api/dao/MangoDaoImpl.java index 574eef7e87..6f03faa3ba 100644 --- a/src/br/org/scadabr/api/dao/MangoDaoImpl.java +++ b/src/br/org/scadabr/api/dao/MangoDaoImpl.java @@ -32,6 +32,7 @@ import com.serotonin.mango.vo.permission.Permissions; import com.serotonin.util.StringUtils; import com.serotonin.web.dwr.DwrResponseI18n; +import org.scada_lts.ds.state.ApiChangeEnableStateDs; import java.util.*; @@ -863,6 +864,7 @@ public int configureDataSource(DataSourceType dataSourceType, ds.setId(config.getId()); ds.setName(config.getName()); ds.setEnabled(config.isEnabled()); + ds.setState(new ApiChangeEnableStateDs()); ds.setHost(config.getHost()); ds.setPort(config.getPort()); ds.setUpdatePeriods((int) config.getPollingPeriod()); @@ -905,6 +907,7 @@ public int configureDataSource(DataSourceType dataSourceType, ds.setId(config.getId()); ds.setName(config.getName()); ds.setEnabled(config.isEnabled()); + ds.setState(new ApiChangeEnableStateDs()); ds.setCommPortId(config.getSerialPort()); ds.setBaudRate(config.getBaudrate()); ds.setUpdatePeriods((int) config.getPollingPeriod()); diff --git a/src/br/org/scadabr/rt/scripting/context/DSCommandsScriptContextObject.java b/src/br/org/scadabr/rt/scripting/context/DSCommandsScriptContextObject.java index b04d4d57c7..f5ebeabd0b 100644 --- a/src/br/org/scadabr/rt/scripting/context/DSCommandsScriptContextObject.java +++ b/src/br/org/scadabr/rt/scripting/context/DSCommandsScriptContextObject.java @@ -5,6 +5,7 @@ import com.serotonin.mango.rt.RuntimeManager; import com.serotonin.mango.vo.dataSource.DataSourceVO; import com.serotonin.mango.vo.permission.Permissions; +import org.scada_lts.ds.state.ScryptChangeEnableStateDs; public class DSCommandsScriptContextObject extends ScriptContextObject { public static final Type TYPE = Type.DATASOURCE_COMMANDS; @@ -21,6 +22,7 @@ public void enableDataSource(String xid) { Permissions.ensureDataSourcePermission(Common.getUser(), dataSource .getId()); dataSource.setEnabled(true); + dataSource.setState(new ScryptChangeEnableStateDs()); runtimeManager.saveDataSource(dataSource); } @@ -33,6 +35,7 @@ public void disableDataSource(String xid) { Permissions.ensureDataSourcePermission(Common.getUser(), dataSource .getId()); dataSource.setEnabled(false); + dataSource.setState(new ScryptChangeEnableStateDs()); runtimeManager.saveDataSource(dataSource); } diff --git a/src/com/serotonin/mango/vo/dataSource/DataSourceVO.java b/src/com/serotonin/mango/vo/dataSource/DataSourceVO.java index 8c50f3b70a..311296687e 100644 --- a/src/com/serotonin/mango/vo/dataSource/DataSourceVO.java +++ b/src/com/serotonin/mango/vo/dataSource/DataSourceVO.java @@ -67,6 +67,8 @@ import com.serotonin.util.StringUtils; import com.serotonin.web.dwr.DwrResponseI18n; import com.serotonin.web.i18n.LocalizableMessage; +import org.scada_lts.ds.state.MigrationOrErrorSerializeChangeEnableState; +import org.scada_lts.ds.state.IStateDs; import java.io.IOException; import java.io.ObjectInputStream; @@ -381,6 +383,9 @@ public boolean isNew() { private String name; @JsonRemoteProperty private boolean enabled; + + private IStateDs state; + private Map alarmLevels = new HashMap(); public boolean isEnabled() { @@ -391,6 +396,14 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } + public IStateDs getState() { + return state; + } + + public void setState(IStateDs state) { + this.state = state; + } + public int getId() { return id; } @@ -487,6 +500,8 @@ public final void addProperties(List list) { AuditEventType.addPropertyMessage(list, "dsEdit.head.name", name); AuditEventType.addPropertyMessage(list, "common.xid", xid); AuditEventType.addPropertyMessage(list, "common.enabled", enabled); + AuditEventType.addPropertyMessage(list, "common.state", state); + addPropertiesImpl(list); } @@ -500,6 +515,8 @@ public final void addPropertyChanges(List list, T from) { AuditEventType.maybeAddPropertyChangeMessage(list, "common.enabled", from.isEnabled(), enabled); + AuditEventType.maybeAddPropertyChangeMessage(list, "common.describeStatus", from.getState(), state); + addPropertyChangesImpl(list, from); } @@ -520,6 +537,7 @@ private void writeObject(ObjectOutputStream out) throws IOException { out.writeInt(version); out.writeBoolean(enabled); out.writeObject(alarmLevels); + out.writeObject(state); } @SuppressWarnings("unchecked") @@ -532,9 +550,20 @@ private void readObject(ObjectInputStream in) throws IOException, if (ver == 1) { enabled = in.readBoolean(); alarmLevels = new HashMap(); + try { + state = (IStateDs) in.readObject(); + } catch (Exception e) { + state = new MigrationOrErrorSerializeChangeEnableState(); + } + } else if (ver == 2) { enabled = in.readBoolean(); alarmLevels = (HashMap) in.readObject(); + try { + state = (IStateDs) in.readObject(); + } catch (Exception e) { + state = new MigrationOrErrorSerializeChangeEnableState(); + } } } diff --git a/src/com/serotonin/mango/vo/dataSource/http/HttpRetrieverDataSourceVO.java b/src/com/serotonin/mango/vo/dataSource/http/HttpRetrieverDataSourceVO.java index 7fccfbd6bc..b9897b2b0c 100644 --- a/src/com/serotonin/mango/vo/dataSource/http/HttpRetrieverDataSourceVO.java +++ b/src/com/serotonin/mango/vo/dataSource/http/HttpRetrieverDataSourceVO.java @@ -214,7 +214,6 @@ private void readObject(ObjectInputStream in) throws IOException { timeoutSeconds = in.readInt(); ; retries = in.readInt(); - // We don't check version we work on latest when is not correctly set default value; try { stop = in.readBoolean(); } catch (Exception e) { diff --git a/src/com/serotonin/mango/web/dwr/DataSourceListDwr.java b/src/com/serotonin/mango/web/dwr/DataSourceListDwr.java index dc8713589a..f360d2ed7c 100644 --- a/src/com/serotonin/mango/web/dwr/DataSourceListDwr.java +++ b/src/com/serotonin/mango/web/dwr/DataSourceListDwr.java @@ -39,6 +39,7 @@ import com.serotonin.mango.vo.dataSource.DataSourceVO.Type; import com.serotonin.mango.vo.permission.Permissions; import com.serotonin.web.dwr.DwrResponseI18n; +import org.scada_lts.ds.state.UserChangeEnableStateDs; /** * @author Matthew Lohbihler @@ -100,8 +101,10 @@ public Map toggleDataSource(int dataSourceId) { Map result = new HashMap(); dataSource.setEnabled(!dataSource.isEnabled()); + dataSource.setState(new UserChangeEnableStateDs()); runtimeManager.saveDataSource(dataSource); + result.put("state", dataSource.getState().getDescribe()); result.put("enabled", dataSource.isEnabled()); result.put("id", dataSourceId); return result; diff --git a/src/com/serotonin/mango/web/dwr/beans/ImportTask.java b/src/com/serotonin/mango/web/dwr/beans/ImportTask.java index fda21a181b..354fc13dd2 100644 --- a/src/com/serotonin/mango/web/dwr/beans/ImportTask.java +++ b/src/com/serotonin/mango/web/dwr/beans/ImportTask.java @@ -75,6 +75,7 @@ import com.serotonin.web.dwr.DwrMessageI18n; import com.serotonin.web.dwr.DwrResponseI18n; import com.serotonin.web.i18n.I18NUtils; +import org.scada_lts.ds.state.ImportChangeEnableStateDs; /** * @author Matthew Lohbihler @@ -214,6 +215,7 @@ private void preloadDataPoints() { .getId())) { disabledDataSources.add(dsvo.getId()); dsvo.setEnabled(false); + dsvo.setState(new ImportChangeEnableStateDs()); Common.ctx.getRuntimeManager().saveDataSource( dsvo); } @@ -360,6 +362,7 @@ protected void runImpl() { for (Integer id : disabledDataSources) { DataSourceVO ds = dataSourceDao.getDataSource(id); ds.setEnabled(true); + ds.setState(new ImportChangeEnableStateDs()); Common.ctx.getRuntimeManager().saveDataSource(ds); } } catch (Exception e) { @@ -427,6 +430,13 @@ private void importDataSource(JsonObject dataSource) { name == null ? "(undefined)" : name); else { DataSourceVO vo = dataSourceDao.getDataSource(xid); + if (vo != null) { + //Check the enable/disable is changed. And to test when don't have enable property when import data + boolean importedDsEnabled = dataSource.getBoolean("enabled"); + if (vo.isEnabled() != importedDsEnabled) { + vo.setState(new ImportChangeEnableStateDs()); + } + } if (vo == null) { String typeStr = dataSource.getString("type"); if (StringUtils.isEmpty(typeStr)) @@ -464,6 +474,7 @@ private void importDataSource(JsonObject dataSource) { else { // Sweet. Save it. boolean isnew = vo.isNew(); + vo.setState(new ImportChangeEnableStateDs()); Common.ctx.getRuntimeManager().saveDataSource(vo); addSuccessMessage(isnew, "emport.dataSource.prefix", xid); @@ -534,6 +545,7 @@ private void importDataPoint(JsonObject dataPoint) { && !disabledDataSources.contains(dsvo.getId())) { disabledDataSources.add(dsvo.getId()); dsvo.setEnabled(false); + dsvo.setState(new ImportChangeEnableStateDs()); Common.ctx.getRuntimeManager().saveDataSource(dsvo); } diff --git a/src/org/scada_lts/ds/StopDsRT.java b/src/org/scada_lts/ds/StopDsRT.java index f42890339b..bac6e662d5 100644 --- a/src/org/scada_lts/ds/StopDsRT.java +++ b/src/org/scada_lts/ds/StopDsRT.java @@ -3,6 +3,7 @@ import com.serotonin.mango.Common; import com.serotonin.mango.rt.RuntimeManager; import com.serotonin.mango.vo.dataSource.DataSourceVO; +import org.scada_lts.ds.state.StopChangeEnableStateDs; /** * @project Scada-LTS @@ -22,6 +23,7 @@ public void run() { RuntimeManager runtimeManager = Common.ctx.getRuntimeManager(); DataSourceVO dataSource = runtimeManager.getDataSource(idDs); dataSource.setEnabled(false); + dataSource.setState(new StopChangeEnableStateDs()); runtimeManager.saveDataSource(dataSource); } catch (Exception e) { diff --git a/src/org/scada_lts/ds/state/ApiChangeEnableStateDs.java b/src/org/scada_lts/ds/state/ApiChangeEnableStateDs.java new file mode 100644 index 0000000000..062a282a07 --- /dev/null +++ b/src/org/scada_lts/ds/state/ApiChangeEnableStateDs.java @@ -0,0 +1,20 @@ +package org.scada_lts.ds.state; + +import org.scada_lts.localization.ConfigLocalization; + +import java.io.Serializable; +import java.util.Locale; + +/** + * @project Scada-LTS-master + * @autor grzegorz.bylica@gmail.com on 10.10.18 + */ +public class ApiChangeEnableStateDs implements IStateDs, Serializable { + + private static final String API_CHANGE_ENABLE_STATE_DS = "ds.state.apiChangeEnableStateDs"; + + @Override + public String getDescribe() { + return ConfigLocalization.getInstance().messageSource().getMessage(API_CHANGE_ENABLE_STATE_DS, new Object[]{}, Locale.getDefault()); + } +} diff --git a/src/org/scada_lts/ds/state/IStateDs.java b/src/org/scada_lts/ds/state/IStateDs.java new file mode 100644 index 0000000000..7bce9548f1 --- /dev/null +++ b/src/org/scada_lts/ds/state/IStateDs.java @@ -0,0 +1,15 @@ +package org.scada_lts.ds.state; + +import com.serotonin.mango.vo.dataSource.DataSourceVO; + +/** + * @project Scada-LTS-master + * @autor grzegorz.bylica@gmail.com on 10.10.18 + */ +public interface IStateDs { + + //void change(DataSourceVO ds); + + String getDescribe(); + +} diff --git a/src/org/scada_lts/ds/state/ImportChangeEnableStateDs.java b/src/org/scada_lts/ds/state/ImportChangeEnableStateDs.java new file mode 100644 index 0000000000..2265cdbb2e --- /dev/null +++ b/src/org/scada_lts/ds/state/ImportChangeEnableStateDs.java @@ -0,0 +1,20 @@ +package org.scada_lts.ds.state; + +import org.scada_lts.localization.ConfigLocalization; + +import java.io.Serializable; +import java.util.Locale; + +/** + * @project Scada-LTS-master + * @autor grzegorz.bylica@gmail.com on 10.10.18 + */ +public class ImportChangeEnableStateDs implements IStateDs, Serializable { + + private static final String IMPORT = "ds.state.importChangeEnableStateDs"; + + @Override + public String getDescribe() { + return ConfigLocalization.getInstance().messageSource().getMessage(IMPORT, new Object[]{}, Locale.getDefault()); + } +} diff --git a/src/org/scada_lts/ds/state/MigrationOrErrorSerializeChangeEnableState.java b/src/org/scada_lts/ds/state/MigrationOrErrorSerializeChangeEnableState.java new file mode 100644 index 0000000000..9ec6d1ecad --- /dev/null +++ b/src/org/scada_lts/ds/state/MigrationOrErrorSerializeChangeEnableState.java @@ -0,0 +1,21 @@ +package org.scada_lts.ds.state; + + +import org.scada_lts.localization.ConfigLocalization; + +import java.io.Serializable; +import java.util.Locale; + +/** + * @project Scada-LTS-master + * @autor grzegorz.bylica@gmail.com on 10.10.18 + */ +public class MigrationOrErrorSerializeChangeEnableState implements IStateDs, Serializable { + + private static final String MIGRATION = "ds.state.migrationOrErrorSerializeChangeEnableState"; + + @Override + public String getDescribe() { + return ConfigLocalization.getInstance().messageSource().getMessage(MIGRATION, new Object[]{}, Locale.getDefault()); + } +} diff --git a/src/org/scada_lts/ds/state/ScryptChangeEnableStateDs.java b/src/org/scada_lts/ds/state/ScryptChangeEnableStateDs.java new file mode 100644 index 0000000000..42ee014c30 --- /dev/null +++ b/src/org/scada_lts/ds/state/ScryptChangeEnableStateDs.java @@ -0,0 +1,20 @@ +package org.scada_lts.ds.state; + +import org.scada_lts.localization.ConfigLocalization; + +import java.io.Serializable; +import java.util.Locale; + +/** + * @project Scada-LTS-master + * @autor grzegorz.bylica@gmail.com on 10.10.18 + */ +public class ScryptChangeEnableStateDs implements IStateDs, Serializable { + + private static final String SCRYPT_CHANGE_ENABLE = "ds.state.scryptChangeEnable"; + + @Override + public String getDescribe() { + return ConfigLocalization.getInstance().messageSource().getMessage(SCRYPT_CHANGE_ENABLE, new Object[]{}, Locale.getDefault()); + } +} diff --git a/src/org/scada_lts/ds/state/StopChangeEnableStateDs.java b/src/org/scada_lts/ds/state/StopChangeEnableStateDs.java new file mode 100644 index 0000000000..261d4c3545 --- /dev/null +++ b/src/org/scada_lts/ds/state/StopChangeEnableStateDs.java @@ -0,0 +1,20 @@ +package org.scada_lts.ds.state; + +import org.scada_lts.localization.ConfigLocalization; + +import java.io.Serializable; +import java.util.Locale; + +/** + * @project Scada-LTS-master + * @autor grzegorz.bylica@gmail.com on 10.10.18 + */ +public class StopChangeEnableStateDs implements IStateDs, Serializable { + + private static final String STOP = "ds.state.stopChangeEnableStateDs"; + + @Override + public String getDescribe() { + return ConfigLocalization.getInstance().messageSource().getMessage(STOP, new Object[]{}, Locale.getDefault()); + } +} diff --git a/src/org/scada_lts/ds/state/UserChangeEnableStateDs.java b/src/org/scada_lts/ds/state/UserChangeEnableStateDs.java new file mode 100644 index 0000000000..70f34211d3 --- /dev/null +++ b/src/org/scada_lts/ds/state/UserChangeEnableStateDs.java @@ -0,0 +1,21 @@ +package org.scada_lts.ds.state; + +import org.scada_lts.localization.ConfigLocalization; + +import java.io.Serializable; +import java.util.Locale; + +/** + * @project Scada-LTS-master + * @autor grzegorz.bylica@gmail.com on 10.10.18 + */ +public class UserChangeEnableStateDs implements IStateDs, Serializable { + + private static final String USER = "ds.state.userChangeEnableStateDs"; + + @Override + public String getDescribe() { + return ConfigLocalization.getInstance().messageSource().getMessage(USER, new Object[]{}, Locale.getDefault()); + } + +} diff --git a/src/org/scada_lts/ds/state/UserCpChangeEnableStateDs.java b/src/org/scada_lts/ds/state/UserCpChangeEnableStateDs.java new file mode 100644 index 0000000000..1457b256aa --- /dev/null +++ b/src/org/scada_lts/ds/state/UserCpChangeEnableStateDs.java @@ -0,0 +1,20 @@ +package org.scada_lts.ds.state; + +import org.scada_lts.localization.ConfigLocalization; + +import java.io.Serializable; +import java.util.Locale; + +/** + * @project Scada-LTS-master + * @autor grzegorz.bylica@gmail.com on 10.10.18 + */ +public class UserCpChangeEnableStateDs implements IStateDs, Serializable { + + private static final String USER_CP_DS = "ds.state.userCpChangeEnableStateDs"; + + @Override + public String getDescribe() { + return ConfigLocalization.getInstance().messageSource().getMessage(USER_CP_DS, new Object[]{}, Locale.getDefault()); + } +} diff --git a/src/org/scada_lts/localization/ConfigLocalization.java b/src/org/scada_lts/localization/ConfigLocalization.java new file mode 100644 index 0000000000..5fccbeaa3e --- /dev/null +++ b/src/org/scada_lts/localization/ConfigLocalization.java @@ -0,0 +1,29 @@ +package org.scada_lts.localization; + +import org.springframework.context.MessageSource; +import org.springframework.context.support.ReloadableResourceBundleMessageSource; + +/** + * @project Scada-LTS-master + * @autor grzegorz.bylica@gmail.com on 11.10.18 + */ +public class ConfigLocalization { + + private static ConfigLocalization ourInstance = new ConfigLocalization(); + private ReloadableResourceBundleMessageSource messageSource; + + public static ConfigLocalization getInstance() { + return ourInstance; + } + + private ConfigLocalization() { + messageSource = new ReloadableResourceBundleMessageSource(); + messageSource.setBasename("messages"); + messageSource.setDefaultEncoding("UTF-8"); + messageSource.setUseCodeAsDefaultMessage(true); + } + + public MessageSource messageSource () { + return messageSource; + } +} diff --git a/src/org/scada_lts/mango/service/DataSourceService.java b/src/org/scada_lts/mango/service/DataSourceService.java index c08cb7101d..4651a237a1 100644 --- a/src/org/scada_lts/mango/service/DataSourceService.java +++ b/src/org/scada_lts/mango/service/DataSourceService.java @@ -18,7 +18,6 @@ package org.scada_lts.mango.service; import com.serotonin.mango.Common; -import com.serotonin.mango.db.dao.DataPointDao; import com.serotonin.mango.vo.DataPointVO; import com.serotonin.mango.vo.User; import com.serotonin.mango.vo.dataSource.DataSourceVO; @@ -26,9 +25,9 @@ import com.serotonin.util.StringUtils; import com.serotonin.web.i18n.LocalizableMessage; import org.scada_lts.dao.DAO; -import org.scada_lts.dao.DataPointDAO; import org.scada_lts.dao.DataSourceDAO; import org.scada_lts.dao.MaintenanceEventDAO; +import org.scada_lts.ds.state.UserCpChangeEnableStateDs; import org.scada_lts.mango.adapter.MangoDataSource; import org.scada_lts.mango.adapter.MangoPointHierarchy; import org.springframework.dao.EmptyResultDataAccessException; @@ -137,6 +136,8 @@ public int copyDataSource(final int dataSourceId, final ResourceBundle bundle) { dataSourceCopy.setId(Common.NEW_ID); dataSourceCopy.setXid(generateUniqueXid()); dataSourceCopy.setEnabled(false); + dataSourceCopy.setState(new UserCpChangeEnableStateDs()); + //TODO seroUtils dataSourceCopy.setName(StringUtils.truncate(LocalizableMessage.getMessage(bundle, "common.copyPrefix", dataSource.getName()), 40));