jimu-decompiled/sources/com/ubt/jimu/transport3/upgrade/DiyModelActionUpgrade.java
2025-05-13 19:24:51 +02:00

72 lines
3.3 KiB
Java

package com.ubt.jimu.transport3.upgrade;
import android.text.TextUtils;
import com.ubt.jimu.gen.TransportFileDao;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.transport3.dao.DiyModelActionDBHandler;
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
import com.ubt.jimu.transport3.model.DiyModelAction;
import com.ubt.jimu.utils.SystemUtils;
import com.ubtrobot.log.ALog;
import java.util.ArrayList;
import java.util.List;
import org.greenrobot.greendao.query.QueryBuilder;
/* loaded from: classes2.dex */
public class DiyModelActionUpgrade {
private final String TAG = "upgrade";
private final String REG_LIKE_ACTION = "%actions%";
private TransportFileDbHandler2 fileDbHandler = TransportFileDbHandler2.getInstance();
private DiyModelActionDBHandler actionDbHandler = DiyModelActionDBHandler.getInstance();
private DiyModelAction fromTransportFile(TransportFile transportFile) {
DiyModelAction diyModelAction = new DiyModelAction();
diyModelAction.setUserId(transportFile.getUserId());
diyModelAction.setModelId(Integer.parseInt(String.valueOf(transportFile.getModelId())));
diyModelAction.setCustomModelId(transportFile.getCustomModelId());
diyModelAction.setModelType(Integer.parseInt(transportFile.getModelType()));
diyModelAction.setFileUrl(transportFile.getFileUrl());
diyModelAction.setFileName(transportFile.getFileName());
diyModelAction.setServerId(0L);
diyModelAction.setUploaded(false);
diyModelAction.setModify(true);
long a = SystemUtils.a();
diyModelAction.setCreateTime(a);
diyModelAction.setModifyTime(a);
diyModelAction.setLastUploadTime(a);
diyModelAction.setIsDeleted(transportFile.getIsDeleted() ? 1 : 0);
String filePath = transportFile.getFilePath();
if (!TextUtils.isEmpty(filePath)) {
int indexOf = filePath.indexOf("/");
int lastIndexOf = filePath.lastIndexOf("/");
int i = indexOf + 1;
if (i <= lastIndexOf) {
diyModelAction.setCustomModelId(filePath.substring(i, lastIndexOf));
}
}
return diyModelAction;
}
public void upgrade() {
try {
QueryBuilder<TransportFile> queryBuilder = this.fileDbHandler.getQueryBuilder();
queryBuilder.a(TransportFileDao.Properties.FileName.a("%actions%"), TransportFileDao.Properties.FilePath.a("%actions%"));
List<TransportFile> query = this.fileDbHandler.query(queryBuilder);
if (query != null && query.size() != 0) {
ArrayList arrayList = new ArrayList();
for (TransportFile transportFile : query) {
if (!transportFile.getIsDeleted()) {
DiyModelAction fromTransportFile = fromTransportFile(transportFile);
arrayList.add(fromTransportFile);
ALog.a("upgrade").d("DiyModelAction: " + fromTransportFile.getUserId() + fromTransportFile.getCustomModelId() + " " + fromTransportFile.getFileName());
}
}
this.actionDbHandler.insertInTx(arrayList);
this.fileDbHandler.deleteInTx(query);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}