Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions src/firefly/html/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,7 @@
display: inline-block;
position: relative;
text-shadow: 0 1px 0 #fff;
width: 12px;
height: 14px;
}
.btn-close:hover {
background-color: #949494;
border-radius: 50%;
cursor: pointer;
}
.btn-close:after {
content: '×'; /* UTF-8 symbol */
}

.btn-close {
color: #666;
font-size: 10px;
display: inline-block;
position: relative;
text-shadow: 0 1px 0 #fff;
width: 12px;
width: 14px;
height: 14px;
}
.btn-close:hover {
Expand All @@ -267,6 +249,10 @@
}
.btn-close:after {
content: '×'; /* UTF-8 symbol */
left: 50%;
position: absolute;
transform: translate(-50%, 0);
font-weight: bold;
}

/*-------------------< loading mask ---------------------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class TableServerRequest extends ServerRequest implements Serializable, DataEntry, Cloneable {

public static final String DECIMATE_INFO = "decimate";
public static final String TBL_FILE_PATH = "tblFilePath";
public static final String TBL_ID = "tbl_id";
public static final String TITLE = "tbl_table";
public static final String FILTERS = "filters";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public DataGroupPart getData(ServerRequest sr) throws DataAccessException {
dgFile = postProcessData(dgFile, request);
page = IpacTableParser.getData(dgFile, request.getStartIndex(), request.getPageSize());
page.getTableDef().ensureStatus(); // make sure there's a status line so
page.getTableDef().setSource(ServerContext.replaceWithPrefix(dgFile)); // set table meta source to file it came from.
page.getTableDef().setAttribute(TableServerRequest.TBL_FILE_PATH, ServerContext.replaceWithPrefix(dgFile)); // set table's meta tblFilePath to the file it came from.
} catch (Exception e) {
LOGGER.error(e, "Fail to parse ipac table file: " + dgFile);
throw e;
Expand Down Expand Up @@ -243,54 +243,43 @@ public void onComplete(ServerRequest request, DataGroupPart results) throws Data
}

public String getUniqueID(ServerRequest request) {

String uid = request.getRequestId() + "-";
if ( useWorkspace || (isSecurityAware() &&
ServerContext.getRequestOwner().isAuthUser()) ) {
uid = uid + ServerContext.getRequestOwner().getUserKey();
}

// parameters to get original data (before filter, sort, etc.)
List<Param> srvParams = new ArrayList<>();
for (Param p : request.getParams()) {
if (!SYS_PARAMS.contains("|" + p.getName() + "|")) {
srvParams.add(p);
}
}

// sort by parameter name
Collections.sort(srvParams, (p1, p2) -> p1.getName().compareTo(p2.getName()));

for (Param p : srvParams) {
uid += "|" + p.toString();
}

return uid;
return createUniqueId(request.getRequestId(), srvParams);
}

// unique key without page info
public String getDataKey(ServerRequest request) {

String uid = request.getRequestId() + "-";
List<Param> srvParams = new ArrayList<>();
for (Param p : request.getParams()) {
if (!SYS_PARAMS.contains("|" + p.getName() + "|") &&
!PAGE_PARAMS.contains(p.getName())) {
srvParams.add(p);
}
}
return createUniqueId(request.getRequestId(), srvParams);
}

private String createUniqueId(String reqId, List<Param> params) {
String uid = reqId + "-";
if ( useWorkspace || (isSecurityAware() &&
ServerContext.getRequestOwner().isAuthUser()) ) {
uid = uid + ServerContext.getRequestOwner().getUserKey();
}

/*
java.util.Collections.sort(request.getParams(), new Comparator<Param>(){
@Override
public int compare(Param o1, Param o2) {
return o1.getName().compareTo(o2.getName());
}
});
*/
// sort by parameter name
Collections.sort(params, (p1, p2) -> p1.getName().compareTo(p2.getName()));

