RapidClipseX、MicroStreamDB:如何将 MicroStream Table 分配给 RapidClipseX 网格?

RapidClipseX, MicroStreamDB: How to assign MicroStream Table to RapidClipseX Grid?

我尝试使用 RapidClipseX 和 MicroStreamDB。 我生成了一个存储,在不同的 table 对象中导入了不同的数据。 现在我想读取数据并在 RapidClipseX 网格组件中将其可视化。

通过使用 MicroStreamDB,我没有像在休眠中那样的 DAO 对象。 我仍然不知道该怎么做。 RapidClipseX 文档中也没有可用的示例,Microstream 文档中也没有。

我尝试使用以下作业,它仍然填满了网格。 但它用大约 6000 行填充网格,这仍然是 table 中的行数。但是每一行的内容都是一样的,仍然是db-table中最后保存的一行。 (我仍然通过文本编辑器检查 MicrostreamDB 是否存储了正确的数据。--> 是的)

private void grid_onAttach(final AttachEvent event)
{
    final dataRoot               root    = dbHandler.getRoot();
    this.grid.setDataProvider(DataProvider.ofCollection(root.getAllUmsClassifications()));
}

这是我用过的 class table:

package com.opaheinz.rcx_test.dbmodel;
import static javax.persistence.GenerationType.IDENTITY;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import com.rapidclipse.framework.server.resources.Caption;

/**
 * msTUmsatzClassification
 */
public class msTUmsatzClassification
{
    private Integer id;
    private Integer UId;
    private Integer pos;
    private Integer l2Id;
    private Integer l3Id;
    private Integer l1Id;
    private String  rule;
    private Date    datum;
    private double  sbetrag;
    private double  dbetrag;
    private Integer fixedCosts;


@Caption("Id")
@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "id", unique = true, nullable = false, columnDefinition = "INTEGER")
public Integer getId()
{
    return this.id;
}

public void setId(final Integer id)
{
    this.id = id;
}

@Caption("UId")
@Column(name = "u_id", nullable = false, columnDefinition = "INTEGER")
public Integer getUId()
{
    return this.UId;
}

public void setUId(final Integer UId)
{
    this.UId = UId;
}

@Caption("Pos")
@Column(name = "pos", nullable = false, columnDefinition = "INTEGER")
public Integer getPos()
{
    return this.pos;
}

public void setPos(final Integer pos)
{
    this.pos = pos;
}

@Caption("L2Id")
@Column(name = "L2_id", columnDefinition = "INTEGER")
public Integer getL2Id()
{
    return this.l2Id;
}

public void setL2Id(final Integer l2Id)
{
    this.l2Id = l2Id;
}

@Caption("L3Id")
@Column(name = "L3_id", columnDefinition = "INTEGER")
public Integer getL3Id()
{
    return this.l3Id;
}

public void setL3Id(final Integer l3Id)
{
    this.l3Id = l3Id;
}

@Caption("L1Id")
@Column(name = "L1_id", nullable = false, columnDefinition = "INTEGER")
public Integer getL1Id()
{
    return this.l1Id;
}

public void setL1Id(final Integer l1Id)
{
    this.l1Id = l1Id;
}

@Caption("Rule")
@Column(name = "rule", nullable = false, columnDefinition = "VARCHAR", length = 100)
public String getRule()
{
    return this.rule;
}

public void setRule(final String rule)
{
    this.rule = rule;
}

@Caption("Datum")
@Temporal(TemporalType.DATE)
@Column(name = "datum", nullable = false, columnDefinition = "DATE", length = 10)
public Date getDatum()
{
    return this.datum;
}

public void setDatum(final Date datum)
{
    this.datum = datum;
}

@Caption("Sbetrag")
@Column(name = "sBetrag", nullable = false, columnDefinition = "DOUBLE", precision = 22, scale = 0)
public double getSbetrag()
{
    return this.sbetrag;
}

public void setSbetrag(final double sbetrag)
{
    this.sbetrag = sbetrag;
}

@Caption("Dbetrag")
@Column(name = "dBetrag", nullable = false, columnDefinition = "DOUBLE", precision = 22, scale = 0)
public double getDbetrag()
{
    return this.dbetrag;
}

public void setDbetrag(final double dbetrag)
{
    this.dbetrag = dbetrag;
}

@Caption("FixedCosts")
@Column(name = "fixedCosts", columnDefinition = "INTEGER")
public Integer getFixedCosts()
{
    return this.fixedCosts;
}

public void setFixedCosts(final Integer fixedCosts)
{
    this.fixedCosts = fixedCosts;
}
}

以下代码是我的数据根:

package com.opaheinz.rcx_test.dbstorage;
import java.util.ArrayList;
import java.util.List;
import com.opaheinz.rcx_test.dbmodel.msTCabinet;
import com.opaheinz.rcx_test.dbmodel.msTCabinetList;
import com.opaheinz.rcx_test.dbmodel.msTUmsatzClassification;
import com.opaheinz.rcx_test.dbmodel.msTgroup;
public class dataRoot
{

private msTCabinet              msTCabinet;
private msTCabinetList          msTCabinetList;
private msTgroup                msTgroup;
private msTUmsatzClassification msTUmsatzClassification;

private final List<msTCabinet>              cabinets              = new ArrayList<>();
private final List<msTCabinetList>          allCabinets           = new ArrayList<>();
private final List<msTgroup>                allGroups             = new ArrayList<>();
private final List<msTUmsatzClassification> allUmsClassifications = new ArrayList<>();

public msTCabinet getMsTCabinet()
{
    return this.msTCabinet;
}

public void setMsTCabinet(final msTCabinet msTCabinet)
{
    this.msTCabinet = msTCabinet;
}

public List<msTCabinet> getCabinets()
{
    return this.cabinets;
}

public msTCabinetList getMsTCabinetList()
{
    return this.msTCabinetList;
}

public void setMsTCabinetList(final msTCabinetList msTCabinetList)
{
    this.msTCabinetList = msTCabinetList;
}

public List<msTCabinetList> getAllCabinets()
{
    return this.allCabinets;
}

public msTgroup getMsTgroup()
{
    return this.msTgroup;
}

public void setMsTgroup(final msTgroup msTgroup)
{
    this.msTgroup = msTgroup;
}

public List<msTgroup> getAllGroups()
{
    return this.allGroups;
}

public msTUmsatzClassification getMsTUmsatzClassification()
{
    return this.msTUmsatzClassification;
}

public void setMsTUmsatzClassification(final msTUmsatzClassification msTUmsatzClassification)
{
    this.msTUmsatzClassification = msTUmsatzClassification;
}

public List<msTUmsatzClassification> getAllUmsClassifications()
{
    return this.allUmsClassifications;
}
}

哪里出了问题,哪里出了问题? 任何帮助/想法/示例将不胜感激。 rgds OpaHeinz

目前我还没有使用过。不幸的是,没有更新的文件。我无法将我们的应用程序迁移到 X,因为 X 没有图表。

我还有两个问题:
1st) 我在微流中导入数据时出错 table.
我用过:

    private void btnImportTCabinet_onClick(final ClickEvent<Button> event)
{
    final dataRoot root = dbHandler.getRoot();
    final List<TCabinet> allRegister = new TCabinetDAO().findAll();
    final msTCabinet myMsTCcabinet = new msTCabinet();

    for(final TCabinet TCabinet : allRegister)
    {
        myMsTCcabinet.setId(TCabinet.getId());
        myMsTCcabinet.setDescription(TCabinet.getDescription());

        root.setMsTCabinet(myMsTCcabinet);
        root.getCabinets().add(myMsTCcabinet);

        dbHandler.getStoragemanager().store(myMsTCcabinet);
    }
}

出错了,我要搬家

final msTCabinet myMsTCcabinet = new msTCabinet();

在 for 循环中,如:

    private void btnImportTCabinet_onClick(final ClickEvent<Button> event)
{
    final dataRoot       root          = dbHandler.getRoot();
    final List<TCabinet> allRegister   = new TCabinetDAO().findAll();

    for(final TCabinet TCabinet : allRegister)
    {
        final msTCabinet     myMsTCcabinet = new msTCabinet();
        myMsTCcabinet.setId(TCabinet.getId());
        myMsTCcabinet.setDescription(TCabinet.getDescription());

        root.setMsTCabinet(myMsTCcabinet);
        root.getCabinets().add(myMsTCcabinet);

        dbHandler.getStoragemanager().store(myMsTCcabinet);
    }
}

然后
2nd) 通过使用以下代码输出到网格中仍然有效:

this.grid.setDataProvider(DataProvider.ofCollection(root.getAllCabinets()));


现在我找到了最终的解决方案: 我必须使用以下代码进行分配:

    private void grid_onAttach(final AttachEvent event)
{

    final EmbeddedStorageManager storage = dbHandler.getStoragemanager();

    if(storage.root() == null)
    {
        System.out.println("No existing Database found ");
    }
    else
    {
        System.out.println("Existing Database found: ");
        final dataRoot root = (dataRoot)storage.root();
        this.grid.setDataProvider(DataProvider.ofCollection(root.getAllCabinets()));

    }

}