Exemplo n.º 1
0
  /** @return set of ids of classes this class depends on */
  protected TreeSet<String> supplierIds() {

    // Only retrieve/compute supplierIds once
    // Cache the results for subsequent use
    if (supplierIds == null) {

      // Prepare set to return
      supplierIds = new TreeSet<String>();
      // Ask EA for the connectors attached to the package object and loop
      // over the connectors returned
      // Only compute them once for the whole class
      if (!connectorsAccessed) {
        conns = eaClassElement.GetConnectors();
        connectorsAccessed = true;
      }
      // Ensure that there are connectors before continuing
      if (conns != null) {
        for (Connector conn : conns) {
          // Single out dependency connectors
          String type = conn.GetType();
          if (type.equals("Dependency")) {
            // From the dependency grab the id of the supplier
            int suppId = conn.GetSupplierID();
            String suppIdS = Integer.toString(suppId);
            // Since all connectors are delivered from both objects
            // at the
            // connector ends, we have to make sure it is not
            // accidently us,
            // which we found.
            if (suppId == eaClassId) continue;
            // Now, this is an element id, not a package id. So we
            // have to
            // identify the package, which owns the element
            // addressed.
            ClassInfoEA suppClass = (ClassInfoEA) document.fClassById.get(suppIdS);

            if (suppClass != null) {
              // From this only the id is required
              String suppPackId = suppClass.id();
              if (suppPackId != null) supplierIds.add(suppPackId);

            } else {
              // package of supplier class has not been loaded,
              // dismiss the supplier
            }
          }
        }
      }
    }
    return supplierIds;
  } // supplierIds()
Exemplo n.º 2
0
  // Establish all class associations. This is an auxiliary initializing
  // method, which retrieves all associations (EA: Connectors) known to
  // the class and creates wrapper objects for them in case they have not
  // already been encountered from the other class end. All created
  // association objects are registered. Object creation established the
  // necessary links to source and target objects and properties.
  // Note that invocation of this method requires that all classes of the
  // model are already cached.
  public void establishAssociations() {
    // Find out about associations connected to the class
    // Only do this once; cache the results for subsequent use
    if (!connectorsAccessed) {
      conns = eaClassElement.GetConnectors();
      connectorsAccessed = true;
    }

    // check that this class has connectors
    if (conns != null) {

      // Enumerate connectors
      boolean known;
      int id;
      String connid;

      for (Connector conn : conns) {

        // only process "Association" connectors
        String type = conn.GetType();
        if (!type.equalsIgnoreCase("Association") && !type.equalsIgnoreCase("Aggregation")) {
          continue;
        }
        // First find out whether the association has already been
        // processed from its other end. If so, discard.
        id = conn.GetConnectorID();
        connid = new Integer(id).toString();
        known = document.fAssociationById.containsKey(connid);
        if (known) continue;
        // First encounter: Create AssociationInfo wrapper and
        // properties linkage.
        AssociationInfoEA ai = new AssociationInfoEA(document, conn, id);
        // Register with global associations map, if relevant class
        // association
        if (ai.relevant) document.fAssociationById.put(connid, ai);
      }
    }
  }
Exemplo n.º 3
0
  // Establish class derivation hierarchy. This auxiliary initializing
  // method sets the base class relation ship obtained from the model and
  // also enters this class as subclass of all its base classes.
  // Note that invocation of this method requires that all classes in
  // the model are already cached.
  // Note: ISO19107 makes use of realization instead of generalization in some
  // cases to inherit from interfaces. Therefore realization of interfaces is
  // also considered a base class relationship as a default unless overruled
  // by
  // a parameter.
  public void establishClassDerivationHierarchy() {
    // Find out about all connectors attached to the class
    // Only do this once; cache the results for subsequent use
    if (!connectorsAccessed) {
      conns = eaClassElement.GetConnectors();
      connectorsAccessed = true;
    }

    // check that this class has connectors
    if (conns != null) {

      // Enumerate connectors selecting those where this class is the
      // client,
      // from these select "Generalization" and "Realisation". Retrieve
      // the
      // supplier class wrappers. For "Realisation" type suppliers also
      // make
      // sure the class is an interface. The classes found are registered
      // as
      // base classes. In the base classes register this class as
      // subclass.
      int nbcl = 0;
      int clientid, bclid, cat;
      String conntype;
      boolean gen, rea;
      for (Connector conn : conns) {

        // Skip all other connector types
        conntype = conn.GetType();
        gen = conntype.equals("Generalization");
        rea = conntype.equals("Realisation");

        // this.realization is determined from configuration parameters
        // if it is not null then it is false
        if (this.realization != null && !this.realization.booleanValue()) rea = false;
        if (!gen && !rea) continue;

        // Make sure we are the client of this connector
        clientid = conn.GetClientID();
        if (clientid != this.eaClassId) continue;

        // Find out about the id of the base class (=supplier)
        bclid = conn.GetSupplierID();
        // From this determine the ClassInfo wrapper object
        ClassInfoEA baseCI = document.fClassById.get(String.valueOf(bclid));
        // If such an object exists establish it as base class.
        if (baseCI != null) {
          // If we know this via a Realization we additionally check
          // we are seeing an interface.
          if (rea) {
            cat = baseCI.category();
            if (cat != Options.MIXIN) continue;
          }
          // Establish as base class. Since most classes indeed
          // possess
          // at most one base class, this case will be treated
          // somewhat
          // storage-optimized.
          if (++nbcl == 1) {
            baseclassInfo = baseCI;
          } else {
            if (baseclassInfoSet == null) {
              baseclassInfoSet = new TreeSet<ClassInfoEA>();
              baseclassInfoSet.add(baseclassInfo);
              baseclassInfo = null;
            }
            baseclassInfoSet.add(baseCI);
          }
          // Register with the subclasses of the base class.
          baseCI.subclassInfoSet.add(this);
        }
      }
    }
  } // establishClassDerivationHierarchy()