use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigUtil method saveCubridConf.
/**
* save cubrid broker conf
* @param monitor
* @param brokerConfMap
* @param editorInput
* @return failed server
*/
public List<String> saveCubridConf(IProgressMonitor monitor, LinkedHashMap<String, CubridConfConfig> cubridConfMap, CubridServer[] cubridServers) {
List<String> failedServer = new ArrayList<String>();
for (Entry<String, CubridConfConfig> entry : cubridConfMap.entrySet()) {
CubridConfConfig cubridConfConfig = entry.getValue();
String serverName = entry.getKey();
String contents = parseCubridConfConfigToDocumnetString(cubridConfConfig);
CubridServer cubridServer = getCubridServer(serverName, cubridServers);
if (cubridServer != null) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorSavingDataMsg2, "cubrid.conf", serverName));
String[] lines = contents.split(System.getProperty("line.separator"));
SetCubridConfParameterTask task = new SetCubridConfParameterTask(cubridServer.getServerInfo());
task.setConfContents(Arrays.asList(lines));
task.execute();
if (!task.isSuccess()) {
failedServer.add(cubridServer.getName());
}
task.finish();
monitor.worked(1);
}
}
return failedServer;
}
use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigUtil method parseCommonTableValueToCubridConfConfig.
/**
* parse common table value to cubrid config model list
* @param dataList
* @return
*/
public LinkedHashMap<String, CubridConfConfig> parseCommonTableValueToCubridConfConfig(List<Map<String, String>> dataList, int tableColumnCount) {
LinkedHashMap<String, CubridConfConfig> cubridConfConfigMap = new LinkedHashMap<String, CubridConfConfig>();
Map<String, String> serverNameMap = null;
Map<String, String> cubridConfNameMap = null;
for (int i = 0; i < dataList.size(); i++) {
if (i == 0) {
//first data is server name
serverNameMap = dataList.get(i);
for (int j = 1; j < serverNameMap.size(); j++) {
String serverName = serverNameMap.get(j + "");
if (serverName == null || "".equals(serverName)) {
continue;
}
if (cubridConfConfigMap.get(serverName) == null) {
CubridConfConfig config = new CubridConfConfig();
cubridConfConfigMap.put(serverName, config);
}
}
} else if (i == 1) {
//second data is server name
cubridConfNameMap = dataList.get(i);
for (int j = 1; j < cubridConfNameMap.size(); j++) {
String cubridConfName = cubridConfNameMap.get(j + "");
if (cubridConfName == null || "".equals(cubridConfName)) {
continue;
}
String annotation = cubridConfNameMap.get(j + UnifyHostConfigEditor.ANNOTATION);
CubridConfProperty cubridConfProperty = new CubridConfProperty();
cubridConfProperty.setCubridConfPropKey(cubridConfName);
cubridConfProperty.setCubridConfPropAnnotation(annotation);
cubridConfProperty.setCubridConf(true);
String serverName = serverNameMap.get(j + "");
CubridConfConfig config = cubridConfConfigMap.get(serverName);
config.addCubridConfProperty(cubridConfProperty);
}
} else {
Map<String, String> valueMap = dataList.get(i);
String propName = "";
String propValue = "";
for (int j = 0; j < tableColumnCount; j++) {
String value = valueMap.get(Integer.toString(j));
if (j == 0) {
propName = value;
continue;
}
propValue = value;
if (propValue != null && !"".equals(propValue)) {
String cubridConfName = cubridConfNameMap.get(j + "");
String serverName = serverNameMap.get(j + "");
CubridConfConfig config = cubridConfConfigMap.get(serverName);
CubridConfProperty cubridConf = getCubridConfPropertyByCubridConfName(config, cubridConfName);
if (cubridConf != null) {
CubridConfProperty cubridConfProp = new CubridConfProperty();
cubridConf.addCubridConfProperty(cubridConfProp);
cubridConfProp.setCubridConfPropKey(propName);
cubridConfProp.setCubridConfPropValue(propValue);
String annotation = valueMap.get(Integer.toString(j) + UnifyHostConfigEditor.ANNOTATION);
cubridConfProp.setCubridConfPropAnnotation(annotation);
}
}
}
}
}
return cubridConfConfigMap;
}
use of com.cubrid.cubridmanager.ui.host.model.CubridConfConfig in project cubrid-manager by CUBRID.
the class UnifyHostConfigUtil method parseCubridConfConfigToCommonTableValue.
/**
* parse cubrid data to table value
* @param Map<String, CubridConfConfig> cubridConfConfigDataMap
*/
public List<Map<String, String>> parseCubridConfConfigToCommonTableValue(Map<String, CubridConfConfig> cubridConfConfigDataMap) {
List<Map<String, String>> result = new ArrayList<Map<String, String>>();
//mark property in the list
List<String> propList = new ArrayList<String>();
Map<String, String> dataMap = null;
Map<String, String> serverMap = new HashMap<String, String>();
Map<String, String> cubridMap = new HashMap<String, String>();
//first row as server name
result.add(serverMap);
serverMap.put("0", UnifyHostConfigEditor.SERVERNAMECOLUMNTITLE);
int index = 1;
for (Entry<String, CubridConfConfig> entry : cubridConfConfigDataMap.entrySet()) {
CubridConfConfig cubridConfConfig = entry.getValue();
for (CubridConfProperty cubridConfProperty : cubridConfConfig.getPropertyList()) {
//server name
serverMap.put("" + index, entry.getKey());
if (cubridConfProperty.getCubridConfPropAnnotation() != null) {
//set annotation
serverMap.put(Integer.toString(index) + UnifyHostConfigEditor.ANNOTATION, cubridConfProperty.getCubridConfPropAnnotation());
}
index++;
}
}
//second row as broker name
result.add(cubridMap);
cubridMap.put("0", UnifyHostConfigEditor.CUBRIDNAMECOLUMNTITLE);
index = 1;
for (Entry<String, CubridConfConfig> entry : cubridConfConfigDataMap.entrySet()) {
CubridConfConfig cubridConfConfig = entry.getValue();
for (CubridConfProperty cubridConfProperty : cubridConfConfig.getPropertyList()) {
//cubrid name
cubridMap.put("" + index, cubridConfProperty.getCubridConfPropKey());
if (cubridConfProperty.getCubridConfPropAnnotation() != null) {
//set annotation
cubridMap.put(Integer.toString(index) + UnifyHostConfigEditor.ANNOTATION, cubridConfProperty.getCubridConfPropAnnotation());
}
index++;
}
}
for (Entry<String, CubridConfConfig> entry : cubridConfConfigDataMap.entrySet()) {
String serviceName = entry.getKey();
CubridConfConfig cubridConfConfig = entry.getValue();
for (CubridConfProperty cubridConfProperty : cubridConfConfig.getPropertyList()) {
String cubridName = cubridConfProperty.getCubridConfPropKey();
for (CubridConfProperty prop : cubridConfProperty.getPropertyList()) {
String properKey = prop.getCubridConfPropKey();
if (!propList.contains(properKey)) {
//a new property
propList.add(properKey);
dataMap = new HashMap<String, String>();
result.add(dataMap);
dataMap.put("0", prop.getCubridConfPropKey());
if (prop.getCubridConfPropValue() != null) {
dataMap.put("0", prop.getCubridConfPropKey());
}
String indexString = getMapKeyByValue(serverMap, cubridMap, serviceName, cubridName);
if (indexString != null) {
dataMap.put(indexString, prop.getCubridConfPropValue());
if (prop.getCubridConfPropAnnotation() != null) {
dataMap.put(indexString + UnifyHostConfigEditor.ANNOTATION, prop.getCubridConfPropAnnotation());
}
}
} else {
Map<String, String> oneRowData = getRowData(result, properKey);
String indexString = getMapKeyByValue(serverMap, cubridMap, serviceName, cubridName);
String value = prop.getCubridConfPropValue();
String annotation = prop.getCubridConfPropAnnotation();
if (oneRowData != null && indexString != null && value != null) {
oneRowData.put(indexString, value);
if (annotation != null) {
oneRowData.put(indexString + UnifyHostConfigEditor.ANNOTATION, annotation);
}
}
}
}
}
}
return result;
}
Aggregations