cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skolbac...@apache.org
Subject [3/3] cayenne git commit: Merge branch '159'
Date Mon, 19 Dec 2016 12:03:12 GMT
Merge branch '159'


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/62652ff7
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/62652ff7
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/62652ff7

Branch: refs/heads/master
Commit: 62652ff7731109d11cf239b796bc579f6b49167c
Parents: 63ce571 a026d83
Author: Savva Kolbachev <s.kolbachev@gmail.com>
Authored: Mon Dec 19 15:02:58 2016 +0300
Committer: Savva Kolbachev <s.kolbachev@gmail.com>
Committed: Mon Dec 19 15:02:58 2016 +0300

----------------------------------------------------------------------
 .../cayenne/dbsync/merge/DataMapMerger.java     |   3 +-
 .../dbsync/merge/token/AbstractMergerToken.java |  59 ++++++++
 .../dbsync/merge/token/DummyReverseToken.java   |  10 ++
 .../cayenne/dbsync/merge/token/MergerToken.java |   4 +-
 .../dbsync/merge/token/TokenComparator.java     |  58 -------
 .../merge/token/db/AbstractToDbToken.java       |  52 ++-----
 .../dbsync/merge/token/db/AddColumnToDb.java    |  11 +-
 .../merge/token/db/AddRelationshipToDb.java     |  11 +-
 .../dbsync/merge/token/db/CreateTableToDb.java  |   2 +-
 .../dbsync/merge/token/db/DropColumnToDb.java   |  12 +-
 .../merge/token/db/DropRelationshipToDb.java    |  11 +-
 .../dbsync/merge/token/db/DropTableToDb.java    |   2 +-
 .../dbsync/merge/token/db/SetAllowNullToDb.java |   2 +-
 .../merge/token/db/SetColumnTypeToDb.java       |   2 +-
 .../dbsync/merge/token/db/SetNotNullToDb.java   |   2 +-
 .../merge/token/db/SetPrimaryKeyToDb.java       |   2 +-
 .../merge/token/db/SetValueForNullToDb.java     |   2 +-
 .../merge/token/model/AbstractToModelToken.java |  34 +----
 .../merge/token/model/AddColumnToModel.java     |   2 +-
 .../token/model/AddRelationshipToModel.java     |   2 +-
 .../merge/token/model/CreateTableToModel.java   |   2 +-
 .../merge/token/model/DropColumnToModel.java    |   2 +-
 .../token/model/DropRelationshipToModel.java    |   2 +-
 .../merge/token/model/DropTableToModel.java     |   2 +-
 .../merge/token/model/SetAllowNullToModel.java  |   2 +-
 .../merge/token/model/SetColumnTypeToModel.java |   2 +-
 .../merge/token/model/SetNotNullToModel.java    |   2 +-
 .../merge/token/model/SetPrimaryKeyToModel.java |   4 +-
 .../dbsync/merge/token/TokenComparatorTest.java | 113 --------------
 .../dbsync/merge/token/TokenSortTest.java       | 150 +++++++++++++++++++
 .../tools/dbimport/DefaultDbImportAction.java   |   3 +-
 .../dbimport/DefaultDbImportActionTest.java     |   2 +-
 docs/doc/src/main/resources/RELEASE-NOTES.txt   |   1 +
 .../db/merge/MergerTokenSelectorController.java |   3 +-
 .../cayenne/tools/DbImporterMojoTest.java       |  14 +-
 .../dbimport/testComplexChangeOrder-pom.xml     |  42 ++++++
 .../dbimport/testComplexChangeOrder.map.xml     |  64 ++++++++
 .../testComplexChangeOrder.map.xml-result       |  54 +++++++
 .../tools/dbimport/testComplexChangeOrder.sql   |  34 +++++
 39 files changed, 478 insertions(+), 303 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/62652ff7/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/db/CreateTableToDb.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cayenne/blob/62652ff7/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/db/SetPrimaryKeyToDb.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cayenne/blob/62652ff7/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/model/DropColumnToModel.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cayenne/blob/62652ff7/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --cc docs/doc/src/main/resources/RELEASE-NOTES.txt
index bfa6f15,937d8e0..eb13a0e
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@@ -19,11 -19,9 +19,12 @@@ CAY-2165 Explicit "contribution" API fo
  CAY-2166 Auto-loading of Cayenne modules
  CAY-2168 Split DbLoader to parts and clean it up
  CAY-2169 Split DbMerger to parts and clean it up
+ CAY-2170 MergeToken sorting is highly unstable
 +CAY-2172 Cleanup Modeler import and migrate db actions
 +CAY-2176 Java 7 diamond class generation templates
  
  Bug Fixes:
 +CAY-2174 Change FK attribute name cause ObjAttribute appear after Reverse Engineering
  
  ----------------------------------
  Release: 4.0.M4

