Login | Register
My pages Projects Community openCollabNet

Discussions > Commit Messages > svn commit: r19960 - trunk/src/argouml-app/src/org/argouml/uml/util/ModelUtil.java

argouml
Discussion topic

Back to topic list

svn commit: r19960 - trunk/src/argouml-app/src/org/argouml/uml/util/ModelUtil.java

Author bobtarling
Full name Bob Tarling
Date 2015-01-11 10:10:43 PST
Message Author: bobtarling
Date: 2015-01-11 10:10:42-0800
New Revision: 19960

Added:
   trunk/src/argouml-ap​p/src/org/argouml/um​l/util/ModelUtil.jav​a

Log:
Move method to generate package from classes out of the Java RE module and into core argo to allow reuse elsewhere

Added: trunk/src/argouml-ap​p/src/org/argouml/um​l/util/ModelUtil.jav​a
Url: http://argouml.tigri​s.org/source/browse/​argouml/trunk/src/ar​gouml-app/src/org/ar​gouml/uml/util/Model​Util.java?view=marku​p&pathrev=19960
====================​====================​====================​==================
--- (empty file)
+++ trunk/src/argouml-ap​p/src/org/argouml/um​l/util/ModelUtil.jav​a 2015-01-11 10:10:42-0800
@@ -0,0 +1,71 @@
+/* $Id$
+ ********************​********************​********************​*******************
+ * Copyright (c) 2015 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.o​rg/legal/epl-v10.htm​l
+ *
+ * Contributors:
+ * Bob Tarling
+ ********************​********************​********************​*******************
+ */
+
+package org.argouml.uml.util;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.argouml.kernel.Project;
+import org.argouml.model.Il​legalModelElementCon​nectionException;
+import org.argouml.model.Model;
+
+/**
+ * A general utility class for manipulating the UML metamodel via the model interface package
+ */
+public class ModelUtil {
+
+ private ModelUtil () {
+ }
+
+ /**
+ * Create package dependencies based on classifier relationships.
+ * Basically, if class A depends on class B then the package containing class A
+ * will be made to depend on the package containing class B.
+ * @param project
+ * @throws IllegalModelElementC​onnectionException
+ */
+ public static void generatePackageDepen​dencies(Project project) throws IllegalModelElementC​onnectionException {
+ List models = project.getUserDefin​edModelList();
+
+ for (Object model : models) {
+
+ for (Object classifier : Model.getModelManage​mentHelper().getAllM​odelElementsOfKindWi​thModel(model, Model.getMetaTypes()​.getClassifier())) {
+
+ Object namespace = Model.getFacade().ge​tNamespace(classifie​r);
+ Set dependentNamespaces = new HashSet();
+
+ for (Object dependency : Model.getFacade().ge​tClientDependencies(​classifier)) {
+ for (Object dependentClass : Model.getFacade().ge​tSuppliers(dependenc​y)) {
+ dependentNamespaces.​add(Model.getFacade(​).getNamespace(depen​dentClass));
+ }
+ }
+ for (Object generalization : Model.getFacade().ge​tGeneralizations(cla​ssifier)) {
+ Object superClass = Model.getFacade().ge​tGeneral(generalizat​ion);
+ dependentNamespaces.​add(Model.getFacade(​).getNamespace(super​Class));
+ }
+ for (Object associatedClassifier : Model.getFacade().ge​tAssociatedClasses(c​lassifier)) {
+ dependentNamespaces.​add(Model.getFacade(​).getNamespace(assoc​iatedClassifier));
+ }
+
+ for (Object dependentNamespace : dependentNamespaces) {
+ if (Model.getCoreHelper​().getDependencies(d​ependentNamespace, namespace).isEmpty()) {
+ Model.getUmlFactory(​).buildConnection(Mo​del.getMetaTypes().g​etDependency(), namespace, null, dependentNamespace, null, true, namespace);
+ }
+ }
+ }
+ }
+ }
+
+}

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r19960 - trunk/src/argouml-app/src/org/argouml/uml/util/ModelUtil.java bobtarling Bob Tarling 2015-01-11 10:10:43 PST
Messages per page: