}
if (property) {
return;
}
} else {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributeempty", title), Issue.Level.SEVERE));
return;
}
if (!property && type.isEmpty()) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributetype1", title), Issue.Level.SEVERE));
type = "string";
}
if (!property) {
//Class type
if (forStr.isEmpty() || !(forStr.equalsIgnoreCase("node") || forStr.equalsIgnoreCase("edge") || forStr.equalsIgnoreCase("all"))) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributeclass", title), Issue.Level.SEVERE));
return;
}
//Default?
boolean end = false;
boolean defaultFlag = false;
while (reader.hasNext() && !end) {
int xmltype = reader.next();
switch (xmltype) {
case XMLStreamReader.START_ELEMENT:
if (ATTRIBUTE_DEFAULT.equalsIgnoreCase(xmlReader.getLocalName())) {
defaultFlag = true;
}
break;
case XMLStreamReader.CHARACTERS:
if (defaultFlag && !xmlReader.isWhiteSpace()) {
defaultStr = xmlReader.getText();
}
break;
case XMLStreamReader.END_ELEMENT:
if (ATTRIBUTE.equalsIgnoreCase(xmlReader.getLocalName())) {
end = true;
}
break;
}
}
//Type
AttributeType attributeType = AttributeType.STRING;
if (type.equalsIgnoreCase("boolean") || type.equalsIgnoreCase("bool")) {
attributeType = AttributeType.BOOLEAN;
} else if (type.equalsIgnoreCase("integer") || type.equalsIgnoreCase("int")) {
attributeType = AttributeType.INT;
} else if (type.equalsIgnoreCase("long")) {
attributeType = AttributeType.LONG;
} else if (type.equalsIgnoreCase("float")) {
attributeType = AttributeType.FLOAT;
} else if (type.equalsIgnoreCase("double")) {
attributeType = AttributeType.DOUBLE;
} else if (type.equalsIgnoreCase("string")) {
attributeType = AttributeType.STRING;
} else if (type.equalsIgnoreCase("bigdecimal")) {
attributeType = AttributeType.BIGDECIMAL;
} else if (type.equalsIgnoreCase("biginteger")) {
attributeType = AttributeType.BIGINTEGER;
} else if (type.equalsIgnoreCase("byte")) {
attributeType = AttributeType.BYTE;
} else if (type.equalsIgnoreCase("char")) {
attributeType = AttributeType.CHAR;
} else if (type.equalsIgnoreCase("short")) {
attributeType = AttributeType.SHORT;
} else if (type.equalsIgnoreCase("listboolean")) {
attributeType = AttributeType.LIST_BOOLEAN;
} else if (type.equalsIgnoreCase("listint")) {
attributeType = AttributeType.LIST_INTEGER;
} else if (type.equalsIgnoreCase("listlong")) {
attributeType = AttributeType.LIST_LONG;
} else if (type.equalsIgnoreCase("listfloat")) {
attributeType = AttributeType.LIST_FLOAT;
} else if (type.equalsIgnoreCase("listdouble")) {
attributeType = AttributeType.LIST_DOUBLE;
} else if (type.equalsIgnoreCase("liststring")) {
attributeType = AttributeType.LIST_STRING;
} else if (type.equalsIgnoreCase("listbigdecimal")) {
attributeType = AttributeType.LIST_BIGDECIMAL;
} else if (type.equalsIgnoreCase("listbiginteger")) {
attributeType = AttributeType.LIST_BIGINTEGER;
} else if (type.equalsIgnoreCase("listbyte")) {
attributeType = AttributeType.LIST_BYTE;
} else if (type.equalsIgnoreCase("listchar")) {
attributeType = AttributeType.LIST_CHARACTER;
} else if (type.equalsIgnoreCase("listshort")) {
attributeType = AttributeType.LIST_SHORT;
} else {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributetype2", type), Issue.Level.SEVERE));
return;
}
//Default Object
Object defaultValue = null;
if (!defaultStr.isEmpty()) {
try {
defaultValue = attributeType.parse(defaultStr);
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_log_default", defaultStr, title));
} catch (Exception e) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributedefault", title, attributeType.getTypeString()), Issue.Level.SEVERE));
}
}
//Add to model
if ("node".equalsIgnoreCase(forStr) || "all".equalsIgnoreCase(forStr)) {
if (container.getAttributeModel().getNodeTable().hasColumn(id) || container.getAttributeModel().getNodeTable().hasColumn(title)) {
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributecolumn_exist", id));
return;
}
container.getAttributeModel().getNodeTable().addColumn(id, title, attributeType, AttributeOrigin.DATA, defaultValue);
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_log_nodeattribute", title, attributeType.getTypeString()));
} else if ("edge".equalsIgnoreCase(forStr) || "all".equalsIgnoreCase(forStr)) {
if (container.getAttributeModel().getEdgeTable().hasColumn(id) || container.getAttributeModel().getEdgeTable().hasColumn(title)) {
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributecolumn_exist", id));
return;
}
container.getAttributeModel().getEdgeTable().addColumn(id, title, attributeType, AttributeOrigin.DATA, defaultValue);
report.log(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_log_edgeattribute", title, attributeType.getTypeString()));
}
} else {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_attributeempty", title), Issue.Level.SEVERE));
}
}