Changeset 19585


Ignore:
Timestamp:
01/30/12 20:51:52 (4 months ago)
Author:
sys
Message:

Ajout possbiilité de configurer le wspDef du wspProvider à partir du .wspmeta du modèle documentaire. Premier paramètre géré : externalItemAllowed

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Jav_AppBuilder/src/com/scenari/m/builder/gen/HModelGenerator.java

    r19374 r19585  
    21182118                                                        vWspDefToSelect = vWspDef; 
    21192119                                                        //Mise à jour wspMeta. 
    2120                                                         vWspDefToSelect.writeWspMeta(vBuffWspMeta.getInputStream(false)); 
     2120                                                        vWspDefToSelect.writeWspMeta(vBuffWspMeta.getInputStream(false), vReposTest.parseWspType(vBuffWspMeta.getInputStream(false)).fillWspDefProperties(null)); 
    21212121                                                        break; 
    21222122                                                } 
  • trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/lib/primitive/ValueBoolean.java

    r18986 r19585  
    4848public class ValueBoolean extends ValueAbstract<Boolean> { 
    4949 
     50        public static final ValueBoolean TRUE = new ValueBoolean(true); 
     51 
     52        public static final ValueBoolean FALSE = new ValueBoolean(false); 
     53 
    5054        protected boolean fValue; 
    5155 
  • trunk/Jav_Wsp/src/com/scenari/m/bdp/item/fs/WspHandler.java

    r19181 r19585  
    658658                        vWriter.close(); 
    659659                } 
    660                 fWspDefinition.writeWspMeta(vStream.getInputStream(true)); 
     660                //Mise à jour du modèle 
     661                fWspDefinition.writeWspMeta(vStream.getInputStream(true), pWspType.fillWspDefProperties(null)); 
     662                // 
    661663                fNeedSaveWspType = false; 
    662664        } 
  • trunk/Jav_Wsp/src/com/scenari/m/bdp/item/fs/WspHandlerMaster.java

    r18986 r19585  
    112112                } 
    113113 
    114                 public void writeWspMeta(InputStream pNewWspMeta) throws Exception { 
     114                public void writeWspMeta(InputStream pWspMetaStream, Map<String, Object> pWspMetaProps) throws Exception { 
    115115                } 
    116116 
  • trunk/Jav_Wsp/src/eu/scenari/wsp/provider/IWspDefinition.java

    r18986 r19585  
    133133 
    134134        /** 
    135          * <p>Modification des caractéristiques de l'atelier : mises à jour automatiques,  
    136          * changements d'options...</p> 
     135         * <p>Modification du modèle documentaire associé à cet atelier.</p> 
     136         *  
     137         * @param pWspMetaStream Flux du wspMeta. 
     138         * @param pWspMetaProps Propriétés extraites de ce wspMeta destinées à configurer cet atelier. 
    137139         *  
    138140         */ 
    139         public void writeWspMeta(InputStream pNewWspMeta) throws Exception; 
     141        public void writeWspMeta(InputStream pWspMetaStream, Map<String, Object> pWspMetaProps) throws Exception; 
    140142 
    141143        /** 
  • trunk/Jav_Wsp/src/eu/scenari/wsp/repos/wsptype/WspType.java

    r19084 r19585  
    4040 
    4141import java.util.ArrayList; 
     42import java.util.Collections; 
     43import java.util.HashMap; 
    4244import java.util.List; 
     45import java.util.Map; 
    4346 
    4447import com.scenari.m.bdp.item.fs.XSsOverlay; 
     
    4750 
    4851import eu.scenari.commons.initapp.ScVersion; 
     52import eu.scenari.wsp.provider.IWspDefinition; 
    4953import eu.scenari.wsp.res.IRes; 
    5054import eu.scenari.wsp.res.IResMgr; 
     
    6367                 * Uri de l'espace système. 
    6468                 */ 
    65                 public String fSpace = null; 
     69                public String fSpace; 
    6670 
    6771                /** 
    6872                 * Clé de la ressource système du {@link IResMgr}. 
    6973                 */ 
    70                 public IRes fRes = null; 
     74                public IRes fRes; 
    7175 
    7276                /** 
    7377                 * Source de l'espace système (si l'updtateMgr et fUpdateKey non utilisés pour cet espace système). 
    7478                 */ 
    75                 public ISrcSystem fSourceSystem = null; 
     79                public ISrcSystem fSourceSystem; 
    7680 
    7781                /** 
    7882                 * Extrait xml de définition de fSource. 
    7983                 */ 
    80                 public String fSourceXmlDef = null; 
     84                public String fSourceXmlDef; 
    8185 
    8286                /** 
     
    8589                 * niveau de version spécifié (minor, medium, major). 
    8690                 */ 
    87                 public String fLocalAutoUpdate = null; 
     91                public String fLocalAutoUpdate; 
    8892 
    8993                /** 
     
    154158 
    155159        public static class EditionSheet { 
    156                 public String fPack = null; 
    157  
    158                 public String fBrickSelector = null; 
    159  
    160                 public String fBrickProvider = null; 
     160                public String fPack; 
     161 
     162                public String fBrickSelector; 
     163 
     164                public String fBrickProvider; 
    161165 
    162166                /** 
     
    172176        } 
    173177 
    174         protected IResMgr fResMgr = null; 
    175  
    176         protected String fDefaultCode = null; 
    177  
    178         protected String fUri = null; 
    179  
    180         protected String fKey = null; 
    181  
    182         protected String fLang = null; 
    183  
    184         protected String fTitle = null; 
    185  
    186         protected String fDescription = null; 
    187  
    188         protected IRes fWspUpdateRes = null; 
     178        protected IResMgr fResMgr; 
     179 
     180        protected String fDefaultCode; 
     181 
     182        protected String fUri; 
     183 
     184        protected String fKey; 
     185 
     186        protected String fLang; 
     187 
     188        protected String fTitle; 
     189 
     190        protected String fDescription; 
     191 
     192        protected IRes fWspUpdateRes; 
    189193 
    190194        protected ScVersion fWspVersion = ScVersion.UNDEFINED_VERSION; 
    191195 
    192         protected String fConfig = null; 
     196        protected String fConfig; 
    193197 
    194198        /** 
     
    197201         * spécifié (minor, medium, major). 
    198202         */ 
    199         protected String fLocalAutoUpdate = null; 
     203        protected String fLocalAutoUpdate; 
    200204 
    201205        /** 
    202206         * Root de l'atelier surchargé dans le wspMeta de l'atelier. 
    203207         */ 
    204         protected ISrcSystem fContentRootSrcSystem = null; 
     208        protected ISrcSystem fContentRootSrcSystem; 
    205209 
    206210        /** Espaces systèmes. */ 
     
    211215 
    212216        /** Surcharges des SS. */ 
    213         protected List<XSsOverlay> fOverlaysSs = null; 
     217        protected List<XSsOverlay> fOverlaysSs; 
    214218 
    215219        /** Services. */ 
    216         protected List<IWspServiceInternal> fWspServices = null; 
     220        protected List<IWspServiceInternal> fWspServices; 
     221 
     222        /** Propriétés destinées au {@link IWspDefinition}. */ 
     223        protected Map<String, Object> fWspDefProperties; 
    217224 
    218225        /** Options de ce WspType. */ 
    219         protected List<WspOption> fOptions = null; 
     226        protected List<WspOption> fOptions; 
    220227 
    221228        public WspType(IResMgr pResMgr) { 
     
    275282                        for (IWspServiceInternal vWspService : fWspServices) { 
    276283                                vWspService.writeXml(pWriter); 
     284                        } 
     285                } 
     286 
     287                //WspDefProperties 
     288                if (fWspDefProperties != null) { 
     289                        for (Map.Entry<String, Object> vEntry : fWspDefProperties.entrySet()) { 
     290                                pWriter.writeStartTag("wspDefProperties"); 
     291                                pWriter.writeAttribute("key", vEntry.getKey()); 
     292                                pWriter.writeAttribute("value", vEntry.getValue().toString()); 
     293                                pWriter.writeEndEmptyTag(); 
    277294                        } 
    278295                } 
     
    380397        } 
    381398 
     399        public Map<String, Object> fillWspDefProperties(Map<String, Object> pProps) { 
     400                if (pProps == null) { 
     401                        if (fOptions == null) { 
     402                                //Cas simple : pas d'options 
     403                                return (fWspDefProperties == null) ? Collections.EMPTY_MAP : fWspDefProperties; 
     404                        } 
     405                        //Cas plus élaboré : on merge plusieurs options 
     406                        pProps = new HashMap<String, Object>(); 
     407                } 
     408                if (fWspDefProperties != null) pProps.putAll(fWspDefProperties); 
     409                if (fOptions != null) { 
     410                        for (WspOption vWspOption : fOptions) { 
     411                                vWspOption.fillWspDefProperties(pProps); 
     412                        } 
     413                } 
     414                return pProps; 
     415        } 
     416 
    382417        public IResMgr getResMgr() { 
    383418                return fResMgr; 
  • trunk/Jav_Wsp/src/eu/scenari/wsp/repos/wsptype/WspTypeContentHandler.java

    r19084 r19585  
    4040 
    4141import java.util.ArrayList; 
     42import java.util.HashMap; 
    4243import java.util.List; 
    4344import java.util.Map; 
     
    243244                        vEditionSheet.fBrickSelector = pAttributes.getValue("brickSelector"); 
    244245                        vEditionSheet.fBrickProvider = pAttributes.getValue("brickProvider"); 
     246                } else if (pLocalName == "wspDefProperties") { 
     247                        String vKey = pAttributes.getValue("key"); 
     248                        String vValue = pAttributes.getValue("value"); 
     249                        if (fWspType.fWspDefProperties == null) fWspType.fWspDefProperties = new HashMap<String, Object>(); 
     250                        fWspType.fWspDefProperties.put(vKey, vValue); 
    245251                } else if (pLocalName == "wspOption") { 
    246252                        if (fWspType != null) { 
  • trunk/Jav_Wsp/src/eu/scenari/wsp/service/importer/SvcImportDialog.java

    r19163 r19585  
    255255                                } else { 
    256256                                        if (fParamUpdateWspMeta) { 
    257                                                 fWspTarget.getWspDefinition().writeWspMeta(new InputCloseEntry(vZipIn)); 
     257                                                //TODO A revoir : à parser, à évaluer si le modèle existe... 
     258                                                //fWspTarget.getWspDefinition().writeWspMeta(new InputCloseEntry(vZipIn), null); 
    258259                                        } else { 
    259260                                                while (vZipIn.read() >= 0) { 
  • trunk/Jav_WspFs/src/eu/scenari/wspfs/FsWspDefinition.java

    r18986 r19585  
    148148        } 
    149149 
    150         public void writeWspMeta(InputStream pNewWspMeta) throws Exception { 
     150        public void writeWspMeta(InputStream pWspMetaStream, Map<String, Object> pWspMetaProps) throws Exception { 
    151151                OutputStream vOut = fWspProvider.buildWspMetaSrc(this).newOutputStream(false); 
    152152                try { 
    153                         StreamUtils.write(pNewWspMeta, vOut); 
     153                        StreamUtils.write(pWspMetaStream, vOut); 
    154154                } finally { 
    155155                        vOut.close(); 
  • trunk/Jav_WspFs/src/eu/scenari/wspfs/FsWspProvider.java

    r18986 r19585  
    507507                        if (vWspDef.fSrcRootGen == null) vWspDef.fSrcRootGen = buildDefaultWspRootGen(pCode); 
    508508 
    509                         vWspDef.writeWspMeta(pXmlWspType); 
     509                        vWspDef.writeWspMeta(pXmlWspType, null); 
    510510 
    511511                        appendWspDef(vWspDef); 
  • trunk/Jav_WspOdb/src/eu/scenari/wspodb/struct/lib/ValueWsp.java

    r19070 r19585  
    5050import eu.scenari.orient.recordstruct.impl.StructReader; 
    5151import eu.scenari.orient.recordstruct.lib.base.ValueBlob; 
     52import eu.scenari.orient.recordstruct.lib.base.ValueDictionary; 
    5253import eu.scenari.orient.recordstruct.struct.ConversionException; 
    5354import eu.scenari.orient.recordstruct.struct.Struct; 
     
    6263        protected static final byte VERS_SER_WSP = Byte.MIN_VALUE; 
    6364 
     65        protected static final byte VERS_SER_WSP_1 = Byte.MIN_VALUE + 1; 
     66 
    6467        protected String fTitle = ""; 
    6568 
     
    6972 
    7073        protected IValueStamp fStamp; 
     74 
     75        protected ValueDictionary<IValue<?>> fProperties; 
    7176 
    7277        /** Ne pas utiliser. Usage interne cf {@link Struct}. */ 
     
    108113                unmarshall(); 
    109114                return fWspMeta; 
     115        } 
     116 
     117        public ValueDictionary<IValue<?>> getProperties() { 
     118                unmarshall(); 
     119                return fProperties; 
     120        } 
     121 
     122        public ValueDictionary<IValue<?>> getOrCreateProperties() { 
     123                unmarshall(); 
     124                if (fProperties == null) fProperties = new ValueDictionary<IValue<?>>(this); 
     125                return fProperties; 
    110126        } 
    111127 
     
    167183        protected void writeToStream(IStructWriter pWriter) { 
    168184                pWriter.startValue(getStruct(), IStruct.DYNAMICLENGTH_MAX_FOR_2_BYTES); 
    169                 pWriter.addAsByte(VERS_SER_WSP); 
     185                pWriter.addAsByte(VERS_SER_WSP_1); 
    170186                pWriter.addAsString(getTitle()); 
    171187                pWriter.addAsString(getDescription()); 
    172188                fWspMeta.writeValue(pWriter); 
    173189                pWriter.addAsValueOrNull(fStamp); 
     190                pWriter.addAsValueOrNull(fProperties == null || fProperties.isEmpty() ? null : fProperties); 
    174191                pWriter.endValue(getStruct()); 
    175192        } 
     
    185202 
    186203        protected void readFromStream(StructReader pReader, int pLen, boolean pInitFromDb) { 
    187                 pReader.skipByte();//versSer 
     204                byte vVers = pReader.getAsByte();//versSer 
    188205                pReader.pushOwner(this); 
    189206                fTitle = pReader.getAsString(); 
     
    191208                fWspMeta = pReader.getAsValue(); 
    192209                fStamp = pReader.getAsValueOrNull(); 
     210                if (vVers >= VERS_SER_WSP_1) { 
     211                        fProperties = pReader.getAsValueOrNull(); 
     212                } 
    193213                pReader.popOwner(); 
    194214                fDirty = !pInitFromDb; 
  • trunk/Jav_WspOdb/src/eu/scenari/wspodb/wsp/OdbWspDefinition.java

    r19581 r19585  
    7878import eu.scenari.orient.IDbDriver; 
    7979import eu.scenari.orient.recordstruct.IRecordStruct; 
     80import eu.scenari.orient.recordstruct.IValue; 
    8081import eu.scenari.orient.recordstruct.lib.link.ValueLinkPropsBsp; 
    8182import eu.scenari.orient.recordstruct.lib.link.ValueRevLinksIBspU; 
    8283import eu.scenari.orient.recordstruct.lib.link.named.ValueRevLinksNamed; 
     84import eu.scenari.orient.recordstruct.lib.primitive.ValueBoolean; 
    8385import eu.scenari.orient.recordstruct.lib.primitive.ValueString; 
    8486import eu.scenari.orient.recordstruct.link.ILink; 
     
    101103import eu.scenari.wspodb.struct.IValueWsp; 
    102104import eu.scenari.wspodb.struct.lib.ValueSrcContentId; 
     105import eu.scenari.wspodb.struct.lib.ValueWsp; 
    103106import eu.scenari.wspodb.struct.lib.drv.ValueDrvSrcContent; 
    104107import eu.scenari.wspodb.wsp.act.OdbWspSrcAnnot; 
     
    197200                        fSrcRootContent = new OdbVersionWspSrcNode(this, ISrcServer.URI_ROOT); 
    198201                } 
    199                 //Par défaut config des extItems issu du WspProv. 
    200                 fExternalItemsAllowed = pWspProvider.isExternalItemsAllowed(); 
     202                //Init par rapport aux props du wspMeta. 
     203                initWspMetaProps(pValueSrcContent.getExtension(WspOdbTypes.WSP)); 
    201204        } 
    202205 
     
    315318        } 
    316319 
    317         public void writeWspMeta(InputStream pNewWspMeta) throws Exception { 
     320        public void writeWspMeta(InputStream pWspMetaStream, Map<String, Object> pWspMetaProps) throws Exception { 
    318321                IRecordStruct<IValueSrcContent<?>> vRecordWsp = getDbDriver().getThreadLocalDatabase().load(fWspRid); 
    319                 vRecordWsp.getValue().getOrCreateExtension(WspOdbTypes.WSP).getWspMeta().writeFrom(pNewWspMeta, false, true); 
     322                ValueWsp vWsp = vRecordWsp.getValue().getOrCreateExtension(WspOdbTypes.WSP); 
     323                vWsp.getWspMeta().writeFrom(pWspMetaStream, false, true); 
     324                Boolean vAllowExternalItems = getBooleanFromProps(pWspMetaProps, OdbWspProviderLoader.ATT_EXTITEMALLOWED); 
     325                if (vAllowExternalItems == Boolean.TRUE) { 
     326                        vWsp.getOrCreateProperties().put(OdbWspProviderLoader.ATT_EXTITEMALLOWED, ValueBoolean.TRUE); 
     327                } else if (vAllowExternalItems == Boolean.FALSE) { 
     328                        vWsp.getOrCreateProperties().put(OdbWspProviderLoader.ATT_EXTITEMALLOWED, ValueBoolean.FALSE); 
     329                } else { 
     330                        Map<String, IValue<?>> vProps = vWsp.getProperties(); 
     331                        if (vProps != null) vProps.remove(OdbWspProviderLoader.ATT_EXTITEMALLOWED); 
     332                } 
    320333                vRecordWsp.save(); 
     334                initWspMetaProps(vWsp); 
    321335                fWspProvider.fWspDefEventManager.dispatchEvent(new WspDefEvent(WspDefEvent.TYPE_PROPERTIES_UPDATED, this)); 
     336        } 
     337 
     338        protected void initWspMetaProps(ValueWsp pValueWsp) { 
     339                Map<String, IValue<?>> vProps = pValueWsp.getProperties(); 
     340                if (vProps == null) { 
     341                        fExternalItemsAllowed = fWspProvider.isExternalItemsAllowed(); 
     342                        return; 
     343                } 
     344                ValueBoolean vAllowExternalItems = (ValueBoolean) vProps.get(OdbWspProviderLoader.ATT_EXTITEMALLOWED); 
     345                if (vAllowExternalItems == null) { 
     346                        fExternalItemsAllowed = fWspProvider.isExternalItemsAllowed(); 
     347                } else { 
     348                        fExternalItemsAllowed = vAllowExternalItems.getPojo() == true; 
     349                } 
     350        } 
     351 
     352        private Boolean getBooleanFromProps(Map<String, Object> pWspMetaProps, String pKey) { 
     353                if (pWspMetaProps == null) return null; 
     354                Object vVal = pWspMetaProps.get(pKey); 
     355                if (vVal == null) return null; 
     356                return Boolean.parseBoolean(vVal.toString()); 
    322357        } 
    323358 
  • trunk/Jav_WspOdb/src/eu/scenari/wspodb/wsp/OdbWspDefinitionDrv.java

    r19348 r19585  
    5555                refreshWsp(pValueSrcContent); 
    5656                fSrcRootContent = new OdbWspSrcNode(this, ISrcServer.URI_ROOT); 
     57                //Init par rapport aux props du wspMeta. 
     58                initWspMetaProps(pValueSrcContent.getExtension(WspOdbTypes.WSP)); 
    5759        } 
    5860 
Note: See TracChangeset for help on using the changeset viewer.