Code Monkey home page Code Monkey logo

Comments (7)

leodagdag avatar leodagdag commented on August 24, 2024

Hello,
Could you give me the way you use to fill your data ? or your test class / project ?
Thanks.

F.

from play2-morphia-plugin.

bdeveloper01 avatar bdeveloper01 commented on August 24, 2024

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.

bdeveloper01 avatar bdeveloper01 commented on August 24, 2024

Hai!

Friends do you have get any idea? about this problem.

Thanking you!
by
Balamanikandan.T

from play2-morphia-plugin.

leodagdag avatar leodagdag commented on August 24, 2024

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.

leodagdag avatar leodagdag commented on August 24, 2024

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.

bdeveloper01 avatar bdeveloper01 commented on August 24, 2024

Hai!

Thanks for your replay. i will try 0.0.6. I hope you...

Thanking you!
by
Balamanikandan.T

from play2-morphia-plugin.

bdeveloper01 avatar bdeveloper01 commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.