use of indi.mybatis.flying.models.FlyingModel in project mybatis.flying by limeng32.
the class FlyingManager method fetchFlyingFeature.
public static FlyingModel fetchFlyingFeature(String originalSql, String id) {
if (flyingModelCache.get(id) != null) {
return flyingModelCache.get(id);
}
FlyingModel ret = new FlyingModel();
String extension = null;
if (null != originalSql && originalSql.startsWith(FlyingKeyword.FLYING) && originalSql.indexOf(':') > -1) {
String s1 = null;
if (originalSql.startsWith(FlyingKeyword.FLYING_LEFTBRACKET) || originalSql.startsWith(FlyingKeyword.FLYING_QUESTIONMARK_LEFTBRACKET)) {
s1 = originalSql.substring(0, originalSql.indexOf(':', originalSql.indexOf(')')));
} else {
s1 = originalSql.substring(0, originalSql.indexOf(':'));
}
if (FlyingKeyword.FLYING.equals(s1) || FlyingKeyword.FLYING_QUESTIONMARK.equals(s1) || s1.startsWith(FlyingKeyword.FLYING_LEFTBRACKET) || originalSql.startsWith(FlyingKeyword.FLYING_QUESTIONMARK_LEFTBRACKET)) {
String s2 = null;
if (s1.startsWith(FlyingKeyword.FLYING_LEFTBRACKET) || originalSql.startsWith(FlyingKeyword.FLYING_QUESTIONMARK_LEFTBRACKET)) {
s2 = originalSql.substring(originalSql.indexOf(':', originalSql.indexOf(')')) + 1, originalSql.length());
} else {
s2 = originalSql.substring(originalSql.indexOf(':') + 1, originalSql.length());
}
String actionTypeStr = null;
if (s2.indexOf(':') > -1) {
actionTypeStr = s2.substring(0, s2.indexOf(':'));
} else {
actionTypeStr = s2;
}
if (actionTypeStr.endsWith(")") && actionTypeStr.indexOf('(') != -1) {
extension = actionTypeStr.substring(actionTypeStr.lastIndexOf('(') + 1, actionTypeStr.length() - 1);
actionTypeStr = actionTypeStr.substring(0, actionTypeStr.lastIndexOf('('));
}
ActionType actionType = ActionType.forValue(actionTypeStr);
if (actionType != null) {
ret.setHasFlyingFeature(true);
ret.setActionType(actionType);
if (s2.indexOf(':') > -1) {
String s3 = s2.substring(s2.indexOf(':') + 1, s2.length());
String ignoreTag = null;
if (s3.indexOf(':') > -1) {
ignoreTag = s3.substring(0, s3.indexOf(':'));
} else {
ignoreTag = s3;
}
ret.setIgnoreTag(ignoreTag);
}
dealKeyHandler(actionType, extension, originalSql, ret);
flyingModelCache.put(id, ret);
return ret;
}
}
}
ret.setHasFlyingFeature(false);
flyingModelCache.put(id, ret);
return ret;
}
use of indi.mybatis.flying.models.FlyingModel in project mybatis.flying by limeng32.
the class FlyingManager method dealInnerPropertiesIteration.
private static JSONObject dealInnerPropertiesIteration(String id, JSONObject flyingJson, Configuration configuration, FlyingModel flyingModel) {
if (flyingModel2ndCache.get(id) != null) {
return flyingModel2ndCache.get(id);
}
JSONObject threshold = flyingJson.getJSONObject("properties");
if (threshold == null || threshold.isEmpty()) {
return flyingJson;
}
for (Map.Entry<String, Object> e : threshold.getInnerMap().entrySet()) {
JSONObject json = (JSONObject) e.getValue();
if (json.containsKey(FlyingKeyword.ID)) {
String innerId = json.getString(FlyingKeyword.ID);
if (innerId.indexOf('.') == -1 && id.indexOf('.') > -1) {
innerId = new StringBuilder(id.substring(0, id.lastIndexOf('.') + 1)).append(innerId).toString();
}
String originalSql = configuration.getMappedStatement(innerId).getBoundSql(null).getSql();
JSONObject innerJson = JSONObject.parseObject(originalSql);
FlyingModel innerFlyingModel = new FlyingModel();
buildFlyingModel(innerFlyingModel, json, originalSql, innerId, false, innerJson, flyingModel.getPrefix());
dealInnerPropertiesIteration(innerId, innerJson, configuration, innerFlyingModel);
flyingModel.getProperties().put(e.getKey(), innerFlyingModel);
} else {
FlyingModel innerFlyingModel = new FlyingModel();
buildFlyingModel(innerFlyingModel, json, "", null, false, null, flyingModel.getPrefix());
flyingModel.getProperties().put(e.getKey(), innerFlyingModel);
}
}
return flyingJson;
}
Aggregations