Package org.omg.uml.foundation.core

Examples of org.omg.uml.foundation.core.UmlAssociation


            String fkColumnName = columnRs.getString("FKCOLUMN_NAME");
            this.addForeignKey(tableName, fkColumnName);

            // now create the association
            String foreignTableName = columnRs.getString("PKTABLE_NAME");
            UmlAssociation association =
                corePackage.getUmlAssociation().createUmlAssociation(
                    null, VisibilityKindEnum.VK_PUBLIC, false, false, false, false);

            // we set the upper range to 1 if the
            // they primary key of this table is the
            // foreign key of another table (by default
            // its set to a many multiplicity)
            int primaryUpper = -1;
            if (primaryKeys.contains(fkColumnName))
            {
                primaryUpper = 1;
            }

            String endName = null;

            // primary association
            AssociationEnd primaryEnd =
                corePackage.getAssociationEnd().createAssociationEnd(
                    endName,
                    VisibilityKindEnum.VK_PUBLIC,
                    false,
                    true,
                    OrderingKindEnum.OK_UNORDERED,
                    AggregationKindEnum.AK_NONE,
                    ScopeKindEnum.SK_INSTANCE,
                    this.createMultiplicity(
                        corePackage.getDataTypes(),
                        0,
                        primaryUpper),
                    ChangeableKindEnum.CK_CHANGEABLE);
            primaryEnd.setParticipant((Classifier)this.classes.get(tableName));
            association.getConnection().add(primaryEnd);

            boolean required = !this.isColumnNullable(metadata, tableName, fkColumnName);

            int foreignLower = 0;
            if (required)
            {
                foreignLower = 1;
            }

            int deleteRule = columnRs.getInt("DELETE_RULE");

            // determine if we should have composition for
            // the foreign association end depending on cascade delete
            AggregationKindEnum foreignAggregation = AggregationKindEnum.AK_NONE;
            if (deleteRule == DatabaseMetaData.importedKeyCascade)
            {
                foreignAggregation = AggregationKindEnum.AK_COMPOSITE;
            }

            // foriegn association
            AssociationEnd foreignEnd =
                corePackage.getAssociationEnd().createAssociationEnd(
                    endName,
                    VisibilityKindEnum.VK_PUBLIC,
                    false,
                    true,
                    OrderingKindEnum.OK_UNORDERED,
                    foreignAggregation,
                    ScopeKindEnum.SK_INSTANCE,
                    this.createMultiplicity(
                        corePackage.getDataTypes(),
                        foreignLower,
                        1),
                    ChangeableKindEnum.CK_CHANGEABLE);
            final Classifier foreignParticipant = (Classifier)this.classes.get(foreignTableName);
            if (foreignParticipant == null)
            {
                throw new SchemaTransformerException(
                    "The associated table '" + foreignTableName +
                    "' must be available in order to create the association");
            }
            foreignEnd.setParticipant(foreignParticipant);

            if (StringUtils.isNotEmpty(this.columnTaggedValue))
            {
                // add the tagged value for the foreign association end
                TaggedValue taggedValue = this.createTaggedValue(corePackage, this.columnTaggedValue, fkColumnName);
                if (taggedValue != null)
                {
                    foreignEnd.getTaggedValue().add(taggedValue);
                }
            }

            association.getConnection().add(foreignEnd);
            associations.add(association);

            if (logger.isInfoEnabled())
            {
                logger.info(
View Full Code Here

TOP

Related Classes of org.omg.uml.foundation.core.UmlAssociation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.