|
|
|
@ -3,11 +3,13 @@ package com.fr.plugin.decision.request.handler;
|
|
|
|
|
import com.finebi.activate.foundation.StableManager; |
|
|
|
|
import com.finebi.burger.api.bean.configuration.table.attachment.FineAttachment; |
|
|
|
|
import com.finebi.burger.api.bean.configuration.table.field.FineBusinessField; |
|
|
|
|
import com.finebi.burger.api.request.configuration.table.DataBaseAddTableItemRequestBean; |
|
|
|
|
import com.finebi.burger.api.request.configuration.table.DataBaseAddTableRequestBean; |
|
|
|
|
import com.finebi.burger.api.response.configuration.table.TableAddResponseBean; |
|
|
|
|
import com.finebi.common.impl.vo.table.FineDBBusinessTable; |
|
|
|
|
import com.finebi.direct.burger.api.service.FineTableService; |
|
|
|
|
import com.finebi.direct.burger.impl.service.helper.table.FineTableUtils; |
|
|
|
|
import com.finebi.direct.common.authority.api.FineAuthorityUtils; |
|
|
|
|
import com.finebi.direct.burger.api.service.FineUserInfoService; |
|
|
|
|
import com.finebi.direct.common.api.cell.user.authority.UserAuthority; |
|
|
|
|
import com.finebi.foundation.api.reponse.FineRespond; |
|
|
|
|
import com.finebi.foundation.api.service.FineService; |
|
|
|
|
import com.finebi.foundation.api.service.context.BaseContext; |
|
|
|
@ -33,7 +35,6 @@ import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import com.finebi.direct.common.api.cell.context.CellCreator; |
|
|
|
|
import com.finebi.common.impl.vo.table.FineBusinessTable; |
|
|
|
|
import com.finebi.common.impl.vo.table.FineExcelBusinessTable; |
|
|
|
|
import com.finebi.direct.common.authority.decision.role.FineAuthorityUser; |
|
|
|
|
import com.fr.web.utils.WebUtils; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
@ -138,6 +139,7 @@ public class UpgradeHandler extends HWAbstractHandler {
|
|
|
|
|
if (StringUtils.equals("success", dmlResult.getString("status")) && dmlResult.getBoolean("addLink")) { |
|
|
|
|
ExcelLinkService.getInstance().addLink(name, connection, schema, tableName, createUser); |
|
|
|
|
FineLoggerFactory.getLogger().info("HW_excel导入:FineDB 新增数据成功" + name); |
|
|
|
|
CellCreator.getCellProvider().tableCell().removeTable(fineBusinessTable.getName(), CellCreator.getCellProvider().userCellProvider().authorityCell().getSuperAuthority()); |
|
|
|
|
} |
|
|
|
|
} catch(Exception e){ |
|
|
|
|
e.printStackTrace(); |
|
|
|
@ -148,11 +150,11 @@ public class UpgradeHandler extends HWAbstractHandler {
|
|
|
|
|
JSONArray tables = JSONArray.create().put(table); |
|
|
|
|
JSONObject tablesBean = JSONObject.create().put("tables", tables); |
|
|
|
|
try{ |
|
|
|
|
FineAuthorityUser authorityUser = FineAuthorityUtils.getAuth(req); |
|
|
|
|
String packid = "__my_analysis__" + authorityUser.getUserId() + "1"; |
|
|
|
|
UserAuthority authorityUser = getFineUserInfoService().getUserAuthority(req); |
|
|
|
|
String packid = "__my_analysis__" + authorityUser.getUser().getInfo().getUserId() + "1"; |
|
|
|
|
try { |
|
|
|
|
String tableString = tablesBean.toString(); |
|
|
|
|
FineBusinessTable[] businessTables = FineTableUtils.createBusinessTablesFromDBNewAddTableInfo(mapper.readValue(tableString, DataBaseAddTableRequestBean.class), authorityUser.getUserId()); |
|
|
|
|
FineBusinessTable[] businessTables = createBusinessTablesFromDBNewAddTableInfo(mapper.readValue(tableString, DataBaseAddTableRequestBean.class), authorityUser.getUser().getInfo().getUserId()); |
|
|
|
|
TableAddResponseBean responed = getTableService().addNewTable(packid, authorityUser, businessTables); |
|
|
|
|
addDbResult.put(FineRespond.success(responed)); |
|
|
|
|
} catch (JsonMappingException e) { |
|
|
|
@ -202,4 +204,41 @@ public class UpgradeHandler extends HWAbstractHandler {
|
|
|
|
|
} |
|
|
|
|
return 12; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static FineBusinessTable[] createBusinessTablesFromDBNewAddTableInfo(DataBaseAddTableRequestBean bean, String userId) { |
|
|
|
|
List<DataBaseAddTableItemRequestBean> items = bean.getTables(); |
|
|
|
|
FineBusinessTable[] businessTables = new FineBusinessTable[items.size()]; |
|
|
|
|
for (int i = 0; i < businessTables.length; i++) { |
|
|
|
|
DataBaseAddTableItemRequestBean item = items.get(i); |
|
|
|
|
FineBusinessTable table = createBusinessTableByItem(item, userId); |
|
|
|
|
businessTables[i] = table; |
|
|
|
|
} |
|
|
|
|
return businessTables; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static FineBusinessTable createBusinessTableByItem(DataBaseAddTableItemRequestBean item, String userId) { |
|
|
|
|
|
|
|
|
|
return createDBBusinessTable(item, userId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static FineBusinessTable createDBBusinessTable(DataBaseAddTableItemRequestBean item, String userId) { |
|
|
|
|
FineDBBusinessTable table = new FineDBBusinessTable(); |
|
|
|
|
table.setConnectionName(item.getConnectionName()); |
|
|
|
|
table.setTableName(item.getDbTableName()); |
|
|
|
|
table.setCreateByWithId(userId); |
|
|
|
|
String tableName = getTableNameWithConnection(item); |
|
|
|
|
table.setId(tableName); |
|
|
|
|
table.setName(tableName); |
|
|
|
|
return table; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static String getTableNameWithConnection(DataBaseAddTableItemRequestBean itemBean) { |
|
|
|
|
// return com.finebi.utils.StringUtils.join("_", itemBean.getConnectionName(), itemBean.getDbTableName());
|
|
|
|
|
return itemBean.getDbTableName(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected static FineUserInfoService getFineUserInfoService() { |
|
|
|
|
return getBean(FineUserInfoService.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|