Skip to content

Commit

Permalink
Merge pull request #199 from apromore/v7.5
Browse files Browse the repository at this point in the history
V7.5
  • Loading branch information
raboczi authored Aug 6, 2019
2 parents 39a2b7a + 6ab3b68 commit b9c1041
Show file tree
Hide file tree
Showing 117 changed files with 4,643 additions and 8,546 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ public interface LogRepository extends JpaRepository<Log, Integer>, LogRepositor
* @param pageable which page of results to produce
* @return a page of processes
*/
// @Query("SELECT DISTINCT l FROM Log l JOIN l.groupLogs gl JOIN gl.group g1, " +
// "User u JOIN u.groups g2 " +
// "WHERE (l.folder is NULL) AND (u.rowGuid = ?1) AND (g1 = g2) ORDER BY l.id")
@Query("SELECT DISTINCT l FROM Log l JOIN l.user ul " +
"WHERE (l.folder is NULL) AND ((l.publicLog = TRUE) OR (ul.rowGuid = ?1)) ORDER BY l.id")
Page<Log> findLogsByUser(String userRowGuid, Pageable pageable);
@Query("SELECT DISTINCT l FROM Log l JOIN l.groupLogs gl JOIN gl.group g1, " +
"User u JOIN u.groups g2 " +
"WHERE (l.folder is NULL) AND (u.rowGuid = ?1) AND (g1 = g2) ORDER BY l.id")
Page<Log> findRootLogsByUser(String userRowGuid, Pageable pageable);

/**
* Finds processes within a folder which are in a group the user belongs to.
Expand All @@ -79,11 +77,9 @@ public interface LogRepository extends JpaRepository<Log, Integer>, LogRepositor
* @param pageable which page of results to produce
* @return a page of processes
*/
// @Query("SELECT DISTINCT l FROM Log l JOIN l.folder f JOIN l.groupLogs gl JOIN gl.group g1, " +
// "User u JOIN u.groups g2 " +
// "WHERE (f.id = ?1) AND (u.rowGuid = ?2) AND (g1 = g2) ORDER BY l.id")
@Query("SELECT DISTINCT l FROM Log l JOIN l.folder f JOIN l.user ul " +
"WHERE (f.id = ?1) AND ((l.publicLog = TRUE) OR (ul.rowGuid = ?2)) ORDER BY l.id")
@Query("SELECT DISTINCT l FROM Log l JOIN l.folder f JOIN l.groupLogs gl JOIN gl.group g1, " +
"User u JOIN u.groups g2 " +
"WHERE (f.id = ?1) AND (u.rowGuid = ?2) AND (g1 = g2) ORDER BY l.id")
Page<Log> findAllLogsInFolderForUser(Integer folderId, String userRowGuid, Pageable pageable);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public interface LogRepositoryCustom {

/* ************************** JDBC Template / native SQL Queries ******************************* */

String storeProcessLog(final Integer folderId, String logName, XLog log, Integer userID, String domain, String created, boolean publicModel);
String storeProcessLog(final Integer folderId, String logName, XLog log, Integer userID, String domain, String created);

void deleteProcessLog(Log log);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,12 @@ public interface ProcessRepository extends JpaRepository<Process, Integer>, Proc
"User u JOIN u.groups g2 " +
"WHERE (f.id = ?1) AND (u.rowGuid = ?2) AND (g1 = g2) ORDER BY p.id")
Page<Process> findAllProcessesInFolderForUser(Integer folderId, String userRowGuid, Pageable pageable);

