You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Aída Betzabeth Dávila Sotelo <ai...@vortech-it.com> on 2016/11/17 16:32:44 UTC

Count

Hi!

I have the following issue. I need to do a count of registered users per day in my application.
I have the correct query, but I cannot display the results on screen.

I tried with different types of data, at the end I put a simple list of string but sends me the following error, instead of information:

??? EntityModel objectAdapter oid: null

Could you recommend me another way that I can solve
this problem? or how could I get the count of some object by date?.

Thanks in advance.
Aida Davila

This is my code:



public List<String> FindNewUsersCountPerDay() {

    System.out.println("Find");
    List <User> MyUsers = this.findAllUsers();

    List<String> lista = new ArrayList<String>();

    Map<String, Long> countByDate  = MyUsers.stream()
            .collect(Collectors
                            .groupingBy(User::getCreationDate, Collectors.counting())
                     );

    Set<Map.Entry<String, Long>> set = countByDate.entrySet();
    List<Map.Entry<String, Long>> userList = new ArrayList<>(set);
    Iterator<Map.Entry<String, Long>> it = userList.iterator();

    int index = 0;

    while (it.hasNext()) {
        Map.Entry<String, Long> entry = it.next();
        String result = index + " " + entry.getKey() + " " + entry.getValue();
        lista.add(result);
        System.out.println("Entry from converted list : " + index + " 1:" +  entry.getKey() + " 2:" + entry.getValue());
        index++;
    }

    System.out.println(countByDate);

    return (lista);
}


RE: Count

Posted by Aída Betzabeth Dávila Sotelo <ai...@vortech-it.com>.
Thank you very much!!!!
I had already tried that option and it had not worked. But when I saw your example, I found my mistake.

Thanks
Aida 

-----Mensaje original-----
De: Jeroen van der Wal [mailto:jeroen@stromboli.it] 
Enviado el: jueves, 17 de noviembre de 2016 11:46
Para: users
Asunto: Re: Count

Returning a collection of view models would work:

@ViewModel // or @DomainObject(nature = Nature.VIEW_MODEL) public class UserCount {

    public UserCount(final LocalDate date, final BigInteger count) {
        this.date = date;
        this.count = count;
    }

   @Getter @Setter // Uses Lombok to generate getter and setters
   private LocalDate date;

   @Getter @Setter
   private BigInteger count;
}

HTH

On 17 November 2016 at 17:32, Aída Betzabeth Dávila Sotelo < aida.davila@vortech-it.com> wrote:

> Hi!
>
> I have the following issue. I need to do a count of registered users 
> per day in my application.
> I have the correct query, but I cannot display the results on screen.
>
> I tried with different types of data, at the end I put a simple list 
> of string but sends me the following error, instead of information:
>
> ??? EntityModel objectAdapter oid: null
>
> Could you recommend me another way that I can solve this problem? or 
> how could I get the count of some object by date?.
>
> Thanks in advance.
> Aida Davila
>
> This is my code:
>
>
>
> public List<String> FindNewUsersCountPerDay() {
>
>     System.out.println("Find");
>     List <User> MyUsers = this.findAllUsers();
>
>     List<String> lista = new ArrayList<String>();
>
>     Map<String, Long> countByDate  = MyUsers.stream()
>             .collect(Collectors
>                             .groupingBy(User::getCreationDate,
> Collectors.counting())
>                      );
>
>     Set<Map.Entry<String, Long>> set = countByDate.entrySet();
>     List<Map.Entry<String, Long>> userList = new ArrayList<>(set);
>     Iterator<Map.Entry<String, Long>> it = userList.iterator();
>
>     int index = 0;
>
>     while (it.hasNext()) {
>         Map.Entry<String, Long> entry = it.next();
>         String result = index + " " + entry.getKey() + " " + 
> entry.getValue();
>         lista.add(result);
>         System.out.println("Entry from converted list : " + index + " 1:"
> +  entry.getKey() + " 2:" + entry.getValue());
>         index++;
>     }
>
>     System.out.println(countByDate);
>
>     return (lista);
> }
>
>

Re: Count

Posted by Jeroen van der Wal <je...@stromboli.it>.
Returning a collection of view models would work:

@ViewModel // or @DomainObject(nature = Nature.VIEW_MODEL)
public class UserCount {

    public UserCount(final LocalDate date, final BigInteger count) {
        this.date = date;
        this.count = count;
    }

   @Getter @Setter // Uses Lombok to generate getter and setters
   private LocalDate date;

   @Getter @Setter
   private BigInteger count;
}

HTH

On 17 November 2016 at 17:32, Aída Betzabeth Dávila Sotelo <
aida.davila@vortech-it.com> wrote:

> Hi!
>
> I have the following issue. I need to do a count of registered users per
> day in my application.
> I have the correct query, but I cannot display the results on screen.
>
> I tried with different types of data, at the end I put a simple list of
> string but sends me the following error, instead of information:
>
> ??? EntityModel objectAdapter oid: null
>
> Could you recommend me another way that I can solve
> this problem? or how could I get the count of some object by date?.
>
> Thanks in advance.
> Aida Davila
>
> This is my code:
>
>
>
> public List<String> FindNewUsersCountPerDay() {
>
>     System.out.println("Find");
>     List <User> MyUsers = this.findAllUsers();
>
>     List<String> lista = new ArrayList<String>();
>
>     Map<String, Long> countByDate  = MyUsers.stream()
>             .collect(Collectors
>                             .groupingBy(User::getCreationDate,
> Collectors.counting())
>                      );
>
>     Set<Map.Entry<String, Long>> set = countByDate.entrySet();
>     List<Map.Entry<String, Long>> userList = new ArrayList<>(set);
>     Iterator<Map.Entry<String, Long>> it = userList.iterator();
>
>     int index = 0;
>
>     while (it.hasNext()) {
>         Map.Entry<String, Long> entry = it.next();
>         String result = index + " " + entry.getKey() + " " +
> entry.getValue();
>         lista.add(result);
>         System.out.println("Entry from converted list : " + index + " 1:"
> +  entry.getKey() + " 2:" + entry.getValue());
>         index++;
>     }
>
>     System.out.println(countByDate);
>
>     return (lista);
> }
>
>