Search in sources :

Example 1 with ModelSelectionProvider

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;
                }
            }
        }
    }
}
Also used : SelectionProviderReference(com.manydesigns.portofino.resourceactions.m2m.configuration.SelectionProviderReference) ModelSelectionProvider(com.manydesigns.portofino.model.database.ModelSelectionProvider) ForeignKey(com.manydesigns.portofino.model.database.ForeignKey)

Aggregations

ForeignKey (com.manydesigns.portofino.model.database.ForeignKey)1 ModelSelectionProvider (com.manydesigns.portofino.model.database.ModelSelectionProvider)1 SelectionProviderReference (com.manydesigns.portofino.resourceactions.m2m.configuration.SelectionProviderReference)1