Name

sn_smd.SMElementProperty

Description

No description available

Script

var SMElementProperty = Class.create();

SMElementProperty.encodeParameters = function(str) {
  	var regex = /\$\{\/@element::([^}]*)\}/g;
  	// do not encode if reference - ${/@element::elemID/@child::id/propName}
  	if(regex.exec(str) != null) 
  		return str;
  		
  	return str.replace(/\$\{([^}]*)}/g, '${@service-param::$1}');
};

SMElementProperty.prototype = {
  propEntry: null,
  
  initialize: function(propEntry) {
  	this.propEntry = propEntry;
  },
  
  getDAO: function() {
  	return this.propEntry;
  },
  
  getName: function() {
  	return this.getDAO().getName();
  },
  
  getValue: function() {
  	return this.getDAO().getValue();
  },
  
  getValueOrDefault: function(defaultValue) {
  	var val = this.getValue();
  	return gs.nil(val) ? defaultValue : val;
  },
  
  setValue: function(value) {
  	this.getDAO().setValue(value);
  },
  
  encodeAndSetValue: function(value) {
  	var encodedVal = SMElementProperty.encodeParameters(value);
  	this.getDAO().setValue(encodedVal);
  },
  
  isFinal: function() {
  	return this.getDAO().isFinalValue();
  },
  
  setFinal: function(flag) {
  	this.getDAO().setFinalValueFlag(flag);
  },
  
  //returns IPropertyDescriptor 
  getMetadata: function() {
  	return this.getDAO().getMetadata();
  },
  
  requiresSubstitution: function() {
  	return this.getDAO().requiresSubstitutions();
  },
  
  setSubstitution: function(shouldSubstitute) {
  	this.getDAO().setSubstitutionsFlag(shouldSubstitute);
  },
  
  getReferences: function() {
  	var propValue = this.getValue();
  	var references = [];
  	if (!propValue)
  		return references;
  	
  	var regex = /\$\{\/@element::([^}]*)\}/g;
  	
  	var match;
  	while ((match = regex.exec(propValue)) != null) {
  		var reference = {};
  		reference.name = match[1];
  		reference.value = '';
  		references.push(reference);
        }
        return references;
  },
  
  getParams: function(withContext) {
  	var propValue = this.getValue();
  	var params = [];
  	if (!propValue)
  		return params;
  	
  	var regex;
  	if (withContext)
  		regex = /\$\{@service-param::([^}]*)\}/g;
  	else
  		regex = /\$\{([^}]*)\}/g;
  	
  	var match;
  	while ((match = regex.exec(propValue)) != null) {
  		var param = {};
  		param.name = match[1];
  		param.value = '';
  		params.push(param);
  	}

  	return params;
  },
  
  // Decode ${@service-param::param} -> ${param} 
  getDecodedValue: function() {
  	var propValue = this.getValue();
  	return propValue.replace(/\$\{@service-param::([^}]*)}/g, '${$1}');	
  },
  
  type: 'SMElementProperty'
};

Sys ID

8c568925c3122200e2ddb59af3d3aea8

Offical Documentation

Official Docs: