Reputation: 143
I try to work with RapidClipseX and MicroStreamDB. I generated a storage, imported different data in different table Objects. Now I would like to read the data and visualize it in a RapidClipseX Grid component.
By using MicroStreamDB I do not have a DAO object like in hibernate. I have still no idea how to do it. There is also no sample availabel in RapidClipseX- documentation and also nothing in Microstream-documentation.
I tried to use following assignment, which still fills the grid. But it fills the grid with around 6000 rows, which is still the amount of rows in the table. But each row has the same content, which is still the last saved row in db-table. ( I still checked by a texteditor, if the MicrostreamDB has the correct data stored. --> and yes it has)
private void grid_onAttach(final AttachEvent event)
{
final dataRoot root = dbHandler.getRoot();
this.grid.setDataProvider(DataProvider.ofCollection(root.getAllUmsClassifications()));
}
This is my class for the used 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;
}
}
following code is my dataRoot:
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;
}
}
What is wrong and where is the problem? Any help/ idea /samples would be appreciated. rgds OpaHeinz
Upvotes: 1
Views: 171
Reputation: 143
Now I found the final solution: I had to use following code for assgnment:
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()));
}
}
Upvotes: 0
Reputation: 143
I had still two problems:
1st) I did a mistake while importing data in the microstream table.
I used:
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);
}
}
There was a mistake, I had to move
final msTCabinet myMsTCcabinet = new msTCabinet();
inside the for loop, like:
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);
}
}
Then
2nd) the output into the grid still works by using following code:
this.grid.setDataProvider(DataProvider.ofCollection(root.getAllCabinets()));
Upvotes: 0
Reputation: 290
I have not used it as of now. And unfortunately, there are no updated documents. I cannot migrate our application to X because X doesn't have charts.
Upvotes: 0