use of com.thoughtworks.xstream.io.xml.DomDriver in project XobotOS by xamarin.
the class SharpenProject method createXStream.
private XStream createXStream() {
XStream stream = new XStream(new DomDriver());
stream.alias("sharpen", Remembrance.class);
return stream;
}
use of com.thoughtworks.xstream.io.xml.DomDriver in project GDSC-SMLM by aherbert.
the class SettingsManager method createXStream.
private static XStream createXStream() {
if (xs == null) {
xs = new XStream(new DomDriver());
// Map the object names/fields for a nicer configuration file
xs.alias("gdsc.fitting.settings", GlobalSettings.class);
xs.alias("gdsc.fitting.configuration", FitEngineConfiguration.class);
xs.aliasField("gdsc.fitting.configuration", GlobalSettings.class, "fitEngineConfiguration");
xs.aliasField("peakParameters", FitEngineConfiguration.class, "fitConfiguration");
xs.aliasField("smoothing", FitEngineConfiguration.class, "smooth");
//xs.aliasField("width0", FitConfiguration.class, "initialPeakWidth0");
//xs.aliasField("width1", FitConfiguration.class, "initialPeakWidth1");
//xs.aliasField("angle", FitConfiguration.class, "initialAngle");
xs.aliasField("enableValidation", FitConfiguration.class, "fitValidation");
xs.omitField(FitConfiguration.class, "flags");
xs.omitField(FitConfiguration.class, "signalThreshold");
//xs.omitField(FitConfiguration.class, "noise");
xs.omitField(FitConfiguration.class, "enableValidation");
xs.omitField(FitConfiguration.class, "computeResiduals");
// Smart filter settings
xs.omitField(FitConfiguration.class, "directFilter");
xs.omitField(FitConfiguration.class, "dynamicPeakResult");
xs.omitField(FitConfiguration.class, "filterResult");
xs.omitField(FitConfiguration.class, "widthEnabled");
xs.omitField(FitConfiguration.class, "offset");
}
return xs;
}
use of com.thoughtworks.xstream.io.xml.DomDriver in project GDSC-SMLM by aherbert.
the class BatchPeakFit method createXStream.
private XStream createXStream() {
XStream xs = new XStream(new DomDriver());
xs.alias("gdsc.fitting.batchSettings", BatchSettings.class);
xs.alias("parameter", ParameterSettings.class);
xs.alias("gdsc.fitting.batchRun", BatchRun.class);
xs.omitField(FitConfiguration.class, "flags");
xs.omitField(FitConfiguration.class, "signalThreshold");
//xs.omitField(FitConfiguration.class, "noise");
xs.omitField(FitConfiguration.class, "enableValidation");
return xs;
}
use of com.thoughtworks.xstream.io.xml.DomDriver in project spatial-portal by AtlasOfLivingAustralia.
the class MapComposer method loadUserSession.
public void loadUserSession(String sessionid) {
onClick$removeAllLayers();
Scanner scanner = null;
try {
String sfld = getSettingsSupplementary().getProperty(StringConstants.ANALYSIS_OUTPUT_DIR) + "session/" + sessionid;
File sessfolder = new File(sfld);
if (!sessfolder.exists()) {
showMessage("Session information does not exist. Please provide a valid session id");
return;
}
scanner = new Scanner(new File(sfld + "/details.txt"));
// first grab the zoom level and bounding box
String[] mapdetails = scanner.nextLine().split(",");
BoundingBox bb = new BoundingBox();
bb.setMinLongitude(Float.parseFloat(mapdetails[1]));
bb.setMinLatitude(Float.parseFloat(mapdetails[2]));
bb.setMaxLongitude(Float.parseFloat(mapdetails[3]));
bb.setMaxLatitude(Float.parseFloat(mapdetails[4]));
openLayersJavascript.setAdditionalScript(openLayersJavascript.zoomToBoundingBox(bb, true));
String[] scatterplotNames = null;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (line.startsWith("scatterplotNames")) {
scatterplotNames = line.substring(17).split("___");
}
}
ArrayUtils.reverse(scatterplotNames);
// ignore fields not found
XStream xstream = new XStream(new DomDriver()) {
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) {
public boolean shouldSerializeMember(Class definedIn, String fieldName) {
if (definedIn == Object.class || !super.shouldSerializeMember(definedIn, fieldName))
System.out.println("faled to read: " + definedIn + ", " + fieldName);
return definedIn != Object.class ? super.shouldSerializeMember(definedIn, fieldName) : false;
}
};
}
@Override
public Object unmarshal(HierarchicalStreamReader reader) {
Object o = super.unmarshal(reader);
if (o instanceof BiocacheQuery)
((BiocacheQuery) o).getFullQ(false);
return o;
}
@Override
public Object unmarshal(HierarchicalStreamReader reader, Object root) {
Object o = super.unmarshal(reader, root);
if (o instanceof BiocacheQuery)
((BiocacheQuery) o).getFullQ(false);
return o;
}
@Override
public Object unmarshal(HierarchicalStreamReader reader, Object root, DataHolder dataHolder) {
Object o = super.unmarshal(reader, root, dataHolder);
if (o instanceof BiocacheQuery)
((BiocacheQuery) o).getFullQ(false);
return o;
}
};
PersistenceStrategy strategy = new FilePersistenceStrategy(new File(sfld), xstream);
List list = new XmlArrayList(strategy);
ListIterator it = list.listIterator(list.size());
int scatterplotIndex = 0;
while (it.hasPrevious()) {
Object o = it.previous();
MapLayer ml = null;
if (o instanceof MapLayer) {
ml = (MapLayer) o;
LOGGER.debug("Loading " + ml.getName() + " -> " + ml.isDisplayed());
addUserDefinedLayerToMenu(ml, false);
} else if (o instanceof ScatterplotDataDTO) {
ScatterplotDataDTO spdata = (ScatterplotDataDTO) o;
loadScatterplot(spdata, "My Scatterplot " + scatterplotIndex++);
}
if (ml != null) {
addUserDefinedLayerToMenu(ml, true);
}
}
} catch (Exception e) {
try {
File f = new File("/data/sessions/" + sessionid + ".txt");
PrintWriter pw = new PrintWriter(f);
e.printStackTrace(pw);
pw.close();
} catch (Exception ex) {
}
LOGGER.error("Unable to load session data", e);
showMessage("Unable to load session data");
} finally {
if (scanner != null) {
scanner.close();
}
try {
File f = new File("/data/sessions/ok/" + sessionid + ".txt");
FileUtils.writeStringToFile(f, "ok");
} catch (Exception ex) {
}
}
}
use of com.thoughtworks.xstream.io.xml.DomDriver in project universa by UniversaBlockchain.
the class CLIMain method updateFields.
/**
* Update fields for specified contract.
*
* @param contract - contract for update.
* @param fields - map of field names and values.
*/
private static void updateFields(Contract contract, HashMap<String, String> fields) throws IOException {
for (String fieldName : fields.keySet()) {
report("update field: " + fieldName + " -> " + fields.get(fieldName));
Binder binder = new Binder();
Binder data = null;
try {
XStream xstream = new XStream(new DomDriver());
xstream.registerConverter(new MapEntryConverter());
xstream.alias(fieldName, Binder.class);
data = Binder.convertAllMapsToBinders(xstream.fromXML(fields.get(fieldName)));
} catch (Exception xmlEx) {
// xmlEx.printStackTrace();
try {
Gson gson = new GsonBuilder().create();
binder = Binder.convertAllMapsToBinders(gson.fromJson(fields.get(fieldName), Binder.class));
data = (Binder) data.get(fieldName);
} catch (Exception jsonEx) {
// jsonEx.printStackTrace();
try {
Yaml yaml = new Yaml();
data = Binder.convertAllMapsToBinders(yaml.load(fields.get(fieldName)));
data = (Binder) data.get(fieldName);
} catch (Exception yamlEx) {
yamlEx.printStackTrace();
}
}
}
if (data != null) {
BiDeserializer bm = DefaultBiMapper.getInstance().newDeserializer();
binder.put("data", bm.deserialize(data));
contract.set(fieldName, binder);
report("update field " + fieldName + " ok");
} else {
report("update field " + fieldName + " error: no valid data");
}
}
report("contract expires at " + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(contract.getExpiresAt()));
}
Aggregations