Skip to content

Commit

Permalink
#52: save selected properties in [moduledir]/data folder
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeFcosta committed Jan 27, 2023
1 parent e9b4f81 commit 1c3f5b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
19 changes: 11 additions & 8 deletions iped-app/src/main/java/iped/app/ui/ColumnsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ private static final File getGlobalColsFile() {

File moduleDir;
private File caseCols;
private File reportCols;

private static final String SELECTED_PROPERTIES_FILENAME = "data/reportProps.dat";

private File reportPropsFile;

String[] indexFields = null;

Expand Down Expand Up @@ -150,10 +153,10 @@ static class ColumnState implements Serializable {

protected void saveReportSelectedProps() {
try {
Set<String> reportProps = new HashSet<>();
reportProps.addAll(getSelectedProperties());
if (reportProps.size() > 0) {
Util.writeObject(reportProps, reportCols.getAbsolutePath());
Set<String> reportPropsSet = new HashSet<>();
reportPropsSet.addAll(getSelectedProperties());
if (reportPropsSet.size() > 0) {
Util.writeObject(reportPropsSet, reportPropsFile.getAbsolutePath());
}
} catch (Exception e1) {
e1.printStackTrace();
Expand Down Expand Up @@ -188,7 +191,7 @@ protected ColumnsManager() {
autoManageCols = analysisConfig.isAutoManageCols();

moduleDir = App.get().appCase.getAtomicSourceBySourceId(0).getModuleDir();
reportCols = new File(moduleDir, "reportCols.dat");
reportPropsFile = new File(moduleDir, SELECTED_PROPERTIES_FILENAME);

updateDinamicFields();

Expand Down Expand Up @@ -246,9 +249,9 @@ private void loadSavedCols() {
protected ArrayList<String> loadReportSelectedFields() {
Set<String> columnsReport = new HashSet<>();
ArrayList<String> selectedFields = null;
if (reportCols.exists()) {
if (reportPropsFile.exists()) {
try {
columnsReport = (Set<String>) Util.readObject(reportCols.getAbsolutePath());
columnsReport = (Set<String>) Util.readObject(reportPropsFile.getAbsolutePath());
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand Down Expand Up @@ -101,6 +100,8 @@ public class HTMLReportTask extends AbstractTask {
private static final String propNamePlaceHolder = "%PROPERTY_NAME%";
private static final String propValuePlaceHolder = "%PROPERTY_VALUE%";

private static final String SELECTED_PROPERTIES_FILENAME = "data/reportProps.dat";

private static final List<String> basicReportProps = Arrays.asList(BasicProps.NAME, BasicProps.PATH, BasicProps.TYPE, BasicProps.LENGTH,
BasicProps.CREATED, BasicProps.MODIFIED, BasicProps.ACCESSED, BasicProps.DELETED, BasicProps.CARVED,
BasicProps.HASH, IndexItem.ID_IN_SOURCE);
Expand Down Expand Up @@ -215,7 +216,7 @@ public List<Configurable<?>> getConfigurables() {
}

protected ArrayList<String> loadReportSelectedProps() {
File reportCols = new File(Configuration.getInstance().appRoot, "reportCols.dat");
File reportCols = new File(Configuration.getInstance().appRoot, SELECTED_PROPERTIES_FILENAME);

Set<String> columnsReport = new HashSet<>();
ArrayList<String> selectedFields = null;
Expand Down Expand Up @@ -401,8 +402,6 @@ protected void process(IItem evidence) throws Exception {
reg.path = evidence.getPath();

reg.evidenceId = evidence.getId();
// reg.evidenceId = ipedCase.getLuceneId(evidence.getId());
// reg.evidenceId = ipedCase.getLuceneId(new ItemId(0, evidence.getId()));

Set<String> categories = evidence.getCategorySet();
categories = categories.stream().map(c -> CategoryLocalization.getInstance().getLocalizedCategory(c.trim()))
Expand Down

0 comments on commit 1c3f5b7

Please sign in to comment.