package com.basic.security.manager.impl.cblite;
|
|
import android.text.TextUtils;
|
|
import com.basic.security.manager.impl.sqlite.SlIdentityManager;
|
import com.basic.security.utils.Constants;
|
import com.couchbase.lite.Expression;
|
import com.basic.security.model.ModelAdapter;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
public class IdentityManager extends BaseManager {
|
|
public static List<ModelAdapter> findIdentityList() {
|
if (Constants.useCouchbase) {
|
Expression expression = Expression.property("table").equalTo(Expression.string("identity"));
|
|
return findList(expression);
|
} else {
|
return SlIdentityManager.findIdentityList();
|
}
|
}
|
|
public static List<String> findIdentityNameListByPersonId(String personId) {
|
if (Constants.useCouchbase) {
|
List<String> identityNameList = new ArrayList();
|
List<ModelAdapter> personPersonIdentity = PersonIdentityManager.findPersonIdentityListByPersonId(personId);
|
for (ModelAdapter personIdentity : personPersonIdentity) {
|
String identityId = personIdentity.getString("identity_id");
|
ModelAdapter identityDocument = findById(identityId);
|
if (identityDocument != null) {
|
String identityName = identityDocument.getString("name");
|
if (!TextUtils.isEmpty(identityName)) {
|
identityNameList.add(identityName);
|
}
|
}
|
}
|
return identityNameList;
|
} else {
|
return SlIdentityManager.findIdentityNameListByPersonId(personId);
|
}
|
}
|
|
public static ModelAdapter findIdentityById(String id) {
|
if (Constants.useCouchbase) {
|
return BaseManager.findById(id);
|
} else {
|
return SlIdentityManager.findIdentityById(id);
|
}
|
}
|
}
|