Comments (7)
Hello,
Could you give me the way you use to fill your data ? or your test class / project ?
Thanks.
F.
from play2-morphia-plugin.
This is my Upload Script
package controllers;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import models.User;
public class DataLoader{
private static final String Enabled = null;
private static final String Disable = null;
public DataLoader() {
// TODO Auto-generated constructor stub
}
public boolean isDataLoaded() {
boolean flag=false;
try {
List<User> sp = User.find.all();
if(sp.isEmpty())
{
flag=true;
}
else{
flag=false;
}
}
catch (Exception e) {
// TODO: handle exception
}
return flag;
}
public void loadData(InputStream in, String tablename) {
try {
if (in != null) {
InputStreamReader tmp = new InputStreamReader(in);
BufferedReader reader = new BufferedReader(tmp);
CSVReader csvreader = new CSVReader(reader, 1);
String[] nextLine;
while ((nextLine = csvreader.readNext()) != null) {
insertdata(nextLine, tablename);
}
// setListAdaptor(ar);
}
} catch (Exception t) {
System.out.println(t.toString());
}
}
public void load()
{
InputStream in = null;
// in = this.getClass().getResourceAsStream("SharePolicies.csv");
try {
String workingDir = System.getProperty("user.dir");
workingDir=workingDir+"\\"+"db"+"\\";
//Users
in= new FileInputStream(workingDir+"Users.csv");
System.out.println(in);
this.loadData(in,"User");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void insertdata(String[] data, String table_name)
throws ParseException {
if (table_name.equals("User")) {
if(data[0]!=null && !data[0].equals(""))
{
User u=new User();
u.userName=data[0];
u.userType=data[1];
if(data[2].trim().toString().equals("True")){
u.canUpdate=true;
}else{
u.canUpdate=false;
}
u.insert();
}
}
}
}
Application Controller Index
public static Result index(){
DataLoader dl=new DataLoader();
boolean check=dl.isDataLoaded();
if(check==true)
{
dl.load();
}
else{
//
}
return showAllUsers();
}
Thanking you!
by
Balamanikandan.T
from play2-morphia-plugin.
Hai!
Friends do you have get any idea? about this problem.
Thanking you!
by
Balamanikandan.T
from play2-morphia-plugin.
Hello,
Sorry for the delay.
After loading your data, could you check in your database if your data are right ?
In your method
public static Result showCanUpdate(){
List user = User.find.filter("userType", "Admin").filter("canUpdate", true).asList();
System.out.println("All Admin Can Update : "+user.size() );
return null;
}
your filter for field "userType"
with value "Admin"
Do you test your query with mongo client ?
db.User.find({"userType":"Admin","canUpdate":true})
F.
from play2-morphia-plugin.
Hello,
Could you try with the new release 0.0.6 and replace the find
property of your model with a method find()
like describe in issue #8 ?
F.
from play2-morphia-plugin.
Hai!
Thanks for your replay. i will try 0.0.6. I hope you...
Thanking you!
by
Balamanikandan.T
from play2-morphia-plugin.
Hai!
How are you?
I have some doubt about (new version) how to change my old version to new
version ...
Do have any tutorial link ... please send to me ...
Thanking you...
By
(bdeveloper01)
Balamanikandan.T
from play2-morphia-plugin.
Related Issues (18)
- play2-morphia-plugin blob related Error HOT 4
- Index does not seem to be initialised HOT 1
- UNRESOLVED DEPENDENCIES proxytoys HOT 4
- Compatibility with Play 2.0.4 and MorphiaPlugin 0.0.7 HOT 6
- Blob lost on update to the object HOT 1
- Plugin not compatible with Play 2.1
- How to install version 0.0.14 for Play 2.1? HOT 1
- play2-morphia-plugin .asList related Error HOT 1
- How to install for Play 2.2? HOT 13
- id as Long can't work
- Play 2.3.X
- Play 2.5.x
- How to install it? HOT 2
- add support for mongodb credentials HOT 1
- Thanks for this important fix HOT 1
- A big issue about Finder HOT 1
- morphia-0.0.6 (doubt abut filter) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from play2-morphia-plugin.