mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 13:47:09 +00:00
Dev 0.9 (#774)
This commit is contained in:
@@ -3,6 +3,8 @@ package com.tencent.supersonic.headless.core.file;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -17,9 +19,9 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class FileHandlerImpl implements FileHandler {
|
||||
public static final String FILE_SPILT = File.separator;
|
||||
|
||||
private final LocalFileConfig localFileConfig;
|
||||
|
||||
public FileHandlerImpl(LocalFileConfig localFileConfig) {
|
||||
this.localFileConfig = localFileConfig;
|
||||
}
|
||||
@@ -31,8 +33,8 @@ public class FileHandlerImpl implements FileHandler {
|
||||
createDir(dictDirectoryBackup);
|
||||
}
|
||||
|
||||
String source = localFileConfig.getDictDirectoryLatest() + "/" + fileName;
|
||||
String target = dictDirectoryBackup + "/" + fileName;
|
||||
String source = localFileConfig.getDictDirectoryLatest() + FILE_SPILT + fileName;
|
||||
String target = dictDirectoryBackup + FILE_SPILT + fileName;
|
||||
Path sourcePath = Paths.get(source);
|
||||
Path targetPath = Paths.get(target);
|
||||
try {
|
||||
@@ -88,7 +90,7 @@ public class FileHandlerImpl implements FileHandler {
|
||||
if (!existPath(dictDirectoryLatest)) {
|
||||
createDir(dictDirectoryLatest);
|
||||
}
|
||||
String filePath = dictDirectoryLatest + "/" + fileName;
|
||||
String filePath = dictDirectoryLatest + FILE_SPILT + fileName;
|
||||
if (existPath(filePath)) {
|
||||
backupFile(fileName);
|
||||
}
|
||||
@@ -117,7 +119,7 @@ public class FileHandlerImpl implements FileHandler {
|
||||
@Override
|
||||
public Boolean deleteDictFile(String fileName) {
|
||||
backupFile(fileName);
|
||||
deleteFile(localFileConfig.getDictDirectoryLatest() + "/" + fileName);
|
||||
deleteFile(localFileConfig.getDictDirectoryLatest() + FILE_SPILT + fileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.tencent.supersonic.headless.core.file;
|
||||
|
||||
import com.tencent.supersonic.headless.core.knowledge.helper.HanlpHelper;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
@Slf4j
|
||||
@@ -18,16 +21,21 @@ public class LocalFileConfig {
|
||||
private String dictDirectoryBackup;
|
||||
|
||||
public String getDictDirectoryLatest() {
|
||||
return getResourceDir() + dictDirectoryLatest;
|
||||
return getDictDirectoryPrefixDir() + dictDirectoryLatest;
|
||||
}
|
||||
|
||||
public String getDictDirectoryBackup() {
|
||||
return getResourceDir() + dictDirectoryBackup;
|
||||
return getDictDirectoryPrefixDir() + dictDirectoryBackup;
|
||||
}
|
||||
|
||||
private String getResourceDir() {
|
||||
//return hanlpPropertiesPath = HanlpHelper.getHanlpPropertiesPath();
|
||||
return ClassLoader.getSystemClassLoader().getResource("").getPath();
|
||||
private String getDictDirectoryPrefixDir() {
|
||||
try {
|
||||
return HanlpHelper.getHanlpPropertiesPath();
|
||||
} catch (FileNotFoundException e) {
|
||||
log.warn("getDictDirectoryPrefixDir error: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
public class SysTimeDimensionBuilder {
|
||||
|
||||
public static void addSysTimeDimension(List<Dim> dims, DbAdaptor engineAdaptor) {
|
||||
log.info("addSysTimeDimension before:{}, engineAdaptor:{}", dims, engineAdaptor);
|
||||
log.debug("addSysTimeDimension before:{}, engineAdaptor:{}", dims, engineAdaptor);
|
||||
Dim timeDim = getTimeDim(dims);
|
||||
if (timeDim == null) {
|
||||
timeDim = Dim.getDefault();
|
||||
|
||||
Reference in New Issue
Block a user