示例#1
0
 private static IEntity createPattern(IEntity child) {
   IEntity pattern = EntityUtils.clone(child);
   EntityDescriptor<?> ed = pattern.wGetEntityDescriptor();
   for (FeatureDescriptor fd : ed.getEntityFeatureDescriptors()) {
     if (!name.equals(fd))
       pattern.wSet(
           fd, CommonsEntityAdapterFactory.createVariable(fd.getEntityDescriptor(), fd.getName()));
   }
   return pattern;
 }
 protected boolean embedChildrenInComposite(EntityDescriptor<?> ed) {
   switch (ed.getEntityKind()) {
     case SIMPLE:
       for (FeatureDescriptor ced : ed.getEntityFeatureDescriptors())
         if (!embedChildrenInSimple(ced.getEntityDescriptor())) return false;
     case DATA:
       return true;
     case COMPOSITE:
     default:
       return false;
   }
 }
示例#3
0
  public static IEntity cloneArtifact(IEntity artifact, IEntity appendChild) {
    IEntityFactory ef = GenericEntityFactory.instance(RegistryConfigurations.RESOLVER);
    EntityDescriptor<?> ed = artifact.wGetEntityDescriptor();

    IEntity newArtifact = ef.create(ed);
    for (FeatureDescriptor fd : ed.getEntityFeatureDescriptors()) {
      if (artifacts.equals(fd) || projects.equals(fd)) {
        IEntity composite = newArtifact.wGet(fd);
        if (appendChild != null) composite.wAdd(appendChild);
        else composite.wResolveWith(fd.getEntityDescriptor());
      } else newArtifact.wSet(fd, EntityUtils.clone(artifact.wGet(fd)));
    }
    return newArtifact;
  }
 public boolean embedChildren(EntityDescriptor<?> ed) {
   switch (ed.getEntityKind()) {
     case SIMPLE:
       for (FeatureDescriptor ced : ed.getEntityFeatureDescriptors())
         if (!embedChildrenInSimple(ced.getEntityDescriptor())) return false;
       return true;
     case COMPOSITE:
       EntityDescriptor<?> ced = ed.getEntityDescriptor(0);
       return !ced.isPolymorphic() && embedChildrenInComposite(ced);
     case DATA:
       return true;
     default:
       return false;
   }
 }