<@doc hierarchy="GMLDOM"> Class for location object (c) SAP AG 2003-2006. All rights reserved. #INCLUDE[lib:defs.inc] #DEPENDENCIES[ dev:urn.UrnUtils.js ] /** * A Location class. Used to represent a component location. * This is a Channel Object. It must be identical to its corresponding server side object * defined in property _objectType. * * @author I043344 */ Class Location implement env:IChannelObject; <@doc>Gets the Location id property id = ''; <@doc>Gets the Location package prefix property packagePrefix = ''; <@doc>Gets the Location display name property displayName = ''; <@doc>Gets the Location repository id property repository = ''; <@doc scope="private">Gets the Location development component object property dc = null; <@doc scope="private">Gets the Location software component object property sc = null; <@doc scope="private">Gets the corresponding server side object path property _objectType='com.sap.visualcomposer.channelObjects.Location'; <@doc scope="private">Gets the corresponding client side object path property _gsObjectType = "dev:Location"; <@doc> Creates a new Location object constructor(location_id, packagePrefix, rep, sc_name, sc_vendor, dc_id, dc_prefix, dc_vendor) this.init(location_id, packagePrefix, rep, sc_name, sc_vendor, dc_id, dc_prefix, dc_vendor); end <@doc> Initialize a Location object method init(location_id, packagePrefix, rep, sc_name, sc_vendor, dc_id, dc_prefix, dc_vendor) this.id = location_id || ''; this.packagePrefix = packagePrefix || ''; this.repository = rep || ''; this.dc = $ENV.createObject('dev:DCProperties'); if (!dc_prefix || '' == dc_prefix) { this.dc.setId(dc_id || ''); } else { this.dc.setIdWithPrefix(dc_prefix, dc_id || ''); } this.dc.setVendor(dc_vendor || ''); this.sc = $ENV.createObject('dev:SCProperties') this.sc.setId(sc_name || ''); this.sc.setVendor(sc_vendor || ''); end <@doc> Sets id method setId(new_id) this.id = new_id; end <@doc> Gets id method getId() var ret = ''; if (this.id) { ret = this.id; } return ret; end <@doc> Sets packagePrefix method setPackagePrefix(packagePrefix) this.packagePrefix = packagePrefix; end <@doc> Gets package prefix The requested package prefix method getPackagePrefix() var ret = ''; if (this.packagePrefix) { ret = this.packagePrefix; } return ret; end method getGUIDQualifiedName() return this.id && this.id != '' ? this.packagePrefix + '.' + this.id : ''; end <@doc> Sets displayName method setDisplayName(displayName) this.displayName = displayName; end <@doc> Gets displayName The requested displayName method getDisplayName() var ret = ''; if (this.displayName) { ret = this.displayName; } return ret; end <@doc> Sets repository method setRepository(new_rep) this.repository = new_rep; end <@doc> Gets repository id The requested repository id method getRepository() var ret = ''; if (this.repository) { ret = this.repository; } return ret; end <@doc> Gets development component name The requested dc name method getDCName() var ret = ''; if (this.dc) { ret = this.dc.getName(); } return ret; end <@doc> Gets development component id The requested dc id method getDCId() var ret = ''; if (this.dc) { ret = this.dc.getId(); } return ret; end <@doc> Gets development component vendor The requested dc vendor method getDCVendor() var ret = ''; if (this.dc) { ret = this.dc.getVendor(); } return ret; end <@doc> Sets DC name with old prefix and name method setDCIdWithPrefix(dcPrefix, dcId) this.dc.setIdWithPrefix(dcPrefix, dcId); end <@doc> @Deprecated Gets development component prefix The requested dc prefix method getDCPrefix() var ret = ''; if (this.dc) { ret = this.dc.getPrefix(); } return ret; end <@doc> Sets dcProperties method setDc(dcProperties) if (!dcProperties || !dcProperties.clone) return; this.dc = dcProperties.clone(); end <@doc> Gets dcProperties method getDc() return this.dc; end <@doc> @Deprecated Sets DC prefix method setDCPrefix(dcPrefix) this.dc.setPrefix(dcPrefix); end <@doc> Sets DC vendor method setDCVendor(dcVendor) this.dc.setVendor(dcVendor); end <@doc> Sets DC id method setDCId(dcId) this.dc.setId(dcId); end <@doc> Sets DC name method setDCName(dcName) this.dc.setName(dcName); end <@doc> Gets software component name The requested sc name method getSCName() var ret = ''; if (this.sc) { ret = this.sc.getName(); } return ret; end <@doc> Gets software component id The requested sc id method getSCId() var ret = ''; if (this.sc) { ret = this.sc.getId(); } return ret; end <@doc> Gets software component vendor The requested sc vendor method getSCVendor() var ret = ''; if (this.sc) { ret = this.sc.getVendor(); } return ret; end <@doc> Gets software component full name The requested sc full name method getSCFullName() var ret = ''; if (this.sc) { ret = this.sc.getSCFullName(); } return ret; end <@doc> Sets dcProperties method setSc(scProperties) if (!scProperties || !scProperties.clone) return; this.sc = scProperties.clone(); end <@doc> Gets scProperties method getSc() return this.sc; end <@doc> Sets SC vendor method setSCVendor(scVendor) this.sc.setVendor(scVendor); end <@doc> Sets SC name method setSCName(scName) this.sc.setName(scName); end <@doc> Sets SC ID method setSCId(scId) this.sc.setId(scId); end <@doc> Copy location source to location target the target Location if succeeded copying method copyLocation(newGuid) var target = $ENV.createObject('dev:Location', newGuid, this.packagePrefix, this.repository, this.getSCId(), this.getSCVendor(), this.getDCId(), '', this.getDCVendor()); target.displayName = this.displayName; return target; end <@doc> Serializes the location to an XML string the XML serialized format method getAsXML(header, displayname) var stringarray = []; stringarray.push('<'); stringarray.push(header); stringarray.push(' urn="'); stringarray.push(this.id); stringarray.push('" packageprefix="'); stringarray.push(this.packagePrefix); // for backward comp. if (displayname) { stringarray.push('" displayname="'); stringarray.push(displayname); } else if (this.displayName) { stringarray.push('" displayname="'); stringarray.push(this.displayName); } stringarray.push('" repository="'); stringarray.push(this.repository); stringarray.push('" dc="'); stringarray.push(this.getDCId()); stringarray.push('" dcname="'); stringarray.push(this.getDCId()); stringarray.push('" dcvendor="'); stringarray.push(this.getDCVendor()); stringarray.push('" dcprefix="'); //stringarray.push(this.getDCPrefix()); stringarray.push('" sc="'); stringarray.push(this.getSCFullName()); stringarray.push('" scname="'); stringarray.push(this.getSCId()); stringarray.push('" scvendor="'); stringarray.push(this.getSCVendor()); stringarray.push('"/>'); return JOIN(stringarray,''); end <@doc> Returns location relative to parent. Empty strings will replace shared properties. the relative Location object method getRelativeLocation(parentLocation) // *** Relative Dependencies Infrastructure *** // Current relativeness level is only of repository var res = this.copyLocation(this.id); // Relativeness check // (to add more relativeness levels, add 'if's here) if (parentLocation && this.repositoryEquals(parentLocation)) res.repository = ''; return res; end <@doc> Returns absolute location according to parent. Empty properties will be replaced with real values. the absolute Location object method getAbsoluteLocation(parentLocation) // *** Relative Dependencies Infrastructure *** // Current relativeness level is only of repository var res = this.copyLocation(this.id); // Relativeness check // (to add more relativeness levels, add 'if's here) if (parentLocation && this.repository == '') res.repository = parentLocation.repository; // Backward compatibility else if (parentLocation && this.repositoryEquals(parentLocation)) { // Repositories may be equal although strings are not - force using parent's key res.repository = parentLocation.repository; } return res; end <@doc> Deserializes the location from an XML object the Location object method readLocation(xmlnode, tagname, location) tagnode = xmlnode.selectSingleNode(tagname); if (!tagnode) throw new Error(-1, "Failed to read dependency file"); location = $ENV.createObject('dev:Location', tagnode.getAttribute("urn"), tagnode.getAttribute("packageprefix") || '', tagnode.getAttribute("repository"), tagnode.getAttribute("scname"), tagnode.getAttribute("scvendor"), tagnode.getAttribute("dcname"), tagnode.getAttribute("dcprefix"), tagnode.getAttribute("dcvendor")); var dis = tagnode.getAttribute("displayname"); if (dis) { location.displayName = dis; } return location; end <@doc> Clones the Location object the Location object clone method clone() return this.copyLocation(this.id); end <@doc> Checks whether given location equals to this location to repository level. *** Not to be used to compare repositories across development configurations! *** *** (Only inequality that could be found by this method is Local <-> DTR diff *** True if both locations in same repository, false otherwise method repositoryEquals(location) if (GETVAR('Platform') == 'eclipse') { // On Eclipse - always same repository return true; } else { // On server - if one is empty == equals if ('' == this.repository || '' == location.repository) return true; // If not, and both not local == equals if (!$ENV.isLocalRepositoryKey(location.repository) && !$ENV.isLocalRepositoryKey(this.repository)) return true; // Otherwise, compare keys return this.repository == location.repository; } end <@doc> Checks whether given location equals to this location to SC level. True if both locations in same SC, false otherwise method scEquals(location) return this.repositoryEquals(location) && this.getSCName() == location.getSCName() && this.getSCVendor() == location.getSCVendor(); end <@doc> Checks whether given location equals to this location to DC level. True if both locations in same DC, false otherwise method dcEquals(location) return this.scEquals(location) && this.getDCId() == location.getDCId() && this.getDCVendor() == location.getDCVendor(); end <@doc> Checks whether given location equals to this location to model level. True if both locations are of same model, false otherwise method modelEquals(location) return this.dcEquals(location) && this.id == location.id && this.packagePrefix == location.packagePrefix; end <@doc> Returns a display representation of the Location object The dispalyable name method getLocationAsString(withName, rotateSlashes, removeImpl, hideRepository) var retStr = []; var slash = rotateSlashes ? "\\" : "/"; var scFullName = this.getSCFullName(); var dcName = this.getDCName(); if (!hideRepository && this.repository) retStr.push($ENV.getRepositoryName(this.repository)); if (scFullName) retStr.push(scFullName); if (dcName) { var vendor = this.getDCVendor(); if (vendor) retStr.push(vendor); if (removeImpl) dcName = ImplementationToInterfaceDC(dcName); retStr.push(dcName.replace("\/", slash)); } if (withName) retStr.push(this.displayName ? this.displayName : this.id); return JOIN(retStr, slash); end <@doc> Returns Map representation of the Loaction NOTE : this function is Location.java dependent !! HashMap method getLocationAsMap() var retObj = {}; retObj['packageprefix'] = this.packagePrefix || ''; retObj['repository'] = this.repository || ''; retObj['scname'] = this.sc.getName() || ''; retObj['scvendor'] = this.getSCVendor() || ''; retObj['dcname'] = this.dc.getName() || ''; retObj['dcvendor'] = this.getDCVendor() || ''; retObj['dcprefix'] = this.getDCPrefix() || ''; retObj['displayname'] = this.getDisplayName() || ''; return retObj; end <@doc> Returns ~true if Location object is valid (e.g. contains all fields) method isLocationValid() if (!this.dc || !this.sc) return false; var locMap = this.getLocationAsMap(); for (var k in locMap) { // PP/DC Prefix is optional if (k == 'packageprefix' || k == 'dcprefix' || k == 'displayname') continue; if (!locMap[k]) return false; } return true; end <@doc> Returns ~true if Location object is DC type, ~else if model method isDC() return this.id ? false : true; end <@doc> method toBuildString() //Whenever this key changed, last deploy application's key should be update accordingly in Location.java class. return JOIN([this.getSCVendor()+('_'+this.getSCId()),this.getDCVendor(),this.getDCName()],"\/"); end