Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
package com.ubt.jimu.transport.dao;
import android.text.TextUtils;
import android.util.Log;
import com.ubt.jimu.base.db.AbstractDaoHandler;
import com.ubt.jimu.base.db.DatabaseUtils;
import com.ubt.jimu.blockly.bean.BlocklyProject;
import com.ubt.jimu.blockly.bean.JimuMotion;
import com.ubt.jimu.blockly.bean.JimuSound;
import com.ubt.jimu.gen.ConfigItemDao;
import com.ubt.jimu.transport.model.ConfigItem;
import com.ubt.jimu.utils.SystemUtils;
import java.util.List;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.query.QueryBuilder;
/* loaded from: classes2.dex */
public class ConfigItemDbHandler extends AbstractDaoHandler<ConfigItem> {
private static ConfigItemDbHandler b;
private final String a;
public ConfigItemDbHandler(AbstractDao<ConfigItem, Long> abstractDao) {
super(abstractDao);
this.a = ConfigItemDbHandler.class.getSimpleName();
}
public static synchronized ConfigItemDbHandler getInstance() {
ConfigItemDbHandler configItemDbHandler;
synchronized (ConfigItemDbHandler.class) {
if (b == null) {
b = new ConfigItemDbHandler(DatabaseUtils.getDaoSession(true).b());
}
configItemDbHandler = b;
}
return configItemDbHandler;
}
public ConfigItem a(ConfigItem configItem) {
if (configItem == null) {
return null;
}
return a(configItem.getUserId(), configItem.getCustomModelId(), configItem.getType(), configItem.getFileName());
}
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
/* renamed from: b, reason: merged with bridge method [inline-methods] */
public ConfigItem selectUnique(ConfigItem configItem) {
if (configItem == null) {
return null;
}
try {
return a(configItem.getUserId(), configItem.getCustomModelId(), configItem.getType(), configItem.getFileName());
} catch (Exception e) {
e.printStackTrace();
Log.e(this.a, "ConfigItemDbHandler#selectUnique:" + e.getMessage());
return null;
}
}
public void c(ConfigItem configItem) {
configItem.setIsDeleted("1");
configItem.setIsModify(true);
configItem.setFileModifyTime(SystemUtils.a());
update(configItem);
}
public ConfigItem a(BlocklyProject blocklyProject) {
if (blocklyProject == null) {
return null;
}
return a(blocklyProject.getUserId(), blocklyProject.getCustomModelId(), blocklyProject.getBlocklyType(), blocklyProject.getXmlId());
}
public ConfigItem a(JimuSound jimuSound) {
if (jimuSound == null) {
return null;
}
return a(jimuSound.getUserId(), "0", "audio", jimuSound.getKey());
}
public ConfigItem a(JimuMotion jimuMotion) {
if (jimuMotion == null) {
return null;
}
return a(jimuMotion.getUserId(), jimuMotion.getCustomModelId(), ConfigItem.TYPE_MOTION, jimuMotion.getActionID());
}
private ConfigItem a(String str, String str2, String str3, String str4) {
QueryBuilder k = this.dao.k();
if (TextUtils.isEmpty(str2)) {
k.a(ConfigItemDao.Properties.UserId.a((Object) str), ConfigItemDao.Properties.Type.a((Object) str3), ConfigItemDao.Properties.FileName.a((Object) str4));
} else {
k.a(ConfigItemDao.Properties.UserId.a((Object) str), ConfigItemDao.Properties.Type.a((Object) str3), ConfigItemDao.Properties.CustomModelId.a((Object) str2), ConfigItemDao.Properties.FileName.a((Object) str4));
}
List<ConfigItem> b2 = k.b();
if (b2 == null || b2.size() == 0) {
return null;
}
if (b2.size() == 1) {
return (ConfigItem) b2.get(0);
}
for (ConfigItem configItem : b2) {
if (!"1".equals(configItem.getIsDeleted())) {
return configItem;
}
}
return (ConfigItem) b2.get(0);
}
}

View File

