Skip to content

Commit

Permalink
Merge pull request #12 from axonivy-market/simplify
Browse files Browse the repository at this point in the history
simplify
  • Loading branch information
ivy-rew committed May 2, 2023
2 parents cf89707 + 8ea5bb8 commit 474671e
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 260 deletions.
8 changes: 0 additions & 8 deletions stateful-datatable-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
<artifactId>stateful-datatable-demo</artifactId>
<version>10.0.3-SNAPSHOT</version>
<packaging>iar</packaging>
<dependencies>
<dependency>
<groupId>com.axonivy.portal</groupId>
<artifactId>portal-components</artifactId>
<version>10.0.0</version>
<type>iar</type>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public interface IAbstractEntityDAO<AE extends AbstractEntity> {

/**
* Defines the DAO class
*
* @return
*
* @return type
*/
Class<AE> getType();

/**
* save entity in DB
*
* @param entity
* @return
* @return saved
*/
AE save(AE entity);

Expand All @@ -36,33 +36,27 @@ public interface IAbstractEntityDAO<AE extends AbstractEntity> {
void delete(AE entity);

/**
* Finds all entities
*
* @return
* @return all entities
*/
List<AE> getAll();

/**
* Finds entity by its id
*
* @param ae
* @return
* @param id
* @return entity
*/
AE getById(String id);

/**
* Makes query using {@link EntityManager} / {@link CriteriaQuery}
*
* @param cf
* @return
* @param cc
*/
List<AE> getByCriteriaQuery(CriteriaQuery<AE> cc);

/**
* Makes query using {@link EntityManager} / {@link CriteriaQuery}
*
* @param cf
* @return
*/
List<AE> getByCriteriaQuery(CriteriaQuery<AE> cc, int offset, int resultSize);

Expand All @@ -71,15 +65,13 @@ public interface IAbstractEntityDAO<AE extends AbstractEntity> {
* one is found by query, null otherwise.
*
* @param cc
* @return
*/
AE getByCriteriaQuerySingle(CriteriaQuery<AE> cc);

/**
* Returns single result - count of items found by query.
*
*
* @param cc
* @return
*/
Long countByCriteriaQuery(CriteriaQuery<Long> cc);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@

public class ProductRepoDAO implements IProductDAO {

@Override
public Product save(Product product) {
Ivy.repo().save(product);
return product;
}


@Override
public Product getById(String id) {
return Ivy.repo().find(id, Product.class);
};

}

@Override
public List<Product> getAll(){
return Ivy.repo().search(Product.class).limit(10000).execute().getAll();
}


@Override
public void delete(Product product) {
Ivy.repo().delete(product);
}


@Override
public List<Product> callQueryWithLimit(Query<Product> query, int first, int pageSize) {
return query.limit(first, pageSize).execute().getAll();
}


@Override
public long getQueryRowCount(Query<Product> query) {
return query.limit(0, 10000).execute().count();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.axonivy.demo.statefuldatatable.entity;

import java.io.Serializable;
import java.util.Objects;

import javax.persistence.MappedSuperclass;

Expand All @@ -11,13 +12,11 @@
public abstract class AbstractEntity implements Serializable {

private static final long serialVersionUID = 4128302279946094433L;

protected static final String COLUMN_ID = "ID";

/**
* ID of database entity - getter
*
* @return
* return: ID of database entity
*/
public abstract String getId();

Expand All @@ -27,17 +26,17 @@ public abstract class AbstractEntity implements Serializable {
* @param id
*/
public abstract void setId(String id);

/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/

@Override
public boolean equals(Object obj) {
if (obj == null || !AbstractEntity.class.isAssignableFrom(obj.getClass())) {
return false;
}
return getId().equals(((AbstractEntity) obj).getId());
}

@Override
public int hashCode() {
return Objects.hash(getId());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
*
*
*/
package com.axonivy.demo.statefuldatatable.entity;

Expand All @@ -24,51 +24,53 @@ public class Product extends AbstractEntity {
private static final long serialVersionUID = 1L;

@Id
@Column(length = 32, nullable = false)
@Column(length = 32, nullable = false)
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy = "uuid")
private String id;
//Adding Column STEP 1
@Column
private Date validThrough;

@Column
private Date orderDate;

@Column
private Date deliveryDate;

@Column
private Integer quantity;

@Column
@Enumerated(EnumType.STRING)
private Quality quality;

@Column
@Enumerated(EnumType.STRING)
private Availability availability;

@Column
@Enumerated(EnumType.STRING)
private ProductStatus productStatus;

@Column
private String productName;

@Column
private Boolean onSale;

/**
* @return the id
*/
@Override
public String getId() {
return id;
}

/**
* @param id the id to set
*/
@Override
public void setId(String id) {
this.id = id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ public interface HasCmsName {
String name();

/**
* Return the name entry of the instance.
*
* @return
* @return the name entry of the instance.
*/
default String getCmsName() {
return getCms("name");
Expand All @@ -53,11 +51,9 @@ default String getCms(String entry) {

/**
* Lookup the URL of an entry in the Ivy Cms.
*
* If the entry is not found, then the name of the entry is returned.
*
*
* @param entry
* @return
* @return If the entry is not found, then the name of the entry is returned.
*/
default String getCmsUrl(String entry) {
String cmsPath = getEntryPath(entry);
Expand Down
Loading

0 comments on commit 474671e

Please sign in to comment.