Ignore:
Timestamp:
03/14/10 09:12:55 (2 years ago)
Author:
sys
Message:

Copy / move by id.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Jav_Wsp/src/com/scenari/m/bdp/item/fs/XItemCache.java

    r14479 r15098  
    4444import java.util.Date; 
    4545import java.util.Iterator; 
     46import java.util.Map; 
    4647 
    4748import org.xml.sax.Attributes; 
     
    149150                        if (pItemPtd != null) { 
    150151                                //Mutualisation des instances d'objets en mémoire 
    151                                 fRefUriPtd = pItemPtd.getUri(); 
     152                                if (fRefUriPtd.equals(pItemPtd.getUri())) { 
     153                                        fRefUriPtd = pItemPtd.getUri(); 
     154                                } else if (fRefUriPtd.equals(pItemPtd.getId())) { 
     155                                        fRefUriPtd = pItemPtd.getId(); 
     156                                } 
    152157                        } 
    153158                } 
     
    348353        protected XLink fFirstPointer = null; 
    349354 
    350         /** Liste chainée d'items en cache (champ géré par la classe XSpace). */ 
    351         protected XItemCache fNextItem = null; 
    352  
    353355        /** Uri de cet item. */ 
    354356        protected String fUri = IHItem.URI_NULL; 
     357 
     358        /** Id de cet item. */ 
     359        protected String fId = null; 
    355360 
    356361        /** ItemType de cette item. */ 
     
    398403        public String getUri() { 
    399404                return fUri; 
     405        } 
     406 
     407        public String getId() { 
     408                return fId; 
    400409        } 
    401410 
     
    645654                } 
    646655                ISrcNode vSrc = vDatas.getWspSrcNodeItem().getSubSrcNode(); 
     656                //Refresh de l'ID. 
     657                this.setId(vSrc); 
    647658                if (fStatusItem == IHItem.STATUS_UNKNOWN) { 
    648659                        xLoadItemFromSource(false, vSrc, vSrc.getLastModifWithChildren(), IContextBdp.CLIENTID_NONE); 
     
    834845                XItemCacheData vItemData = getDatas(); 
    835846                vItemData.fLastRefresh = System.currentTimeMillis(); 
    836                 fMemLastModif = vItemData.getWspSrcNodeItem().getSubSrcNode().getLastModifWithChildren(); 
     847                ISrcNode vSubSrcNode = vItemData.getWspSrcNodeItem().getSubSrcNode(); 
     848                fMemLastModif = vSubSrcNode.getLastModifWithChildren(); 
     849        } 
     850 
     851        /** 
     852         * Affectation / mise à jour de l'index par ID. 
     853         */ 
     854        public void setId(ISrcNode pSrcNode) throws Exception { 
     855                assert Thread.holdsLock(getWsp()); 
     856                String vNewId = SrcFeatureIds.getSrcId(pSrcNode); 
     857                if (fId == null && vNewId == null) return; 
     858                if (fId == null && vNewId != null) { 
     859                        getWsp().fItemsById.put(vNewId, this); 
     860                } else if (vNewId == null) { 
     861                        getWsp().fItemsById.remove(fId); 
     862                } else if (vNewId.equals(fId)) { 
     863                        return; 
     864                } else { 
     865                        Map<String, XItemCache> vMap = getWsp().fItemsById; 
     866                        vMap.remove(fId); 
     867                        vMap.put(vNewId, this); 
     868                } 
     869                fId = vNewId; 
    837870        } 
    838871 
     
    924957                        } 
    925958                } 
    926                 xRecalStatusItem(); 
     959                xComputeItemStatus(); 
    927960        } 
    928961 
     
    9971030         * Recalcul du status global de l'item après validation des liens notemment. 
    9981031         */ 
    999         protected void xRecalStatusItem() { 
     1032        protected void xComputeItemStatus() { 
    10001033                //Si les liens n'ont pas été calculés on ne fait rien. 
    10011034                boolean fHasWarning = (fFirstContentProblem != null); 
     
    10471080        public void xUnlinkChilds() throws Exception { 
    10481081                if (fAttrs == null || fStatusItem == STATUS_INTERNAL_NOTLINKED) { return; } 
    1049                 if (fAttrs != null) { 
    1050                         for (int i = 0; i < fAttrs.length; i = i + 4) { 
    1051                                 if (fAttrs[i] == IHAttr.TYPE_REF || fAttrs[i] == IHAttr.TYPE_LINK) { 
    1052                                         XLink vLink = (XLink) fAttrs[i + 3]; 
    1053                                         XItemCache vPtd = vLink.fPtd; 
    1054                                         if (vPtd == null) { 
    1055                                                 continue; 
     1082                for (int i = 0; i < fAttrs.length; i = i + 4) { 
     1083                        if (fAttrs[i] == IHAttr.TYPE_REF || fAttrs[i] == IHAttr.TYPE_LINK) { 
     1084                                XLink vLink = (XLink) fAttrs[i + 3]; 
     1085                                XItemCache vPtd = vLink.fPtd; 
     1086                                if (vPtd == null) { 
     1087                                        continue; 
     1088                                } 
     1089                                XLink vPrec = null; 
     1090                                XLink vCurr = vPtd.fFirstPointer; 
     1091                                while (vCurr != null) { 
     1092                                        //On recherche ce pointeur dans le Ptd 
     1093                                        if (vCurr == vLink) { 
     1094                                                //Trouvé 
     1095                                                if (vPrec != null) { 
     1096                                                        vPrec.fNextPointer = vCurr.fNextPointer; 
     1097                                                } else { 
     1098                                                        vPtd.fFirstPointer = vCurr.fNextPointer; 
     1099                                                } 
     1100                                                break; 
    10561101                                        } 
    1057                                         XLink vPrec = null; 
    1058                                         XLink vCurr = vPtd.fFirstPointer; 
    1059                                         while (vCurr != null) { 
    1060                                                 //On recherche ce pointeur dans le Ptd 
    1061                                                 if (vCurr == vLink) { 
    1062                                                         //Trouvé 
    1063                                                         if (vPrec != null) { 
    1064                                                                 vPrec.fNextPointer = vCurr.fNextPointer; 
    1065                                                         } else { 
    1066                                                                 vPtd.fFirstPointer = vCurr.fNextPointer; 
    1067                                                         } 
    1068                                                         break; 
    1069                                                 } 
    1070                                                 vPrec = vCurr; 
    1071                                                 vCurr = vCurr.fNextPointer; 
    1072                                         } 
     1102                                        vPrec = vCurr; 
     1103                                        vCurr = vCurr.fNextPointer; 
    10731104                                } 
    10741105                        } 
     
    11061137                                //On recaclule le satus de l'item pointeur si il a déjà été linké (sinon perte de ref lors de XSpace.xLinkAllItems). 
    11071138                                if (vPointer.fItem.fStatusItem != STATUS_INTERNAL_NOTLINKED) { 
    1108                                         vPointer.fItem.xRecalStatusItem(); 
     1139                                        vPointer.fItem.xComputeItemStatus(); 
    11091140                                        if (pFireEventUpdated && vOldStatus != vPointer.fItem.fStatusItem) getWsp().xFireEventItemStatus(vPointer.fItem); 
    11101141                                } 
Note: See TracChangeset for help on using the changeset viewer.