@@ -0,0 +1,279 @@
package com.ubt.jimu.transport.dao;
import android.text.TextUtils;
import android.util.Log;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.base.db.AbstractDaoHandler;
import com.ubt.jimu.base.db.diy.DiyDBModel;
import com.ubt.jimu.diy.DiyRobotDbHandler;
import com.ubt.jimu.gen.TransportFileDao;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.unity.ModelType;
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
import com.ubt.jimu.utils.SystemUtils;
import com.ubtech.utils.FileHelper;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.query.QueryBuilder;
import org.greenrobot.greendao.query.WhereCondition;
/* loaded from: classes2.dex */
public class TransportFileDbHandler extends AbstractDaoHandler<TransportFile> {
private static final String TAG = "TransportFileDbHandler";
public TransportFileDbHandler(AbstractDao<TransportFile, Long> abstractDao) {
super(abstractDao);
}
public static File getFile(TransportFile transportFile) {
return new File(DiyRobotDbHandler.getUserHome(transportFile.getUserId()) + transportFile.getFilePath() + File.separator + transportFile.getFileName());
}
public static String getFilePath(File file) {
if (file == null) {
return null;
}
String str = ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + "users" + File.separator;
String absolutePath = file.getAbsolutePath();
String name = file.getName();
String replace = absolutePath.replace(str, "");
return replace.substring(replace.indexOf(File.separator) + 1).replace(File.separator + name, "");
}
public void deleteModelFiles(String str, String str2) {
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) str), TransportFileDao.Properties.CustomModelId.a((Object) str2));
List b = k.b();
if (b != null && b.size() > 0) {
deleteInTx(b);
}
File file = new File(DiyRobotDbHandler.getCustomModelPath(str) + str2);
if (file.exists()) {
FileHelper.a(file);
}
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#deleteModelFiles:" + e.getMessage());
e.printStackTrace();
}
}
public boolean deleteTransportFile(TransportFile transportFile) {
if (transportFile == null) {
return false;
}
TransportFile transportFile2 = null;
String userId = Cache.getInstance().getUserId();
if (TextUtils.isEmpty(userId)) {
userId = "local";
}
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FileName.a((Object) (transportFile.getFileName() + "")), TransportFileDao.Properties.CustomModelId.a((Object) transportFile.getCustomModelId()), TransportFileDao.Properties.FileType.a((Object) transportFile.getFileType()));
transportFile2 = (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
}
if (transportFile2 == null) {
return false;
}
File file = new File(transportFile.getFilePath());
if (file.exists()) {
file.delete();
}
this.dao.b((AbstractDao<T, Long>) transportFile2);
return true;
}
public TransportFile getFileBean(String str, File file) {
if (file == null) {
return null;
}
String filePath = getFilePath(file);
String name = file.getName();
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) str), TransportFileDao.Properties.FilePath.a((Object) filePath), TransportFileDao.Properties.FileName.a((Object) name));
return (TransportFile) k.c();
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#getFileBean():" + e.getMessage());
e.printStackTrace();
return null;
}
}
public List<TransportFile> getFiles(String str) {
List<TransportFile> list;
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) str), new WhereCondition[0]);
list = k.b();
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#getFiles(String):" + e.getMessage());
e.printStackTrace();
list = null;
}
return list == null ? new ArrayList() : list;
}
public long insertOrUpdate2(TransportFile transportFile) {
TransportFile selectUnique = selectUnique(transportFile);
if (selectUnique == null) {
return insert(transportFile);
}
transportFile.setCustomFileId(selectUnique.getCustomFileId());
update(transportFile);
return selectUnique.getCustomFileId().longValue();
}
public boolean isFirstUpload(String str, boolean z) {
TransportFile transportFile;
String userId = Cache.getInstance().getUserId();
if (TextUtils.isEmpty(userId)) {
userId = "local";
}
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FilePath.a((Object) str));
transportFile = (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
transportFile = null;
}
if (transportFile == null) {
return false;
}
if (z) {
transportFile.setId(1L);
} else {
transportFile.setId(0L);
}
update(transportFile);
return true;
}
public void setFileModelId(DiyDBModel diyDBModel) {
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) diyDBModel.getModelCreatedId()), TransportFileDao.Properties.CustomModelId.a((Object) diyDBModel.getCustomModelId()));
List b = k.b();
if (b == null || b.size() <= 0) {
return;
}
Iterator it = b.iterator();
while (it.hasNext()) {
((TransportFile) it.next()).setModelId(diyDBModel.getModelId().intValue());
}
updateInTx(b);
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#setFileModelId:" + e.getMessage());
e.printStackTrace();
}
}
public List<TransportFile> setModelFilesDeleted(String str, String str2) {
List<TransportFile> files = getFiles(str, str2);
long a = SystemUtils.a();
for (TransportFile transportFile : files) {
transportFile.setIsDeleted(true);
transportFile.setModifyTime(a);
transportFile.setLastUploadTime(a);
transportFile.setIsModify(true);
}
try {
updateInTx(files);
} catch (Exception e) {
e.printStackTrace();
}
return files;
}
public boolean updataTransportFile(TransportFile transportFile) {
TransportFile selectUnique;
if (transportFile == null || (selectUnique = selectUnique(transportFile)) == null) {
return false;
}
transportFile.setCustomFileId(selectUnique.getCustomFileId());
update(transportFile);
return true;
}
public boolean updateQiNiuState(String str, boolean z) {
TransportFile transportFile;
String userId = Cache.getInstance().getUserId();
if (TextUtils.isEmpty(userId)) {
userId = "local";
}
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FilePath.a((Object) str));
transportFile = (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
transportFile = null;
}
if (transportFile == null) {
return false;
}
transportFile.setUploaded(z);
update(transportFile);
return true;
}
public boolean updateUbtSyncState(String str, boolean z) {
TransportFile transportFile;
String userId = Cache.getInstance().getUserId();
if (TextUtils.isEmpty(userId)) {
userId = "local";
}
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FilePath.a((Object) str));
transportFile = (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
transportFile = null;
}
if (transportFile == null) {
return false;
}
transportFile.setIsModify(z);
update(transportFile);
return true;
}
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
public TransportFile selectUnique(TransportFile transportFile) {
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) transportFile.getUserId()), TransportFileDao.Properties.CustomModelId.a((Object) transportFile.getCustomModelId()), TransportFileDao.Properties.FileType.a((Object) transportFile.getFileType()), TransportFileDao.Properties.FileName.a((Object) transportFile.getFileName()));
return (TransportFile) k.c();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "TransportFile selectUnique: " + e.getMessage());
return null;
}
}
public List<TransportFile> getFiles(String str, String str2) {
List<TransportFile> list;
try {
QueryBuilder k = this.dao.k();
k.a(TransportFileDao.Properties.UserId.a((Object) str), TransportFileDao.Properties.CustomModelId.a((Object) str2));
list = k.b();
} catch (Exception e) {
Log.e(TAG, "TransportFileDbHandler#getFiles(String,String):" + e.getMessage());
e.printStackTrace();
list = null;
}
return list == null ? new ArrayList() : list;
}
}