Fix settings load.

Problems in viewer mode with long (>50char) settings names which don't
get fully stored in the database. Fixed by only looking at the start of
the name. Better to not use such long names.
This commit is contained in:
Douglas Gillespie 2024-02-27 15:55:02 +00:00
parent 2721095a03
commit c36ad2a33a
3 changed files with 27 additions and 9 deletions

View File

@ -403,4 +403,9 @@ public class PamControlledUnitSettings implements Serializable, ManagedParameter
return ps;
}
@Override
public String toString() {
return String.format("Type %s; Name %s, Data ", getUnitType(), getUnitName()) + getSettings();
}
}

View File

@ -384,6 +384,8 @@ public class PamSettingManager {
boolean[] usedSettings, PamSettings user) {
if (settingsList == null) return null;
// go through the list and see if any match this module. Avoid repeats.
// String unitName = user.getUnitName();
// String unitType = user.getUnitType();
for (int i = 0; i < settingsList.size(); i++) {
if (usedSettings != null && usedSettings[i]) continue;
if (isSettingsUnit(user, settingsList.get(i))) {
@ -393,6 +395,7 @@ public class PamSettingManager {
return settingsList.get(i);
}
}
/*
* To improve complex module loading where settings may be saved by multiple sub-modules, in
* July 2015 many modules which had fixed settings had their settings names and types changed !
@ -1482,12 +1485,21 @@ public class PamSettingManager {
if (settings.getUnitName() == null || settingsUser.getUnitName() == null) return false;
if (settings.getUnitType() == null || settingsUser.getUnitType() == null) return false;
/*
* some of the settings names used in Viewer mode have become too long, notably
* in some data selectors which are using a datablocks long data name. This
* screws things up, so moving to a begins with rather than equals for the name.
*/
String name = settingsUser.getUnitName();
String type = settingsUser.getUnitType();
long version = settingsUser.getSettingsVersion();
if (settings.getUnitName().equals(settingsUser.getUnitName())
&& settings.getUnitType().equals(settingsUser.getUnitType())
&& settings.versionNo == settingsUser.getSettingsVersion()){
if (settings.getUnitType().equals(type)
&& settings.versionNo == version){
if (name.startsWith(settings.getUnitName())) {
return true;
}
}
return false;
}

View File

@ -201,10 +201,11 @@ public abstract class DataSelectorCreator implements PamSettings {
}
else {
CompoundDataSelector selector = new CompoundDataSelector(pamDataBlock, allSelectors, selectorName, allowScores, selectorType);
DataSelectParams params = dataSelectorSettings.getParams(selectorName);
if (params instanceof CompoundParams) {
selector.setParams(params);
}
// not needed since it get's done after this call anyway.
// DataSelectParams params = dataSelectorSettings.getParams(selectorName);
// if (params instanceof CompoundParams) {
// selector.setParams(params);
// }
return selector;
}