2021-01-02 16:15:27 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2012 IT Just working.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IT Just working - initial API and implementation
|
|
|
|
*******************************************************************************/
|
|
|
|
package com.minres.scviewer.database.text;
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.List;
|
2021-01-03 14:16:56 +01:00
|
|
|
import java.util.NavigableMap;
|
2021-01-07 17:38:29 +01:00
|
|
|
import java.util.Set;
|
2021-01-03 14:16:56 +01:00
|
|
|
import java.util.stream.Collectors;
|
2021-01-02 16:15:27 +01:00
|
|
|
|
2021-01-03 14:16:56 +01:00
|
|
|
import com.minres.scviewer.database.IWaveform;
|
2021-01-02 16:15:27 +01:00
|
|
|
import com.minres.scviewer.database.tx.ITx;
|
|
|
|
import com.minres.scviewer.database.tx.ITxAttribute;
|
|
|
|
import com.minres.scviewer.database.tx.ITxGenerator;
|
|
|
|
import com.minres.scviewer.database.tx.ITxRelation;
|
|
|
|
|
2021-01-03 14:16:56 +01:00
|
|
|
class Tx implements ITx {
|
2021-01-02 16:15:27 +01:00
|
|
|
|
2021-01-03 14:16:56 +01:00
|
|
|
private final TextDbLoader loader;
|
2021-01-02 16:15:27 +01:00
|
|
|
|
2021-01-03 14:16:56 +01:00
|
|
|
private ScvTx scvTx = null;
|
2021-01-02 16:15:27 +01:00
|
|
|
|
|
|
|
private int concurrencyIndex;
|
2021-01-07 17:38:29 +01:00
|
|
|
|
|
|
|
public Tx(TextDbLoader loader, ScvTx scvTx) {
|
2021-01-03 14:16:56 +01:00
|
|
|
this.loader=loader;
|
2021-01-07 17:38:29 +01:00
|
|
|
this.scvTx = scvTx;
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
2021-01-07 17:38:29 +01:00
|
|
|
|
2021-01-02 16:15:27 +01:00
|
|
|
@Override
|
|
|
|
public Collection<ITxRelation> getIncomingRelations() {
|
2021-01-07 17:38:29 +01:00
|
|
|
Set<ScvRelation> rels = loader.relationsIn.get(scvTx.getId());
|
|
|
|
return rels.stream().map(rel -> new TxRelation(loader, rel)).collect(Collectors.toList());
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Collection<ITxRelation> getOutgoingRelations() {
|
2021-01-07 17:38:29 +01:00
|
|
|
Set<ScvRelation> rels = loader.relationsOut.get(scvTx.getId());
|
|
|
|
return rels.stream().map(rel -> new TxRelation(loader, rel)).collect(Collectors.toList());
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int compareTo(ITx o) {
|
2021-01-03 14:16:56 +01:00
|
|
|
int res =getBeginTime().compareTo(o.getBeginTime());
|
2021-01-02 16:15:27 +01:00
|
|
|
if(res!=0)
|
|
|
|
return res;
|
|
|
|
else
|
2021-01-03 14:16:56 +01:00
|
|
|
return getId().compareTo(o.getId());
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
|
|
|
|
2021-01-07 17:38:29 +01:00
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) return true;
|
|
|
|
if (obj == null || getClass() != obj.getClass()) return false;
|
|
|
|
return this.scvTx.equals(((Tx) obj).scvTx);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return scvTx.hashCode();
|
|
|
|
}
|
|
|
|
|
2021-01-02 16:15:27 +01:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Long getId() {
|
2021-01-03 14:16:56 +01:00
|
|
|
return scvTx.id;
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IWaveform getStream() {
|
2021-01-03 14:16:56 +01:00
|
|
|
return loader.txStreams.get(scvTx.streamId);
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ITxGenerator getGenerator() {
|
2021-01-03 14:16:56 +01:00
|
|
|
return loader.txGenerators.get(scvTx.generatorId);
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Long getBeginTime() {
|
2021-01-03 14:16:56 +01:00
|
|
|
return scvTx.beginTime;
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Long getEndTime() {
|
2021-01-03 14:16:56 +01:00
|
|
|
return scvTx.endTime;
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
|
|
|
|
2021-01-07 17:38:29 +01:00
|
|
|
void setEndTime(Long time) {
|
|
|
|
scvTx.endTime=time;
|
|
|
|
}
|
|
|
|
|
2021-01-02 16:15:27 +01:00
|
|
|
@Override
|
|
|
|
public int getConcurrencyIndex() {
|
|
|
|
return concurrencyIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setConcurrencyIndex(int idx) {
|
|
|
|
concurrencyIndex=idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<ITxAttribute> getAttributes() {
|
2021-01-03 14:16:56 +01:00
|
|
|
return scvTx.attributes;
|
2021-01-02 16:15:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|