@Override public Object apply(ActionParams params) { try { Map<String, Object> map = params.toMap(); engine.setContextVariable(PARAMS, Collections.unmodifiableMap(map)); Object value = JsConvert.convert(module.eval(map)); log.debug("Result : {}", value); if (returnTypeDefined && null != value && returnType.isSimpleType()) { value = Converts.convert(value, returnType.asSimpleType().getJavaType()); } return value; }catch (RuntimeException e) { throw e; }catch (Exception e) { throw new RuntimeException(e.getMessage(), e); }finally { engine.removeContextVariable(PARAMS); } }
Class<?> toJavaType(MType type) { if(type.isSimpleType()) { return type.asSimpleType().getJavaType(); } if(type.isCollectionType()) { return Array.newInstance(toJavaType(type.asCollectionType().getElementType()), 0).getClass(); } if(type.isComplexType() || type.isDictionaryType() || type.isTypeRef()) { return Map.class; } if(type.isObjectType()) { return Object.class; } throw new IllegalStateException("Unsupported data type '" + type + "'"); }
if(!p.getType().isSimpleType()){ return;
void mappingBeanProperty(MetaField f, BeanProperty bp) { if(null == bp) { return; } if(null != bp && !Strings.isEmpty(f.getType())) { MType mtype = MTypes.getMType(bp.getType(), bp.getGenericType()); if(mtype.isSimpleType()) { f.setType(mtype.asSimpleType().getJdbcType().getName()); if(MSimpleTypes.STRING.equals(mtype) && null == f.getLength()) { f.setLength(255); } } } }
if(type.isSimpleType()) { arg.setType(type.asSimpleType().getJavaType()); return; if(elementType.isSimpleType()) { arg.setType(Array.newInstance(elementType.asSimpleType().getJavaType(),0).getClass()); }else if(elementType.isObjectType()){
public static String toTypeName(MType type) { if(type.isSimpleType()) { SwaggerType st = swaggerWriter.convertSimpleType(type.asSimpleType()); if(null == st) { throw new IllegalStateException("Unsupported type '" + type + "'"); } return st.name().toLowerCase(); } if(type.isCollectionType()) { MType elementType = type.asCollectionType().getElementType(); return "array<" + toTypeName(elementType) + ">"; } if(type.isComplexType()) { return type.asComplexType().getName(); } if(type.isTypeRef()) { return type.asTypeRef().getRefTypeName(); } if(type.isDictionaryType()) { return "map<string," + toTypeName(type.asDictionaryType().getValueType()) + ">"; } if(type.isObjectType()) { return "object"; } if(type.isVoidType()) { return ""; } throw new IllegalStateException("Unsupported type '" + type + "'"); }
@Override public Object apply(ActionParams params) { Map<String,Object> map = params.toMap(); Object result; if(command.getMetadata().isSelect()) { //todo: page query, total count Query query = dao.createQuery(command).params(map); if(null != returnType) { if(returnType.isSimpleType()) { result = Converts.convert(query.scalarValueOrNull(), returnType.asSimpleType().getJavaType()); }else if(returnType.isCollectionType() && returnType.asCollectionType().getElementType().isSimpleType()) { result = query.scalars().list(returnType.asCollectionType().getElementType().asSimpleType().getJavaType()); }else { result = query.list(); } }else { result = query.list(); } }else{ //todo: the return type must be simple type result = dao.executeUpdate(command, map); if(null != returnType) { result = Converts.convert(result, returnType.asSimpleType().getJavaType()); } } return ApiResponse.of(result); }
if(type.isSimpleType()) { writeSimpleType(context, m, w, type.asSimpleType()); return;
protected void writeParameterType(WriteContext context, ApiMetadata m, JsonWriter w, MApiParameterBase p) { MType type = p.getType(); if(type.isSimpleType()) { writeSimpleParameterType(context, m, w, p, type.asSimpleType()); return;
public static Validator of(MetaApi api, String name, boolean required, MType type, @Nullable MetaObjFormatted p) { if(type.isSimpleType()) { SimpleValidator validator = null; if(null != p) {
if(dataType.isSimpleType()) { MSimpleType st = dataType.asSimpleType();
if(!fm.getDataType().isSimpleType()) { String serializeFormat = context.getOrmContext().getConfig().getDefaultSerializer(); FieldSerializer serializer = factory.tryGetBean(FieldSerializer.class, serializeFormat);