Overview Schemas Index

ASSEMBLY_FEATURE_RELATIONSHIP_SCHEMA (jsdai.SAssembly_feature_relationship_schema)


FUNCTION find_assembly_root
          (constituent : SET [0:?] OF product_definition) : SET [0:?] OF product_definition;

LOCAL
  local_relation: SET  OF  assembly_component_usage := [];
  local_relation2: BAG OF  assembly_component_usage := [];
  local_parent: SET  OF  product_definition := [];
  root : SET  OF  product_definition;
  i : INTEGER  := 0;
  j : INTEGER := 0;
END_LOCAL;

-- Is constituent root ? --
IF ((SIZEOF (constituent) = 1) AND  assembly_root (constituent[1]))
  THEN  RETURN  ([constituent [1]]);
-- ERROR constituent is vacant --
  ELSE  IF  (SIZEOF (constituent) = 0 ) THEN  RETURN  ([]);

-- extraction OF  related assembly_component_relationships --
    ELSE
      REPEAT  j:= 1 TO  HIINDEX(constituent);
        local_relation2 := local_relation2 + QUERY(pdr <* USEDIN (constituent[j], 
                    'PRODUCT_STRUCTURE_SCHEMA.PRODUCT_DEFINITION_RELATIONSHIP.' 
                    +'RELATED_PRODUCT_DEFINITION') |
                   'PRODUCT_STRUCTURE_SCHEMA.ASSEMBLY_COMPONENT_USAGE' IN
                   TYPEOF(pdr));
      END_REPEAT;
      local_relation := bag_to_set (local_relation2);
      IF  (SIZEOF(local_relation) = 0) THEN
        IF  (SIZEOF(constituent) = 1) THEN  RETURN  ([constituent[1]]);
          ELSE  RETURN  ([]);
        END_IF;
      ELSE
-- extraction OF  a SET OF parents --
        REPEAT  i :=1 TO  HIINDEX(local_relation);
          REPEAT j := 1 TO HIINDEX(constituent);
          IF  (local_relation[i].relating_product_definition <> 
              constituent[j]) THEN
            local_parent := local_parent + 
                            local_relation[i].relating_product_definition;
          END_IF;
          END_REPEAT;
        END_REPEAT;
        IF  ((SIZEOF (local_parent) = 1 ) AND 
             assembly_root (local_parent[1])) 
          THEN  RETURN  ([local_parent[1]]); 
          ELSE  IF  (SIZEOF (local_parent) = 0) THEN  RETURN  ([]);
-- try again --
            ELSE  
              root := find_assembly_root(local_parent);
              IF  (SIZEOF (root) =1) THEN  RETURN  (root);
                ELSE IF (SIZEOF (root) = 0) THEN RETURN ([]);
                END_IF;
              END_IF;
          END_IF;
        END_IF;
      END_IF;
  END_IF;
END_IF;
RETURN ([]);

END_FUNCTION; -- find_assembly_root

public class FFind_assembly_root
          public static Value run(SdaiContext _context, Value constituent)