Esempio n. 1
0
 /**
  * Checks if the dependence relation is antisymmetric.
  *
  * @return A boolean value.
  * @throws PublicationException when something went wrong.
  */
 protected boolean isAntisymmetric() throws PublicationException {
   Resource[] resources = getResources();
   boolean isAntisymmetric = true;
   for (int i = 0; i < resources.length; i++) {
     PublicationWrapper publication = resources[i].getPublicationWrapper();
     SiteManager manager = publication.getSiteManager();
     for (int j = i + 1; j < resources.length; j++) {
       if (manager.requires(resources[i], resources[j])
           && manager.requires(resources[j], resources[i])
           && !(resources[i] == resources[j])) {
         isAntisymmetric = false;
       }
     }
   }
   return isAntisymmetric;
 }
Esempio n. 2
0
  /**
   * This method throws an exception when a loop in the dependency graph occurs.
   *
   * @see
   *     org.apache.lenya.cms.publication.DocumentSet#add(org.apache.lenya.cms.publication.Document)
   */
  public void add(Resource resource) throws PublicationException {

    if (resources == null) {
      resources = new ArrayList();
    }

    PublicationWrapper publication = resource.getPublicationWrapper();
    SiteManager manager = publication.getSiteManager();

    if (manager == null) {
      throw new PublicationException("The site manager must not be null!");
    }

    int i = 0;

    while (i < resources.size() && manager.requires(resource, (Resource) resources.get(i))) {
      i++;
    }

    resources.add(i, resource);

    if (!check()) {
      resources.remove(i);
      throw new PublicationException("The dependence relation is not a strict partial order!");
    }
  }
Esempio n. 3
0
 /**
  * Checks if the dependence relation is transitive.
  *
  * @return A boolean value.
  * @throws PublicationException when something went wrong.
  */
 protected boolean isTransitive() throws PublicationException {
   Resource[] resources = getResources();
   boolean isTransitive = true;
   for (int i = 0; i < resources.length; i++) {
     PublicationWrapper publication = resources[i].getPublicationWrapper();
     SiteManager manager = publication.getSiteManager();
     for (int j = i + 1; j < resources.length; j++) {
       for (int k = j + 1; k < resources.length; k++) {
         if (manager.requires(resources[i], resources[j])
             && manager.requires(resources[j], resources[k])
             && !manager.requires(resources[i], resources[k])) {
           isTransitive = false;
         }
       }
     }
   }
   return isTransitive;
 }
Esempio n. 4
0
 /**
  * Checks if the dependence relation is irreflexive.
  *
  * @return
  * @throws PublicationException
  */
 protected boolean isIrreflexive() throws PublicationException {
   Resource[] resources = getResources();
   boolean isIrreflexive = true;
   for (int i = 0; i < resources.length; i++) {
     PublicationWrapper publication = resources[i].getPublicationWrapper();
     SiteManager manager = publication.getSiteManager();
     if (manager.requires(resources[i], resources[i])) {
       isIrreflexive = false;
     }
   }
   return isIrreflexive;
 }