use of com.cubrid.cubridmanager.core.cubrid.table.model.POJOTemplate in project cubrid-manager by CUBRID.
the class JavaType method getJavaPOJOString.
/**
* Get the POJO String, The type of schemaNode should be table or class
*
* @param schemaNode
* @return the POJO String
*/
public static String getJavaPOJOString(Connection connection, DefaultSchemaNode schemaNode) {
CubridDatabase database = schemaNode.getDatabase();
String tableName = schemaNode.getName();
SchemaInfo schemaInfo = null;
if (connection == null) {
schemaInfo = database.getDatabaseInfo().getSchemaInfo(tableName);
} else {
schemaInfo = database.getDatabaseInfo().getSchemaInfo(connection, tableName);
}
if (schemaInfo == null) {
com.cubrid.common.ui.spi.util.CommonUITool.openErrorBox(Messages.bind(Messages.errGetSchemaInfo, tableName));
LOGGER.debug("Can't get the SchemaInfo:" + tableName);
return "";
}
POJOTemplate template = new POJOTemplate();
template.setTableName(tableName);
StringBuffer typeDeclareSB = new StringBuffer();
typeDeclareSB.append("public class ");
typeDeclareSB.append(getUpperName(tableName));
template.setTypeDeclare(typeDeclareSB.toString());
StringBuffer annotationSB = new StringBuffer();
annotationSB.append("/**" + NEW_LINE);
annotationSB.append(" * Table name : " + tableName + NEW_LINE);
annotationSB.append(" * Generated by CUBRID Tools." + NEW_LINE);
annotationSB.append(" */");
template.setAnnotation(annotationSB.toString());
/* Attributes */
for (DBAttribute dbAttribute : schemaInfo.getAttributes()) {
POJOAttribute attribute = getPOJOAttribute(dbAttribute, true);
if (attribute != null) {
template.getAttributes().add(attribute);
}
}
/* Class Attribute */
for (DBAttribute dbAttribute : schemaInfo.getClassAttributes()) {
POJOAttribute attribute = getPOJOAttribute(dbAttribute, true);
if (attribute != null) {
template.getAttributes().add(attribute);
}
}
return getJavaPOJOString(template);
}
use of com.cubrid.cubridmanager.core.cubrid.table.model.POJOTemplate in project cubrid-manager by CUBRID.
the class JavaType method getPhpPOJOString.
/**
* Get the PHP POJO String, The type of schemaNode should be table or class
*
* @param schemaNode
* @return the POJO String
*/
public static String getPhpPOJOString(Connection connection, DefaultSchemaNode schemaNode) {
CubridDatabase database = schemaNode.getDatabase();
String tableName = schemaNode.getName();
SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(connection, tableName);
if (schemaInfo == null) {
com.cubrid.common.ui.spi.util.CommonUITool.openErrorBox(Messages.bind(Messages.errGetSchemaInfo, tableName));
LOGGER.debug("Can't get the SchemaInfo:" + tableName);
return "";
}
POJOTemplate template = new POJOTemplate();
template.setTableName(tableName);
StringBuffer typeDeclareSB = new StringBuffer();
typeDeclareSB.append("class ");
typeDeclareSB.append(getUpperName(tableName));
template.setTypeDeclare(typeDeclareSB.toString());
StringBuffer annotationSB = new StringBuffer();
annotationSB.append("/**" + NEW_LINE);
annotationSB.append(" * Table name : " + tableName + NEW_LINE);
annotationSB.append(" * Generated by CUBRID Tools." + NEW_LINE);
annotationSB.append(" */");
template.setAnnotation(annotationSB.toString());
/* Attributes */
for (DBAttribute dbAttribute : schemaInfo.getAttributes()) {
POJOAttribute attribute = getPOJOAttribute(dbAttribute, false);
if (attribute != null) {
template.getAttributes().add(attribute);
}
}
/* Class Attribute */
for (DBAttribute dbAttribute : schemaInfo.getClassAttributes()) {
POJOAttribute attribute = getPOJOAttribute(dbAttribute, false);
if (attribute != null) {
template.getAttributes().add(attribute);
}
}
return getPhpPOJOString(template);
}
Aggregations