示例#1
0
        public virtual VString copyResource(JDFResource r, JDFResource.EnumSpawnStatus copyStatus, VJDFAttributeMap vParts, string spawnID)
        {
            VString ss = getResIds();
            VString v  = new VString();

            // r is not yet here copy r
            if (!ss.Contains(r.getID()))
            {
                JDFResource rNew = null;
                // if spawning, fix stati and locks
                if (copyStatus == JDFResource.EnumSpawnStatus.SpawnedRO)
                {
                    // copy the complete resource as RO - no need to reduce
                    // partitions
                    r.appendSpawnIDs(spawnID);
                    rNew = (JDFResource)copyElement(r, null);
                    rNew.setLocked(true);
                    r.setSpawnStatus(copyStatus);
                }
                else if (copyStatus == JDFResource.EnumSpawnStatus.SpawnedRW)
                {
                    if (vParts.Count == 0)
                    { // just copy the whole thing - no parts specified
                        r.appendSpawnIDs(spawnID);
                        rNew = (JDFResource)copyElement(r, null);
                        r.setSpawnStatus(copyStatus);
                    }
                    else
                    {
                        rNew = (JDFResource)copyElement(r, null);
                        rNew.reducePartitions(vParts);
                        // reduce any unneeded leaves
                        // loop over all part maps to get best matching resource
                        for (int i = 0; i < vParts.Count; i++)
                        {
                            JDFResource pLeaf    = r.getPartition(vParts[i], null);
                            JDFResource pNewLeaf = rNew.getPartition(vParts[i], null);
                            if (pLeaf != null)
                            {
                                pLeaf.setSpawnStatus(copyStatus);
                                pLeaf.appendSpawnIDs(spawnID);
                            }
                            if (pNewLeaf != null)
                            {
                                pNewLeaf.appendSpawnIDs(spawnID);
                            }
                        }
                    }
                }

                if (rNew != null)
                {
                    v.Add(rNew.getID());
                }
            }

            VString vs = r.getHRefs(null, false, true);

            // add recursively copied resources
            for (int i = 0; i < vs.Count; i++)
            {
                string id = vs[i];
                // the referenced resource is in this pool - continue
                if (ss.Contains(id))
                {
                    continue;
                }

                // the referenced resource has already been merged in - continue
                if (v.Contains(id))
                {
                    continue;
                }

                JDFResource next = (JDFResource)getDocRoot().getTarget(id, AttributeName.ID);
                if (next == null)
                {
                    // 071101 RP added r is by definition in the original document
                    // which also contains the rrefs elements
                    next = (JDFResource)r.getDocRoot().getTarget(id, AttributeName.ID);
                    // and now all those interlinked resources
                    VString vv = copyResource(next, copyStatus, vParts, spawnID);
                    v.AddRange(vv);
                }
            }

            return(v);
        }