|
|
@ -709,8 +709,39 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray jrules = new JSONArray();
|
|
|
|
JSONArray jrules = new JSONArray();
|
|
|
|
for (EntityRule rule : db.rule().getRules(folder.id))
|
|
|
|
for (EntityRule rule : db.rule().getRules(folder.id)) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
JSONObject jaction = new JSONObject(rule.action);
|
|
|
|
|
|
|
|
int type = jaction.getInt("type");
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
|
|
case EntityRule.TYPE_MOVE:
|
|
|
|
|
|
|
|
case EntityRule.TYPE_COPY:
|
|
|
|
|
|
|
|
long target = jaction.getLong("target");
|
|
|
|
|
|
|
|
EntityFolder f = db.folder().getFolder(target);
|
|
|
|
|
|
|
|
EntityAccount a = (f == null ? null : db.account().getAccount(f.account));
|
|
|
|
|
|
|
|
if (a != null)
|
|
|
|
|
|
|
|
jaction.put("targetAccountUuid", a.uuid);
|
|
|
|
|
|
|
|
if (f != null)
|
|
|
|
|
|
|
|
jaction.put("targetFolderName", f.name);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_ANSWER:
|
|
|
|
|
|
|
|
long identity = jaction.getLong("identity");
|
|
|
|
|
|
|
|
long answer = jaction.getLong("answer");
|
|
|
|
|
|
|
|
EntityIdentity i = db.identity().getIdentity(identity);
|
|
|
|
|
|
|
|
EntityAnswer t = db.answer().getAnswer(answer);
|
|
|
|
|
|
|
|
if (i != null)
|
|
|
|
|
|
|
|
jaction.put("identityUuid", i.uuid);
|
|
|
|
|
|
|
|
if (t != null)
|
|
|
|
|
|
|
|
jaction.put("answerUuid", t.uuid);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rule.action = jaction.toString();
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jrules.put(rule.toJSON());
|
|
|
|
jrules.put(rule.toJSON());
|
|
|
|
|
|
|
|
}
|
|
|
|
jfolder.put("rules", jrules);
|
|
|
|
jfolder.put("rules", jrules);
|
|
|
|
|
|
|
|
|
|
|
|
jfolders.put(jfolder);
|
|
|
|
jfolders.put(jfolder);
|
|
|
@ -1169,17 +1200,48 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|
|
|
switch (type) {
|
|
|
|
switch (type) {
|
|
|
|
case EntityRule.TYPE_MOVE:
|
|
|
|
case EntityRule.TYPE_MOVE:
|
|
|
|
case EntityRule.TYPE_COPY:
|
|
|
|
case EntityRule.TYPE_COPY:
|
|
|
|
|
|
|
|
String targetAccountUuid = jaction.optString("targetAccountUuid");
|
|
|
|
|
|
|
|
String targetFolderName = jaction.optString("targetFolderName");
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(targetAccountUuid) && !TextUtils.isEmpty(targetFolderName)) {
|
|
|
|
|
|
|
|
EntityAccount a = db.account().getAccountByUUID(targetAccountUuid);
|
|
|
|
|
|
|
|
if (a != null) {
|
|
|
|
|
|
|
|
EntityFolder f = db.folder().getFolderByName(a.id, targetFolderName);
|
|
|
|
|
|
|
|
if (f != null) {
|
|
|
|
|
|
|
|
jaction.put("target", f.id);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Legacy
|
|
|
|
long target = jaction.getLong("target");
|
|
|
|
long target = jaction.getLong("target");
|
|
|
|
Log.i("XLAT target " + target + " > " + xFolder.get(target));
|
|
|
|
Long tid = xFolder.get(target);
|
|
|
|
jaction.put("target", xFolder.get(target));
|
|
|
|
Log.i("XLAT target " + target + " > " + tid);
|
|
|
|
|
|
|
|
if (tid != null)
|
|
|
|
|
|
|
|
jaction.put("target", tid);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case EntityRule.TYPE_ANSWER:
|
|
|
|
case EntityRule.TYPE_ANSWER:
|
|
|
|
|
|
|
|
String identityUuid = jaction.optString("identityUuid");
|
|
|
|
|
|
|
|
String answerUuid = jaction.optString("answerUuid");
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(identityUuid) && !TextUtils.isEmpty(answerUuid)) {
|
|
|
|
|
|
|
|
EntityIdentity i = db.identity().getIdentityByUUID(identityUuid);
|
|
|
|
|
|
|
|
EntityAnswer a = db.answer().getAnswerByUUID(answerUuid);
|
|
|
|
|
|
|
|
if (i != null && a != null) {
|
|
|
|
|
|
|
|
jaction.put("identity", i.id);
|
|
|
|
|
|
|
|
jaction.put("answer", a.id);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Legacy
|
|
|
|
long identity = jaction.getLong("identity");
|
|
|
|
long identity = jaction.getLong("identity");
|
|
|
|
long answer = jaction.getLong("answer");
|
|
|
|
long answer = jaction.getLong("answer");
|
|
|
|
Log.i("XLAT identity " + identity + " > " + xIdentity.get(identity));
|
|
|
|
Long iid = xIdentity.get(identity);
|
|
|
|
Log.i("XLAT answer " + answer + " > " + xAnswer.get(answer));
|
|
|
|
Long aid = xAnswer.get(answer);
|
|
|
|
jaction.put("identity", xIdentity.get(identity));
|
|
|
|
Log.i("XLAT identity " + identity + " > " + iid);
|
|
|
|
jaction.put("answer", xAnswer.get(answer));
|
|
|
|
Log.i("XLAT answer " + answer + " > " + aid);
|
|
|
|
|
|
|
|
jaction.put("identity", iid);
|
|
|
|
|
|
|
|
jaction.put("answer", aid);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|