com.alogic.xscript.plugins.FromSettings Maven / Gradle / Ivy
package com.alogic.xscript.plugins;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import com.alogic.xscript.AbstractLogiclet;
import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;
import com.anysoft.util.Settings;
/**
* 从settings中提取相应的值,并设置为变量
*
* @author duanyy
*
* @since 1.6.5.39
*/
public class FromSettings extends AbstractLogiclet {
protected String id;
protected String value;
public FromSettings(String tag, Logiclet p) {
super(tag, p);
}
public void configure(Properties p){
super.configure(p);
id = PropertiesConstants.getString(p,"id","",true);
value = p.GetValue("value", "", false, true);
}
@Override
protected void onExecute(Map root,
Map current, LogicletContext ctx, ExecuteWatcher watcher) {
if (StringUtils.isNotEmpty(id)){
Settings settings = Settings.get();
ctx.SetValue(id, settings.transform(value));
}
}
}