//Dynamic?
boolean dynamic = typeAtt.equalsIgnoreCase("dynamic");
//Type
AttributeType attributeType = AttributeType.STRING;
if (type.equalsIgnoreCase("boolean") || type.equalsIgnoreCase("bool")) {
attributeType = dynamic ? AttributeType.DYNAMIC_BOOLEAN : AttributeType.BOOLEAN;
} else if (type.equalsIgnoreCase("integer") || type.equalsIgnoreCase("int")) {
attributeType = dynamic ? AttributeType.DYNAMIC_INT : AttributeType.INT;
} else if (type.equalsIgnoreCase("long")) {
attributeType = dynamic ? AttributeType.DYNAMIC_LONG : AttributeType.LONG;
} else if (type.equalsIgnoreCase("float")) {
attributeType = dynamic ? AttributeType.DYNAMIC_FLOAT : AttributeType.FLOAT;
} else if (type.equalsIgnoreCase("double")) {
attributeType = dynamic ? AttributeType.DYNAMIC_DOUBLE : AttributeType.DOUBLE;
} else if (type.equalsIgnoreCase("string")) {
attributeType = dynamic ? AttributeType.DYNAMIC_STRING : AttributeType.STRING;
} else if (type.equalsIgnoreCase("bigdecimal")) {
attributeType = dynamic ? AttributeType.DYNAMIC_BIGDECIMAL : AttributeType.BIGDECIMAL;
} else if (type.equalsIgnoreCase("biginteger")) {
attributeType = dynamic ? AttributeType.DYNAMIC_BIGINTEGER : AttributeType.BIGINTEGER;
} else if (type.equalsIgnoreCase("byte")) {
attributeType = dynamic ? AttributeType.DYNAMIC_BYTE : AttributeType.BYTE;
} else if (type.equalsIgnoreCase("char")) {
attributeType = dynamic ? AttributeType.DYNAMIC_CHAR : AttributeType.CHAR;
} else if (type.equalsIgnoreCase("short")) {
attributeType = dynamic ? AttributeType.DYNAMIC_SHORT : 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(ImporterGEXF.class, "importerGEXF_error_attributetype2", type), Issue.Level.SEVERE));
return;
}
//Default Object
Object defaultValue = null;
if (!defaultStr.isEmpty()) {
try {
defaultValue = attributeType.parse(defaultStr);
report.log(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_log_default", defaultStr, title));
} catch (Exception e) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_error_attributedefault", title, attributeType.getTypeString()), Issue.Level.SEVERE));
}
}
//Add to model
if ("node".equalsIgnoreCase(classAtt) || classAtt.isEmpty()) {
if (container.getAttributeModel().getNodeTable().hasColumn(id) || container.getAttributeModel().getNodeTable().hasColumn(title)) {
report.log(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_error_attributecolumn_exist", id));
return;
}
container.getAttributeModel().getNodeTable().addColumn(id, title, attributeType, AttributeOrigin.DATA, defaultValue);
report.log(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_log_nodeattribute", title, attributeType.getTypeString()));
} else if ("edge".equalsIgnoreCase(classAtt) || classAtt.isEmpty()) {
if ((id.equalsIgnoreCase("weight") || title.equalsIgnoreCase("weight")) && dynamic && attributeType.equals(AttributeType.DYNAMIC_FLOAT)) {
//Dynamic weight
report.log(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_log_dynamic_weight", id));
container.getAttributeModel().getEdgeTable().removeColumn(container.getAttributeModel().getEdgeTable().getColumn(PropertiesColumn.EDGE_WEIGHT.getIndex()));
container.getAttributeModel().getEdgeTable().addColumn(id, PropertiesColumn.EDGE_WEIGHT.getTitle(), attributeType, AttributeOrigin.PROPERTY, defaultValue);
return;
} else if (container.getAttributeModel().getEdgeTable().hasColumn(id) || container.getAttributeModel().getEdgeTable().hasColumn(title)) {
report.log(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_error_attributecolumn_exist", id));
return;
}
container.getAttributeModel().getEdgeTable().addColumn(id, title, attributeType, AttributeOrigin.DATA, defaultValue);
report.log(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_log_edgeattribute", title, attributeType.getTypeString()));
}
} else {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_error_attributeempty", title), Issue.Level.SEVERE));
}
}