for (Param p : request.getParams()) {
if (!PAGE_PARAMS.contains(p.getName())) {
uid += "|" + p.toString();
}
for (Param p : params) {
uid += "|" + p.toString();
}

return uid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,7 @@ public void start() throws IOException {

writer = new PrintWriter(new BufferedWriter(new FileWriter(this.outf), IpacTableUtil.FILE_IO_BUFFER_SIZE));

// combine meta with file attributes
ArrayList<DataGroup.Attribute> attributes = new ArrayList<>(source.getKeywords());
if (meta == null) {
meta = new HashMap<>(attributes.size());
} else {
for (String k : meta.keySet()) {
attributes.add(new DataGroup.Attribute(k, meta.get(k)));
}
}
for (DataGroup.Attribute at : attributes) {
meta.put(at.getKey(), at.getValue());
}


writeStatus(writer, DataGroupPart.State.INPROGRESS);
IpacTableUtil.writeAttributes(writer, attributes, DataGroupPart.LOADING_STATUS);
List<DataType> headers = Arrays.asList(source.getDataDefinitions());
Expand All @@ -118,7 +105,9 @@ private void close() {
insertStatus(outf, DataGroupPart.State.COMPLETED);
writer.flush();
writer.close();
IpacTableUtil.sendLoadStatusEvents(meta, outf, rowCount, DataGroupPart.State.COMPLETED);
if (meta != null) {
IpacTableUtil.sendLoadStatusEvents(meta, outf, rowCount, DataGroupPart.State.COMPLETED);
}
}
}
}
Expand All @@ -130,8 +119,10 @@ public void run() {
while(itr.hasNext()) {
DataObject row = itr.next();
IpacTableUtil.writeRow(writer, headers, row);
if (++rowCount % 5000 == 0) {
IpacTableUtil.sendLoadStatusEvents(meta, outf, rowCount, DataGroupPart.State.INPROGRESS);
if (meta != null) {
if (++rowCount % 5000 == 0) {
IpacTableUtil.sendLoadStatusEvents(meta, outf, rowCount, DataGroupPart.State.INPROGRESS);
}
}
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class JsonTableUtil {
*/
public static JSONObject toJsonTableModel(DataGroupPart page, TableServerRequest request) throws IOException {

TableDef meta = page.getTableDef();
TableDef meta = page.getTableDef().clone();
if (request != null && request.getMeta() != null) {
for (String key : request.getMeta().keySet()) {
meta.setAttribute(key, request.getMeta(key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,11 @@ public void setMetaTo(TableMeta meta) {
if (contains("fileSize")) {
meta.setFileSize(Long.parseLong(getAttribute("fileSize").getValue()));
}
if (getSource() != null) {
meta.setSource(getSource());
}
meta.setIsLoaded(Boolean.parseBoolean(getAttribute("isFullyLoaded").getValue()));
for (String key : meta.getAttributes().keySet()) {
setAttribute(key, meta.getAttribute(key));
if (!key.equals("source")) {
setAttribute(key, meta.getAttribute(key));
}
}
}

Expand All @@ -144,14 +143,23 @@ public void getMetaFrom(TableMeta meta) {
if (meta.getFileSize() > 0) {
setAttribute("fileSize", String.valueOf( meta.getFileSize()) );
}
if (meta.getSource() != null) {
setSource(meta.getSource());
}
setAttribute("isFullyLoaded", String.valueOf(meta.isLoaded()));
for (String key : meta.getAttributes().keySet()) {
setAttribute(key, meta.getAttribute(key));
if (!key.equals("source")) {
setAttribute(key, meta.getAttribute(key));
}
}
}
public TableDef clone() {
TableDef copy = new TableDef();
copy.cols = new ArrayList<>(cols);
copy.attributes = new HashMap<>(attributes);
copy.lineWidth = lineWidth;
copy.rowCount = rowCount;
copy.rowStartOffset = rowStartOffset;
copy.lineSepLength = lineSepLength;
return copy;
}
}
/*
* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE CALIFORNIA
Expand Down
3 changes: 0 additions & 3 deletions src/firefly/java/edu/caltech/ipac/util/IpacTableUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,11 @@ public static TableDef getMetaInfo(BufferedReader reader, File src) throws IOExc
public static void sendLoadStatusEvents(Map<String,String> meta, File outf, int crows, DataGroupPart.State state) {
if (meta == null || StringUtils.isEmpty(meta.get("tbl_id"))) return;

String source = ServerContext.replaceWithPrefix(outf);
String tblId = String.valueOf( meta.get("tbl_id") );

FluxAction action = new FluxAction("table.update");
action.setValue(tblId, "tbl_id");
action.setValue(crows, "totalRows");
action.setValue(state.name(), "tableMeta", DataGroupPart.LOADING_STATUS);
action.setValue(source, "tableMeta", "source");
ServerEventManager.fireAction(action);
}

Expand Down
4 changes: 2 additions & 2 deletions src/firefly/js/charts/HistogramCntlr.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const loadColData = function(rawAction) {
return (dispatch) => {

const {chartId, histogramParams, tblId} = rawAction.payload;
const tblSource = get(getTblById(tblId), 'tableMeta.source');
const tblSource = get(getTblById(tblId), 'tableMeta.tblFilePath');

const chartModel = get(getChartSpace(HISTOGRAM), chartId);
let serverCallNeeded = !chartModel || !chartModel.tblSource || chartModel.tblSource !== tblSource;
Expand Down Expand Up @@ -186,7 +186,7 @@ function fetchColData(dispatch, tblId, histogramParams, chartId) {

const activeTableModel = getTblById(tblId);
const activeTableServerRequest = activeTableModel['request'];
const tblSource = get(activeTableModel, 'tableMeta.source');
const tblSource = get(activeTableModel, 'tableMeta.tblFilePath');

const sreq = Object.assign({}, omit(activeTableServerRequest, ['tbl_id', 'META_INFO']),
{'startIdx' : 0, 'pageSize' : 1000000});
Expand Down
4 changes: 2 additions & 2 deletions src/firefly/js/charts/XYPlotCntlr.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function loadPlotData (rawAction) {
return (dispatch) => {
let xyPlotParams = rawAction.payload.xyPlotParams;
const {chartId, tblId} = rawAction.payload;
const tblSource = get(getTblById(tblId), 'tableMeta.source');
const tblSource = get(getTblById(tblId), 'tableMeta.tblFilePath');

const chartModel = get(getChartSpace(SCATTER), chartId);
let serverCallNeeded = !chartModel || !chartModel.tblSource || chartModel.tblSource !== tblSource;
Expand Down Expand Up @@ -303,7 +303,7 @@ function fetchPlotData(dispatch, tblId, xyPlotParams, chartId) {

const activeTableModel = getTblById(tblId);
const activeTableServerRequest = activeTableModel['request'];
const tblSource = get(activeTableModel, 'tableMeta.source');
const tblSource = get(activeTableModel, 'tableMeta.tblFilePath');

if (!xyPlotParams) { xyPlotParams = getDefaultXYPlotParams(tblId); }

Expand Down
Loading