<@doc hierarchy="GMLDOM"> An object that provides some methods for the runtime providers. (c) SAP AG 2003-2006. All rights reserved. Class CodeCache inherit gml:Object; /////////////////////////////////////////////////////////////////////// // Properties virtual property mUnitID = null; virtual property mUnitLocation = null; virtual property mXglFile = null; virtual property mXlfFile = null; virtual property mWarningData = null; virtual property mXglFileName = 'XGL.xml'; virtual property mXlfFileName = 'MasterLanguage.xlf'; virtual property mXglIndex = 0; virtual property mXlfIndex = 1; virtual property mXglExt = 'xgl'; virtual property mXlfExt = 'xlf'; virtual property mDot = '.'; constructor (gml2Model) if(gml2Model){ this.mUnitID=gml2Model.id; this.mUnitLocation = gml2Model.impl_location; } end <@doc scope="protected"> set the object status as empty of xgl file method setDirty() #TRACE[1,'#### CodeCache::setDirty (in)####']; this.mXglFile = null; this.mXlfFile = null; this.mWarningData = null; #TRACE[1,'#### CodeCache::setDirty (out)####']; end <@doc scope="public"> Return the unit of this cache method getUnit() return $ENV.model.getUnit(this.mUnitID,this.mUnitLocation); end <@doc scope="public"> Reports the status of the cached data method isDirty() var unit = this.getUnit(); if(!unit){ #LOG[1,'#### Model '+this.mUnitID+' can not be found. ####']; return false; } return (!unit.isReadonly() && this.isXGLDirty()); end <@doc scope="public"> Reports the status of the cached data method isXGLDirty() var unit = this.getUnit(); if(!unit){ #LOG[1,'#### Model '+this.mUnitID+' can not be found. ####']; return false; } return (unit.xglDirty != #[XGL_DAMAGE_NONE]); end <@doc scope="public"> return the cached xgl file as string method getXgl() return this.mXglFile; end <@doc scope="public"> return the cached xlf file as string method getXlf() return this.mXlfFile; end method hasWarning(){ return this.mWarningData != null; } method getWarningsMsg(){ return this.mWarningData; } method serializeData(writer) var success = true; this.setDirty(); var unit = this.getUnit(); if(writer && unit){ writer.serialize(); if(writer.errorsCount == 0){ var baseFilePath = "\\"+unit.id+"\\"+unit.id; var xglFile = writer.getFile(baseFilePath+this.mDot+this.mXglExt) || null; var xlfFile = writer.getFile(baseFilePath+this.mDot+this.mXlfExt) || null; if(xglFile){ if(!xlfFile && !ISA(unit,'gml2:Service')){ var msg = '#TEXT[XMSG_XLF_FILENOTFOUND]'; #LOG[4, msg + baseFilePath + this.mDot + this.mXlfExt]; } else { this.mXglFile = xglFile.text; this.mXlfFile = xlfFile ? xlfFile.text : null; this.mWarningData = writer.getErrorsOfUnit(unit); try{ //make sure that if the model is not save we will save it //in order to keep GML and XGL up-to-date #TRACE[1,'#### CodeCache::serializeData call saveSingleModel####']; // if there is a breaking migration, display the warning message and save the model no matter what if(unit.isDirty() || unit.hasMigrationStatus()) $ENV.saveSingleModel(unit.id); #TRACE[1,'#### CodeCache::serializeData return from call saveSingleModel####']; } catch(e) { #LOG[4,'#### CodeCache::serializeData internal error while trying to save model, reason: ' +e.description+' ####']; success = false; } var files = {}; files[this.mXglFileName] = { text:this.mXglFile }; if(this.mXlfFile){ files[this.mXlfFileName] = { text: this.mXlfFile }; } try{ success = $ENV.model.writeImplementationXMLFiles(files,unit.impl_location) } catch(e) { #LOG[4,'#### CodeCache::serializeData internal erro while trying to write implementation, reason: ' +e.description+' ####']; success = false; } if(!success){ this.setDirty(); var msg = '#TEXT[XMSG_ENV_SAVING_ERROR]'; #LOG[4, msg]; } }//of if !xlfFile }//of if !xglFile }//of if errorsCount==0 }//of if writer && unit if(!success){ writer.error('#TEXT[XMSG_ERROR_IN_COMPILATION]',unit); } return success; end method deserializeData(writer) var success = true; var unit = this.getUnit(); if(writer && unit){ if(unit.isReadonly()){ if(!this.mXglFile){ var fileList = []; fileList[this.mXglIndex] = this.mXglFileName; fileList[this.mXlfIndex] = this.mXlfFileName; var unitFiles = $ENV.model.channel.readUnit(unit.id, fileList, unit.impl_location); var xgl = unitFiles[this.mXglIndex]; var xlf = unitFiles[this.mXlfIndex]; this.mXglFile = xgl && xgl.xml ? xgl.xml : null; this.mXlfFile = xlf && xlf.xml ? xlf.xml : null; if(this.isDirty()){ var msg = '#TEXT[XMSG_XGL_FILENOTFOUND_INDB]'; #LOG[4, msg + " ("+unit.id+")"]; success = false; } } } if(!this.isDirty()){ var urn = unit.urn || unit.id; var folder = writer.createFolder(null,urn); if(folder){ folder.caption = (unit.name||urn); var file = writer.createFile(folder,urn,this.mXglExt); if(file){ file.caption = (unit.name||urn) + this.mDot + this.mXglExt; writer.add(this.mXglFile); if(this.mXlfFile!=null){ file = writer.createFile(folder,urn,this.mXlfExt); file.caption = (unit.name||urn) + this.mDot + this.mXlfExt; writer.add(this.mXlfFile); } if(this.mWarningData){ var warnings = this.mWarningData,len=warnings.length; for(var idx=0 ; idx < len ; ++idx){ writer.warning(warnings[idx].msg,warnings[idx].obj,warnings[idx].hint); } } } else {//of if file #TRACE[4, 'Failed to create file for '+urn]; } } else {//of if folder #TRACE[4, 'Failed to create folder for '+urn]; } } } if(!success){ writer.error('#TEXT[XMSG_ERROR_IN_COMPILATION]',unit); } return success; end method deserializeDataFromDB(xgl,xlf) //update the xgl state on the unit while when it is open if(xgl && xgl.xml){ this.mXglFile = xgl.xml; this.mXlfFile = xlf && xlf.xml ? xlf.xml : null; var unit = this.getUnit(); if(!unit){ #LOG[1,'#### Model '+this.mUnitID+' can not be found. ####']; return; } unit.clearXglDirty(); } else { this.mXglFile = null; this.mXlfFile = null; } end