use of com.manydesigns.portofino.model.database.ModelSelectionProvider in project Portofino by ManyDesigns.
the class ConfigurationForm method writeTo.
public void writeTo(ManyToManyConfiguration m2mConfiguration) {
m2mConfiguration.setViewType(viewType);
m2mConfiguration.setDatabase(database);
m2mConfiguration.setQuery(query);
m2mConfiguration.setOneExpression(oneExpression);
m2mConfiguration.setOnePropertyName(onePropertyName);
if (StringUtils.isEmpty(oneSpName)) {
m2mConfiguration.setOneSelectionProvider(null);
} else {
boolean found = false;
for (ForeignKey fk : m2mConfiguration.getActualRelationTable().getForeignKeys()) {
if (fk.getName().equals(oneSpName)) {
SelectionProviderReference ref = new SelectionProviderReference();
ref.setForeignKeyName(oneSpName);
m2mConfiguration.setOneSelectionProvider(ref);
found = true;
break;
}
}
if (!found) {
for (ModelSelectionProvider sp : m2mConfiguration.getActualRelationTable().getSelectionProviders()) {
if (sp.getName().equals(oneSpName)) {
SelectionProviderReference ref = new SelectionProviderReference();
ref.setSelectionProviderName(oneSpName);
m2mConfiguration.setOneSelectionProvider(ref);
break;
}
}
}
}
if (StringUtils.isEmpty(manySpName) || m2mConfiguration.getActualRelationTable() == null) {
m2mConfiguration.setManySelectionProvider(null);
} else {
boolean found = false;
for (ForeignKey fk : m2mConfiguration.getActualRelationTable().getForeignKeys()) {
if (fk.getName().equals(manySpName)) {
SelectionProviderReference ref = new SelectionProviderReference();
ref.setForeignKeyName(manySpName);
m2mConfiguration.setManySelectionProvider(ref);
found = true;
break;
}
}
if (!found) {
for (ModelSelectionProvider sp : m2mConfiguration.getActualRelationTable().getSelectionProviders()) {
if (sp.getName().equals(manySpName)) {
SelectionProviderReference ref = new SelectionProviderReference();
ref.setSelectionProviderName(manySpName);
m2mConfiguration.setManySelectionProvider(ref);
break;
}
}
}
}
}
Aggregations