use of org.apache.ofbiz.minilang.MiniLangRuntimeException in project ofbiz-framework by apache.
the class SetNonpkFields method exec.
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
GenericValue value = valueFma.get(methodContext.getEnvMap());
if (value == null) {
throw new MiniLangRuntimeException("Entity value not found with name: " + valueFma, this);
}
Map<String, ? extends Object> theMap = mapFma.get(methodContext.getEnvMap());
if (theMap == null) {
throw new MiniLangRuntimeException("Map not found with name: " + mapFma, this);
}
boolean setIfNull = !"false".equals(setIfNullFse.expand(methodContext.getEnvMap()));
value.setNonPKFields(theMap, setIfNull);
return true;
}
use of org.apache.ofbiz.minilang.MiniLangRuntimeException in project ofbiz-framework by apache.
the class RemoveList method exec.
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
List<GenericValue> values = listFma.get(methodContext.getEnvMap());
if (values == null) {
throw new MiniLangRuntimeException("Entity value list not found with name: " + listFma, this);
}
try {
Delegator delegator = getDelegator(methodContext);
delegator.removeAll(values);
} catch (GenericEntityException e) {
String errMsg = "Exception thrown while removing entities: " + e.getMessage();
Debug.logWarning(e, errMsg, module);
simpleMethod.addErrorMessage(methodContext, errMsg);
return false;
}
return true;
}
use of org.apache.ofbiz.minilang.MiniLangRuntimeException in project ofbiz-framework by apache.
the class SetCurrentUserLogin method exec.
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
GenericValue userLogin = valueFma.get(methodContext.getEnvMap());
if (userLogin == null) {
throw new MiniLangRuntimeException("Entity value not found with name: " + valueFma, this);
}
methodContext.setUserLogin(userLogin, this.simpleMethod.getUserLoginEnvName());
return true;
}
use of org.apache.ofbiz.minilang.MiniLangRuntimeException in project ofbiz-framework by apache.
the class SetPkFields method exec.
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
GenericValue value = valueFma.get(methodContext.getEnvMap());
if (value == null) {
throw new MiniLangRuntimeException("Entity value not found with name: " + valueFma, this);
}
Map<String, ? extends Object> theMap = mapFma.get(methodContext.getEnvMap());
if (theMap == null) {
throw new MiniLangRuntimeException("Map not found with name: " + mapFma, this);
}
boolean setIfNull = !"false".equals(setIfNullFse.expand(methodContext.getEnvMap()));
value.setPKFields(theMap, setIfNull);
return true;
}
use of org.apache.ofbiz.minilang.MiniLangRuntimeException in project ofbiz-framework by apache.
the class RegexpCondition method checkCondition.
@Override
public boolean checkCondition(MethodContext methodContext) throws MiniLangException {
Object fieldVal = fieldFma.get(methodContext.getEnvMap());
if (fieldVal == null) {
fieldVal = "";
} else if (!(fieldVal instanceof String)) {
try {
fieldVal = MiniLangUtil.convertType(fieldVal, String.class, methodContext.getLocale(), methodContext.getTimeZone(), null);
} catch (Exception e) {
throw new MiniLangRuntimeException(e, this);
}
}
String regExp = exprFse.expandString(methodContext.getEnvMap());
Pattern pattern = null;
try {
pattern = PatternFactory.createOrGetPerl5CompiledPattern(regExp, true);
} catch (MalformedPatternException e) {
Debug.logError(e, "Regular Expression [" + regExp + "] is mal-formed: " + e.toString(), module);
throw new MiniLangRuntimeException(e, this);
}
PatternMatcher matcher = new Perl5Matcher();
if (matcher.matches((String) fieldVal, pattern)) {
// Debug.logInfo("The string [" + fieldVal + "] matched the pattern expr [" + pattern.getPattern() + "]", module);
return true;
} else {
// Debug.logInfo("The string [" + fieldVal + "] did NOT match the pattern expr [" + pattern.getPattern() + "]", module);
return false;
}
}
Aggregations