http://git-wip-us.apache.org/repos/asf/cayenne/blob/62652ff7/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/merge/MergerTokenSelectorController.java
----------------------------------------------------------------------
diff --cc modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/merge/MergerTokenSelectorController.java
index 7f6d4da,0000000..21d0e82
mode 100644,000000..100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/merge/MergerTokenSelectorController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/merge/MergerTokenSelectorController.java
@@@ -1,240 -1,0 +1,239 @@@
 +/*****************************************************************
 + *   Licensed to the Apache Software Foundation (ASF) under one
 + *  or more contributor license agreements.  See the NOTICE file
 + *  distributed with this work for additional information
 + *  regarding copyright ownership.  The ASF licenses this file
 + *  to you under the Apache License, Version 2.0 (the
 + *  "License"); you may not use this file except in compliance
 + *  with the License.  You may obtain a copy of the License at
 + *
 + *    http://www.apache.org/licenses/LICENSE-2.0
 + *
 + *  Unless required by applicable law or agreed to in writing,
 + *  software distributed under the License is distributed on an
 + *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + *  KIND, either express or implied.  See the License for the
 + *  specific language governing permissions and limitations
 + *  under the License.
 + ****************************************************************/
 +
 +package org.apache.cayenne.modeler.dialog.db.merge;
 +
 +import org.apache.cayenne.dbsync.merge.context.MergeDirection;
 +import org.apache.cayenne.dbsync.merge.token.MergerToken;