/**
* Returns a Process
* @param processId the id of the process
* @return the process
*/
@Query("SELECT DISTINCT p FROM Process p WHERE p.id = ?1")
Process findUniqueByID(Integer processId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
import java.util.List;

@Repository
public interface StatisticRepository extends JpaRepository<Statistic, Integer> {
public interface StatisticRepository extends JpaRepository<Statistic, Integer>, StatisticRepositoryCustom {

/**
* Get statistics of specified LogId from DB
* @param logid
* @return
*/
List<Statistic> findByLogid(Integer logid);

// List<Statistic> findByLogidAnd

// boolean existsByLogidAndStat_value(Integer logid, String stat_value);
// List<Statistic> findByLogidAndStat_value(Integer logid, String stat_value);
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.apromore.dao;

import org.apromore.dao.model.Statistic;

import java.util.List;

public interface StatisticRepositoryCustom {

/**
* Store all statistics into DB. Use custom JPA instead of sava() for better performance.
* @param stats
*/
void storeAllStats(List<Statistic> stats);
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public class LogRepositoryCustomImpl implements LogRepositoryCustom {

private static final String GET_ALL_LOGS_JPA = "SELECT l FROM Log l ";
private static final String GET_ALL_LOGS_FOLDER_JPA = "SELECT l FROM Log l JOIN l.folder f ";
private static final String GET_ALL_PUBLIC_JPA = "l.publicLog = true ";
private static final String GET_ALL_FOLDER_JPA = "f.id = ";
private static final String GET_ALL_SORT_JPA = " ORDER by l.id";

Expand All @@ -79,9 +78,6 @@ public List<Log> findAllLogs(final String conditions) {
strQry.append(GET_ALL_LOGS_JPA);
if (conditions != null && !conditions.isEmpty()) {
strQry.append(" WHERE ").append(conditions);
strQry.append(" AND ").append(GET_ALL_PUBLIC_JPA);
} else {
strQry.append(" WHERE ").append(GET_ALL_PUBLIC_JPA);
}
strQry.append(GET_ALL_SORT_JPA);

Expand All @@ -99,20 +95,11 @@ public List<Log> findAllLogsByFolder(final Integer folderId, final String condit
boolean whereAdded = false;
StringBuilder strQry = new StringBuilder(0);
strQry.append(GET_ALL_LOGS_FOLDER_JPA);
strQry.append(" WHERE ");
if (conditions != null && !conditions.isEmpty()) {
strQry.append(" WHERE ").append(conditions);
strQry.append(" AND ").append(GET_ALL_PUBLIC_JPA);
whereAdded = true;
}
else {
strQry.append(" WHERE ").append(GET_ALL_PUBLIC_JPA);
}
// if (whereAdded) {
strQry.append(conditions);
strQry.append(" AND ");
// } else {
// strQry.append(" WHERE ");
// }

}
strQry.append(GET_ALL_FOLDER_JPA).append(folderId);
strQry.append(GET_ALL_SORT_JPA);

Expand All @@ -125,7 +112,7 @@ public List<Log> findAllLogsByFolder(final Integer folderId, final String condit
* {@inheritDoc}
*/
@Override
public String storeProcessLog(final Integer folderId, final String logName, XLog log, final Integer userID, final String domain, final String created, final boolean publicModel) {
public String storeProcessLog(final Integer folderId, final String logName, XLog log, final Integer userID, final String domain, final String created) {

LOGGER.error("Storing Log " + log.size() + " " + logName);
if (log != null && logName != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.apromore.dao.jpa;

import org.apromore.dao.StatisticRepositoryCustom;
import org.apromore.dao.model.Statistic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

public class StatisticRepositoryCustomImpl implements StatisticRepositoryCustom {

private static final Logger LOGGER = LoggerFactory.getLogger(StatisticRepositoryCustomImpl.class);

@PersistenceContext
private EntityManager em;

@Override
@Transactional
public void storeAllStats(List<Statistic> stats) {
try {
int ip = 0;
for(Statistic stat : stats) {
ip = ip +1;
em.persist(stat);
if((ip % 10000) == 0 ) {
em.flush();
em.clear();
}
}
} catch (Exception e) {
LOGGER.error("Error " + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@ public void setRanking(final String newRanking) {
this.ranking = newRanking;
}

@Column(name = "public_log")
public boolean getPublicLog() {
return this.publicLog;
}

public void setPublicLog(final boolean newPublicLog) {
this.publicLog = newPublicLog;
}

@Column(name = "createDate")
public String getCreateDate() {
return this.createDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@ public void setRanking(final String newRanking) {
this.ranking = newRanking;
}

@Column(name = "public_model")
public boolean getPublicModel() {
return this.publicModel;
}

public void setPublicModel(final boolean newPublicModel) {
this.publicModel = newPublicModel;
}

@Column(name = "createDate")
public String getCreateDate() {
return this.createDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
@Entity
@Table(name = "statistic",
uniqueConstraints = {
@UniqueConstraint(columnNames = {"count"}),
@UniqueConstraint(columnNames = {"id"})
@UniqueConstraint(columnNames = {"count"})
}
)
@Configurable("statistic")
Expand All @@ -34,7 +33,7 @@ public Statistic() {


@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "count", unique = true, nullable = false)
public Long getCount() {
return count;
Expand All @@ -43,8 +42,7 @@ public void setCount(Long count) {
this.count = count;
}


@Column(name = "id", unique = true, nullable = false, length = 16)
@Column(name = "id", nullable = false, length = 16)
public byte[] getId() {
return this.id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apromore.exception.*;
import org.apromore.model.ExportLogResultType;
import org.apromore.model.SummariesType;
import org.apromore.util.StatType;
import org.deckfour.xes.model.XLog;

import java.io.InputStream;
Expand Down Expand Up @@ -76,6 +77,8 @@ ExportLogResultType exportLog(Integer logId)

void updateLogMetaData(Integer logId, String logName, boolean isPublic);

boolean isPublicLog(Integer logId);

/**
* Get XLog and append statistics as log level metadata
* @param logId
Expand All @@ -95,4 +98,17 @@ ExportLogResultType exportLog(Integer logId)
* @return List of statistic entities
*/
List<Statistic> getStats(Integer logId);


/**
* Persist statistics of XLog into DB by stat types
* TODO: explain the format of input nested map
* @param map {String statUID {[String stat_key, String stat_value]}}
* The statUID is a unique identifier that is associated with a set of statistics of the same type.
* For example, it can be the caseID which is used to identify a set of attributes of one case.
* {caseID, {[attrKey, attrValue] [attrKey, attrValue]}}
* @param logId logID of XES log file
* @param statType enum that store all the types of statistic
*/
void storeStatsByType(Map<String, Map<String, String>> map, Integer logId, StatType statType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ ExportFormatResultType exportProcess(final String name, final Integer processId,
void updateProcessMetaData(final Integer processId, final String processName, final String domain, final String username,
final Version preVersion, final Version newVersion, final String ranking, final boolean isPublic) throws UpdateProcessException;

boolean isPublicProcess(Integer processId);

/**
* Add a new ProcessModelVersion record into the DB.
* @param branch the process branch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,13 @@ public interface SecurityService {
* @return if success or not.
*/
boolean resetUserPassword(String username, String password);

/**
* Update the user password with the new one passed in.
* @param username the user to find.
* @param oldPassword the current password
* @param newPassword the new password
* @return if success or not.
*/
boolean changeUserPassword(String username, String oldPassword, String newPassword);
}
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ private ProcessSummaryType buildProcessSummary(final Process process) {
processSummary.setName(process.getName());
processSummary.setDomain(process.getDomain());
processSummary.setRanking(process.getRanking());
processSummary.setMakePublic(process.getPublicModel());

ProcessModelVersion latestVersion = pmvRepository.getLatestProcessModelVersion(process.getId(), "MAIN");
if (latestVersion != null) {
Expand Down Expand Up @@ -302,7 +301,6 @@ public LogSummaryType buildLogSummary(final Log log) {
logSummaryType.setName(log.getName());
logSummaryType.setDomain(log.getDomain());
logSummaryType.setRanking(log.getRanking());
logSummaryType.setMakePublic(log.getPublicLog());

// ProcessModelVersion latestVersion = pmvRepository.getLatestProcessModelVersion(log.getId(), "MAIN");
// if (latestVersion != null) {
Expand Down Expand Up @@ -340,7 +338,6 @@ private ProcessSummaryType buildProcessList(List<Integer> proIds, ProcessVersion
processSummary.setName(process.getName());
processSummary.setDomain(process.getDomain());
processSummary.setRanking(process.getRanking());
processSummary.setMakePublic(process.getPublicModel());
if (process.getNativeType() != null) {
processSummary.setOriginalNativeType(process.getNativeType().getNatType());
}
Expand Down
Loading

0 comments on commit b9c1041

Please sign in to comment.