Search in sources :

Example 1 with SurrogateKeyRef

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

the class DdlUtilsConverter method convert.

/**
 * Re-Used 列を DdlUtils の Reference のリストに変換する
 */
private List<Reference> convert(ReusedIdentifier reused) {
    List<Reference> refences = new ArrayList<Reference>();
    if (reused.isSurrogateKeyEnabled()) {
        // 再帰表の場合を考慮して1つ目のみを取得
        SurrogateKeyRef sref = reused.getSurrogateKeys().get(0);
        Column localColumn = convert(sref);
        Column originalColumn = convert(sref.getOriginal());
        addReference(refences, localColumn, originalColumn);
        return refences;
    } else {
        List<IdentifierRef> list = reused.getUniqueIdentifiers();
        int reusedCount = list.size();
        // 再帰表は同一Reused×2となっているため1つ目のみを取得する
        if (isRecursive(reused)) {
            reusedCount = reusedCount / 2;
        }
        for (int i = 0; i < reusedCount; i++) {
            IdentifierRef iref = list.get(i);
            Column localColumn = convert(iref);
            Column originalColumn = convert(iref.getOriginal());
            addReference(refences, localColumn, originalColumn);
        }
        return refences;
    }
}
Also used : SurrogateKeyRef(org.tmdmaker.core.model.SurrogateKeyRef) IndexColumn(org.apache.ddlutils.model.IndexColumn) Column(org.apache.ddlutils.model.Column) Reference(org.apache.ddlutils.model.Reference) ArrayList(java.util.ArrayList) IdentifierRef(org.tmdmaker.core.model.IdentifierRef)

Example 2 with SurrogateKeyRef

use of org.tmdmaker.core.model.SurrogateKeyRef 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)

Aggregations

ArrayList (java.util.ArrayList)2 IdentifierRef (org.tmdmaker.core.model.IdentifierRef)2 SurrogateKeyRef (org.tmdmaker.core.model.SurrogateKeyRef)2 Column (org.apache.ddlutils.model.Column)1 IndexColumn (org.apache.ddlutils.model.IndexColumn)1 Reference (org.apache.ddlutils.model.Reference)1 AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)1 IAttribute (org.tmdmaker.core.model.IAttribute)1 ReusedIdentifier (org.tmdmaker.core.model.ReusedIdentifier)1 SurrogateKey (org.tmdmaker.core.model.SurrogateKey)1