Search in sources :

Example 1 with SurrogateKey

use of org.tmdmaker.core.model.SurrogateKey in project tmdmaker by tmdmaker.

the class ImplementRule method findAllImplementAttributes.

/**
 * モデルの実装対象アトリビュートを取得する
 *
 * @param model
 *            対象モデル
 * @return アトリビュートのリスト
 */
public static List<IAttribute> findAllImplementAttributes(AbstractEntityModel model) {
    List<IAttribute> attributes = new ArrayList<IAttribute>();
    SurrogateKey surrogateKey = model.getKeyModels().getSurrogateKey();
    if (surrogateKey.isEnabled()) {
        attributes.add(surrogateKey);
    }
    // 個体指定子を追加
    addIdentifier(model, attributes);
    // re-usedを追加
    Map<AbstractEntityModel, ReusedIdentifier> reused = model.getReusedIdentifiers();
    for (Entry<AbstractEntityModel, ReusedIdentifier> entry : reused.entrySet()) {
        ReusedIdentifier ri = entry.getValue();
        if (ri == null) {
            continue;
        }
        if (ri.isSurrogateKeyEnabled()) {
            for (SurrogateKeyRef s : ri.getSurrogateKeys()) {
                attributes.add(s);
            }
        } else {
            for (IdentifierRef ref : ri.getUniqueIdentifiers()) {
                attributes.add(ref);
            }
        }
    }
    // モデルのアトリビュートを追加
    attributes.addAll(model.getAttributes());
    // 派生元に戻して実装するモデルのアトリビュートを追加
    for (AbstractEntityModel m : model.getImplementDerivationModels()) {
        attributes.addAll(m.getAttributes());
    }
    return attributes;
}
Also used : ReusedIdentifier(org.tmdmaker.core.model.ReusedIdentifier) SurrogateKeyRef(org.tmdmaker.core.model.SurrogateKeyRef) IAttribute(org.tmdmaker.core.model.IAttribute) ArrayList(java.util.ArrayList) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) SurrogateKey(org.tmdmaker.core.model.SurrogateKey) IdentifierRef(org.tmdmaker.core.model.IdentifierRef)

Example 2 with SurrogateKey

use of org.tmdmaker.core.model.SurrogateKey in project tmdmaker by tmdmaker.

the class EditImplementEntity method addSurrogateKey.

private void addSurrogateKey(AbstractEntityModel model) {
    KeyModels originalKeyModels = model.getKeyModels();
    if (originalKeyModels == null) {
        return;
    }
    originalKeyModels.copyTo(keyModels);
    SurrogateKey key = originalKeyModels.getSurrogateKey();
    surrogateKey = new EditSurrogateKey(model, key);
    if (surrogateKey.isEnabled()) {
        attributes.add(surrogateKey);
    }
}
Also used : KeyModels(org.tmdmaker.core.model.KeyModels) SurrogateKey(org.tmdmaker.core.model.SurrogateKey)

Example 3 with SurrogateKey

use of org.tmdmaker.core.model.SurrogateKey in project tmdmaker by tmdmaker.

the class ImplementInfoEditAction method run.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    ImplementInfoEditDialog dialog = new ImplementInfoEditDialog(getPart().getViewer().getControl().getShell(), getModel());
    if (dialog.open() == Dialog.OK) {
        CompoundCommand ccommand = new CompoundCommand();
        ccommand.add(new ModelEditCommand(getModel(), dialog.getEditedValueEntity()));
        for (EditImplementAttribute ea : dialog.getEditedValueAttributes()) {
            IAttribute original = ea.getOriginalAttribute();
            IAttribute newAttribute = original.getCopy();
            ea.copyTo(newAttribute);
            ccommand.add(new AttributeEditCommand(original, newAttribute, ea.getContainerModel()));
        }
        SurrogateKey newSurrogateKey = new SurrogateKey();
        EditSurrogateKey edited = dialog.getEditedSurrogateKey();
        edited.copyTo(newSurrogateKey);
        ImplementRule.setSurrogateKeyDefaultValue(newSurrogateKey);
        SurrogateKey original = (SurrogateKey) edited.getOriginalAttribute();
        ccommand.add(new AttributeEditCommand(original, newSurrogateKey, edited.getContainerModel()));
        execute(ccommand);
    }
}
Also used : EditSurrogateKey(org.tmdmaker.ui.dialogs.model.EditSurrogateKey) EditImplementAttribute(org.tmdmaker.ui.dialogs.model.EditImplementAttribute) ImplementInfoEditDialog(org.tmdmaker.ui.dialogs.ImplementInfoEditDialog) IAttribute(org.tmdmaker.core.model.IAttribute) AttributeEditCommand(org.tmdmaker.ui.editor.gef3.commands.AttributeEditCommand) ModelEditCommand(org.tmdmaker.ui.editor.gef3.commands.ModelEditCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EditSurrogateKey(org.tmdmaker.ui.dialogs.model.EditSurrogateKey) SurrogateKey(org.tmdmaker.core.model.SurrogateKey)

Aggregations

SurrogateKey (org.tmdmaker.core.model.SurrogateKey)3 IAttribute (org.tmdmaker.core.model.IAttribute)2 ArrayList (java.util.ArrayList)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)1 IdentifierRef (org.tmdmaker.core.model.IdentifierRef)1 KeyModels (org.tmdmaker.core.model.KeyModels)1 ReusedIdentifier (org.tmdmaker.core.model.ReusedIdentifier)1 SurrogateKeyRef (org.tmdmaker.core.model.SurrogateKeyRef)1 ImplementInfoEditDialog (org.tmdmaker.ui.dialogs.ImplementInfoEditDialog)1 EditImplementAttribute (org.tmdmaker.ui.dialogs.model.EditImplementAttribute)1 EditSurrogateKey (org.tmdmaker.ui.dialogs.model.EditSurrogateKey)1 AttributeEditCommand (org.tmdmaker.ui.editor.gef3.commands.AttributeEditCommand)1 ModelEditCommand (org.tmdmaker.ui.editor.gef3.commands.ModelEditCommand)1