- import org.apache.cayenne.dbsync.merge.token.TokenComparator;
 +import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactory;
 +import org.apache.cayenne.modeler.Application;
 +import org.apache.cayenne.modeler.util.CayenneController;
 +import org.apache.cayenne.swing.BindingBuilder;
 +import org.apache.cayenne.swing.ObjectBinding;
 +
 +import javax.swing.*;
 +import javax.swing.table.AbstractTableModel;
 +import javax.swing.table.TableColumn;
 +import javax.swing.table.TableColumnModel;
 +import javax.swing.table.TableModel;
 +import java.awt.*;
 +import java.util.ArrayList;
 +import java.util.Collections;
 +import java.util.HashSet;
 +import java.util.List;
 +import java.util.Set;
 +
 +public class MergerTokenSelectorController extends CayenneController {
 +
 +    protected MergerTokenSelectorView view;
 +    protected ObjectBinding tableBinding;
 +
 +    protected MergerToken token;
 +    protected int permanentlyExcludedCount;
 +    protected Set<MergerToken> excludedTokens;
 +    protected List<MergerToken> selectableTokensList;
 +    protected MergerTokenFactory mergerTokenFactory;
 +
 +    public MergerTokenSelectorController(CayenneController parent) {
 +        super(parent);
 +        this.view = new MergerTokenSelectorView();
 +        this.excludedTokens = new HashSet<MergerToken>();
 +        this.selectableTokensList = new ArrayList<MergerToken>();
 +        initController();
 +    }
 +
 +    public void setMergerTokenFactory(MergerTokenFactory mergerTokenFactory) {
 +        this.mergerTokenFactory = mergerTokenFactory;
 +    }
 +
 +    public void setTokens(List<MergerToken> tokens) {
 +        selectableTokensList.clear();
 +        selectableTokensList.addAll(tokens);
 +        excludedTokens.addAll(tokens);
 +    }
 +
 +    public List<MergerToken> getSelectedTokens() {
 +        List<MergerToken> t = new ArrayList<MergerToken>(selectableTokensList);
 +        t.removeAll(excludedTokens);
 +        return Collections.unmodifiableList(t);
 +    }
 +
 +    public List<MergerToken> getSelectableTokens() {
 +        return Collections.unmodifiableList(selectableTokensList);
 +    }
 +    
 +    public void removeToken(MergerToken token) {
 +        selectableTokensList.remove(token);
 +        excludedTokens.remove(token);
 +
 +        AbstractTableModel model = (AbstractTableModel) view.getTokens().getModel();
 +        model.fireTableDataChanged();
 +    }
 +
 +    // ----- properties -----
 +
 +    public Component getView() {
 +        return view;
 +    }
 +
 +    /**
 +     * Called by table binding script to set current token.
 +     */
 +    public void setToken(MergerToken token) {
 +        this.token = token;
 +    }
 +
 +    /**
 +     * Returns {@link MergerToken}s that are excluded from DB generation.
 +     */
 +    /*
 +     * public Collection getExcludedTokens() { return excludedTokens; }
 +     */
 +
 +    public boolean isIncluded() {
 +        if (token == null) {
 +            return false;
 +        }
 +
 +        return !excludedTokens.contains(token);
 +    }
 +
 +    public void setIncluded(boolean b) {
 +        if (token == null) {
 +            return;
 +        }
 +
 +        if (b) {
 +            excludedTokens.remove(token);
 +        }
 +        else {
 +            excludedTokens.add(token);
 +        }
 +
 +        tableSelectedAction();
 +    }
 +
 +    /**
 +     * A callback action that updates the state of Select All checkbox.
 +     */
 +    public void tableSelectedAction() {
 +        int unselectedCount = excludedTokens.size() - permanentlyExcludedCount;
 +
 +        if (unselectedCount == selectableTokensList.size()) {
 +            view.getCheckAll().setSelected(false);
 +        }
 +        else if (unselectedCount == 0) {
 +            view.getCheckAll().setSelected(true);
 +        }
 +    }
 +
 +    // ------ other stuff ------
 +
 +    protected void initController() {
 +        BindingBuilder builder = new BindingBuilder(
 +                getApplication().getBindingFactory(),
 +                this);
 +
 +        builder.bindToAction(view.getCheckAll(), "checkAllAction()");
 +        builder.bindToAction(view.getReverseAll(), "reverseAllAction()");
 +
 +        TableModel model = new MergerTokenTableModel(this);
 +
 +        MergeDirection[] dirs = new MergeDirection[] {
 +                MergeDirection.TO_DB, MergeDirection.TO_MODEL
 +        };
 +
 +        view.getTokens().setModel(model);
 +
 +        TableColumnModel columnModel = view.getTokens().getColumnModel();
 +        
 +        // dropdown for direction column
 +        JComboBox directionCombo = Application.getWidgetFactory().createComboBox(dirs, false);
 +        directionCombo.setEditable(false);
 +        TableColumn directionColumn = columnModel.getColumn(
 +                MergerTokenTableModel.COL_DIRECTION);
 +        directionColumn.setCellEditor(new DefaultCellEditor(directionCombo));
 +
 +        columnModel.getColumn(MergerTokenTableModel.COL_SELECT).setPreferredWidth(50);
 +        columnModel.getColumn(MergerTokenTableModel.COL_DIRECTION).setPreferredWidth(100);
 +        columnModel.getColumn(MergerTokenTableModel.COL_SELECT).setMaxWidth(50);
 +        columnModel.getColumn(MergerTokenTableModel.COL_DIRECTION).setMaxWidth(100);
 +    }
 +
 +    public boolean isSelected(MergerToken token) {
 +        return (selectableTokensList.contains(token) && !excludedTokens.contains(token));
 +    }
 +
 +    public void select(MergerToken token, boolean select) {
 +        if (select) {
 +            excludedTokens.remove(token);
 +        }
 +        else {
 +            excludedTokens.add(token);
 +        }
 +    }
 +
 +    public void setDirection(MergerToken token, MergeDirection direction) {
 +        if (token.getDirection().equals(direction)) {
 +            return;
 +        }
 +        int i = selectableTokensList.indexOf(token);
 +        MergerToken reverse = token.createReverse(mergerTokenFactory);
 +        selectableTokensList.set(i, reverse);
 +        if (excludedTokens.remove(token)) {
 +            excludedTokens.add(reverse);
 +        }
 +        
 +        /**
 +         * Repaint, so that "Operation" column updates properly
 +         */
 +        view.getTokens().repaint();
 +    }
 +
 +    public void checkAllAction() {
 +
 +        boolean isCheckAllSelected = view.getCheckAll().isSelected();
 +
 +        if (isCheckAllSelected) {
 +            excludedTokens.clear();
 +        }
 +        else {
 +            excludedTokens.addAll(selectableTokensList);
 +        }
 +
 +        AbstractTableModel model = (AbstractTableModel) view.getTokens().getModel();
 +        model.fireTableDataChanged();
 +    }
 +
 +    public void reverseAllAction() {
 +        
 +        for (int i = 0; i < selectableTokensList.size(); i++) {
 +            MergerToken token = selectableTokensList.get(i);
 +            MergerToken reverse = token.createReverse(mergerTokenFactory);
 +            selectableTokensList.set(i, reverse);
 +            if (excludedTokens.remove(token)) {
 +                excludedTokens.add(reverse);
 +            }
 +        }
 +
-         Collections.sort(selectableTokensList, new TokenComparator());
++        Collections.sort(selectableTokensList);
 +        AbstractTableModel model = (AbstractTableModel) view.getTokens().getModel();
 +        model.fireTableDataChanged();
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/62652ff7/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
----------------------------------------------------------------------


Mime
View raw message