OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Compare Revisions

Ignore whitespace Rev 161 → Rev 162

/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableDescritor.java
13,15 → 13,14
import org.openconcerto.modules.extensionbuilder.Extension;
import org.openconcerto.modules.extensionbuilder.ExtensionGroupSQLComponent;
import org.openconcerto.modules.extensionbuilder.component.ComponentDescritor;
import org.openconcerto.modules.extensionbuilder.list.ColumnDescriptor;
import org.openconcerto.modules.extensionbuilder.list.ListDescriptor;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.request.RowItemDesc;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
 
public class TableDescritor {
47,6 → 46,37
}
 
@Override
protected List<String> getComboFields() {
List<String> l = new ArrayList<String>();
int matchCodeNom = 0;
for (SQLField field : getTable().getContentFields()) {
l.add(field.getName());
if (field.getName().equalsIgnoreCase("CODE") || field.getName().equalsIgnoreCase("NOM")) {
matchCodeNom++;
}
}
if (matchCodeNom == 2) {
l.add("CODE");
l.add("NOM");
} else {
ListDescriptor listDesc = null;
for (ListDescriptor listDescriptor : ext.getCreateListList()) {
if (listDescriptor.getMainTable().equals(getTable().getName())) {
listDesc = listDescriptor;
break;
}
}
for (ColumnDescriptor string : listDesc.getColumns()) {
if (!string.getFieldsPaths().contains(".")) {
l.add(string.getFieldsPaths());
break;
}
}
}
return l;
}
 
@Override
protected SQLTableModelSourceOnline instantiateTableSourceOnline(ListSQLRequest req) {
ListDescriptor listDesc = null;
for (ListDescriptor listDescriptor : ext.getCreateListList()) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/Extension.java
60,7 → 60,6
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.request.RowItemDesc;
import org.openconcerto.sql.request.SQLFieldTranslator;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.ChangeTable;
439,10 → 438,13
}
// fields creation
boolean mustAdd = false;
final Set<String> addedFieldNames = new HashSet<>();
for (FieldDescriptor fDesc : tDesc.getFields()) {
final SQLField f = (table == null) ? null : table.getFieldRaw(fDesc.getName());
if (f == null) {
final String fieldName = fDesc.getName();
final SQLField f = (table == null) ? null : table.getFieldRaw(fieldName);
if (f == null && !addedFieldNames.contains(fieldName)) {
final String type = fDesc.getType();
addedFieldNames.add(fieldName);
if (type.equals(FieldDescriptor.TYPE_STRING)) {
int l = 256;
try {
450,7 → 452,7
} catch (Exception e) {
Log.get().log(Level.WARNING, "Extension: unable to parse length: " + fDesc.getLength(), e);
}
createTable.addVarCharColumn(fDesc.getName(), l);
createTable.addVarCharColumn(fieldName, l);
} else if (type.equals(FieldDescriptor.TYPE_INTEGER)) {
int defaultVal = 0;
try {
458,7 → 460,7
} catch (Exception e) {
Log.get().log(Level.WARNING, "Extension: unable to parse default integer value : " + fDesc.getDefaultValue(), e);
}
createTable.addIntegerColumn(fDesc.getName(), defaultVal);
createTable.addIntegerColumn(fieldName, defaultVal);
} else if (type.equals(FieldDescriptor.TYPE_DECIMAL)) {
BigDecimal defaultVal = BigDecimal.ZERO;
try {
466,19 → 468,19
} catch (Exception e) {
Log.get().log(Level.WARNING, "Extension: unable to parse default bigdecimal value : " + fDesc.getDefaultValue(), e);
}
createTable.addNumberColumn(fDesc.getName(), BigDecimal.class, defaultVal, false);
createTable.addNumberColumn(fieldName, BigDecimal.class, defaultVal, false);
} else if (type.equals(FieldDescriptor.TYPE_BOOLEAN)) {
String defaultValue = "false";
if (fDesc.getDefaultValue() != null && fDesc.getDefaultValue().equals("true")) {
defaultValue = "true";
}
createTable.addColumn(fDesc.getName(), "boolean", defaultValue, false);
createTable.addColumn(fieldName, "boolean", defaultValue, false);
} else if (type.equals(FieldDescriptor.TYPE_DATE)) {
createTable.addColumn(fDesc.getName(), "date");
createTable.addColumn(fieldName, "date");
} else if (type.equals(FieldDescriptor.TYPE_TIME)) {
createTable.addColumn(fDesc.getName(), "time");
createTable.addColumn(fieldName, "time");
} else if (type.equals(FieldDescriptor.TYPE_DATETIME)) {
createTable.addDateAndTimeColumn(fDesc.getName());
createTable.addDateAndTimeColumn(fieldName);
} else if (type.equals(FieldDescriptor.TYPE_REF)) {
// created later
mustAdd = false;