Add javadoc comments and improve logic

merge-requests/7/head
lasanthaDLPDS 6 years ago
parent 26568273e5
commit 4316cb0ef4

@ -30,58 +30,97 @@ public class ApplicationRelease {
@Exclude
private int id;
/**
* Version of the application release
*/
private String version;
/**
* UUID of the application release
*/
private String uuid;
/**
* Application storing location
*/
private String appStoredLoc;
/**
* Banner file storing location
*/
private String bannerLoc;
/**
* Screenshot storing location
*/
private String screenshotLoc1;
/**
* Screenshot storing location
*/
private String screenshotLoc2;
/**
* Screenshot storing location
*/
private String screenshotLoc3;
/**
* Application release creator
*/
private String applicationCreator;
/**
* Release type of the application release
* e.g: alpha, beta etc
*/
private String releaseType;
/**
* Price of the application release
*/
private Double price;
private Timestamp createdAt;
private String publishedBy;
private Timestamp publishedAt;
private String modifiedBy;
private Timestamp modifiedAt;
/**
* icon file storing location
*/
private String iconLoc;
private String currentState;
private String previousState;
private String stateModifiedBy;
private Timestamp stateModifiedAt;
/**
* Hash value of the application release
*/
private String appHashValue;
/**
* If application release is shared with all tenants it is eqal to 1 otherwise 0
*/
private int isSharedWithAllTenants;
/**
* MEta data of the application release
*/
private String metaData;
/**
* Number of users who has rated the application release
*/
private int ratedUsers;
/**
* Rating value of the application release
*/
private Double rating;
/**
* URL which is used for WEB-CLIP
*/
private String url;
/**
* Latest Lifecycle state of the application release
*/
private LifecycleState lifecycleState;
public int getRatedUsers() {
return ratedUsers;
}
@ -150,37 +189,6 @@ public class ApplicationRelease {
this.price = price;
}
public String getCurrentState() {
return currentState;
}
public void setCurrentState(String currentState) {
this.currentState = currentState;
}
public String getPreviousState() {
return previousState;
}
public void setPreviousState(String previousState) {
this.previousState = previousState;
}
public String getStateModifiedBy() {
return stateModifiedBy;
}
public void setStateModifiedBy(String stateModifiedBy) {
this.stateModifiedBy = stateModifiedBy;
}
public Timestamp getStateModifiedAt() {
return stateModifiedAt;
}
public void setStateModifiedAt(Timestamp stateModifiedAt) {
this.stateModifiedAt = stateModifiedAt;
}
public String getAppHashValue() {
return appHashValue;
@ -242,46 +250,6 @@ public class ApplicationRelease {
this.applicationCreator = applicationCreator;
}
public Timestamp getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Timestamp createdAt) {
this.createdAt = createdAt;
}
public String getPublishedBy() {
return publishedBy;
}
public void setPublishedBy(String publishedBy) {
this.publishedBy = publishedBy;
}
public Timestamp getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(Timestamp publishedAt) {
this.publishedAt = publishedAt;
}
public String getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Timestamp getModifiedAt() {
return modifiedAt;
}
public void setModifiedAt(Timestamp modifiedAt) {
this.modifiedAt = modifiedAt;
}
public String getIconLoc() {
return iconLoc;
}
@ -298,4 +266,11 @@ public class ApplicationRelease {
this.url = url;
}
public LifecycleState getLifecycleState() {
return lifecycleState;
}
public void setLifecycleState(LifecycleState lifecycleState) {
this.lifecycleState = lifecycleState;
}
}

@ -168,9 +168,6 @@ public class Util {
appRelease.setAppStoredLoc(rs.getString("STORED_LOCATION"));
appRelease.setBannerLoc(rs.getString("BANNER_LOCATION"));
appRelease.setApplicationCreator(rs.getString("CREATED_BY"));
appRelease.setCreatedAt(rs.getTimestamp("CREATED_AT"));
appRelease.setPublishedBy(rs.getString("PUBLISHED_BY"));
appRelease.setPublishedAt(rs.getTimestamp("PUBLISHED_AT"));
appRelease.setRating(rs.getDouble("RATING"));
appRelease.setIsSharedWithAllTenants(rs.getInt("SHARED_WITH_ALL_TENANTS"));
appRelease.setMetaData(rs.getString("APP_META_INFO"));

@ -247,9 +247,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
applicationRelease.setCreatedAt(resultSet.getTimestamp("CREATED_AT"));
applicationRelease.setPublishedBy(resultSet.getString("PUBLISHED_BY"));
applicationRelease.setPublishedAt(resultSet.getTimestamp("PUBLISHED_AT"));
applicationRelease.setRating(resultSet.getDouble("RATING"));
applicationReleases.add(applicationRelease);
@ -392,14 +389,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
applicationRelease.setApplicationCreator(resultSet.getString("CREATED_BY"));
applicationRelease.setCreatedAt(resultSet.getTimestamp("CREATED_AT"));
applicationRelease.setPublishedBy(resultSet.getString("PUBLISHED_BY"));
applicationRelease.setPublishedAt(resultSet.getTimestamp("PUBLISHED_AT"));
applicationRelease.setRating(resultSet.getDouble("RATING"));
applicationRelease.setCurrentState(resultSet.getString("CURRENT_STATE"));
applicationRelease.setPreviousState(resultSet.getString("PREVIOUS_STATE"));
applicationRelease.setStateModifiedBy(resultSet.getString("UPDATED_BY"));
applicationRelease.setStateModifiedAt(resultSet.getTimestamp("UPDATED_AT"));
return applicationRelease;
}

@ -97,6 +97,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
validateReleaseCreatingRequest(application.getApplicationReleases().get(0));
DeviceType deviceType;
ApplicationRelease applicationRelease;
List<ApplicationRelease> applicationReleases = new ArrayList<>();
try {
ConnectionManagerUtil.beginDBTransaction();
deviceType = this.deviceTypeDAO.getDeviceType(application.getDeviceType(), tenantId);
@ -121,9 +122,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
} else {
application.setIsRestricted(0);
}
if (application.getApplicationReleases().size() > 1 ){
throw new ApplicationManagementException(
"Invalid payload. Application creating payload should contains one application release, but "
+ "the payload contains more than one");
}
ConnectionManagerUtil.commitDBTransaction();
applicationRelease = application.getApplicationReleases().get(0);
applicationRelease.setCreatedAt((Timestamp) new Date());
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().
createRelease(applicationRelease, application.getId(), tenantId);
LifecycleState lifecycleState = new LifecycleState();
@ -134,6 +139,9 @@ public class ApplicationManagerImpl implements ApplicationManager {
lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString());
lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString());
addLifecycleState(application.getId(), applicationRelease.getUuid(), lifecycleState);
applicationRelease.setLifecycleState(lifecycleState);
applicationReleases.add(applicationRelease);
application.setApplicationReleases(applicationReleases);
}
return application;
@ -200,9 +208,9 @@ public class ApplicationManagerImpl implements ApplicationManager {
if (log.isDebugEnabled()) {
log.debug("Application release request is received for the application " + application.toString());
}
applicationRelease.setCreatedAt((Timestamp) new Date());
try {
ConnectionManagerUtil.beginDBTransaction();
// todo consider about lifecycle adding
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().
createRelease(applicationRelease, application.getId(), tenantId);
ConnectionManagerUtil.commitDBTransaction();
@ -353,10 +361,10 @@ public class ApplicationManagerImpl implements ApplicationManager {
for (ApplicationRelease applicationRelease : applicationReleases) {
LifecycleState lifecycleState = ApplicationManagementDAOFactory.getLifecycleStateDAO().
getLatestLifeCycleStateByReleaseID(applicationRelease.getId());
applicationRelease.setCurrentState(lifecycleState.getCurrentState());
applicationRelease.setPreviousState(lifecycleState.getPreviousState());
applicationRelease.setLifecycleState(lifecycleState);
if (!AppLifecycleState.REMOVED.toString().equals(applicationRelease.getCurrentState())) {
if (!AppLifecycleState.REMOVED.toString()
.equals(applicationRelease.getLifecycleState().getCurrentState())) {
filteredApplicationReleases.add(applicationRelease);
}
}
@ -613,7 +621,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
try {
ConnectionManagerUtil.openDBConnection();
applicationRelease.setModifiedBy(userName);
// todo consider about lifecycle
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO()
.updateRelease(appId, applicationRelease, tenantId);

@ -328,8 +328,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
if (!applicationManager.isApplicationReleaseUpdateAcceptable(application.getId(),
applicationRelease.getUuid())) {
String msg = "Application release is in the " + applicationRelease.getCurrentState() + " state. Hence" +
" updating is not acceptable when application in this state";
String msg = "Application release is in the " + applicationRelease.getLifecycleState().getCurrentState()
+ " state. Hence updating is not acceptable when application in this state";
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
}

@ -70,7 +70,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
for (Application application : applications.getApplications()) {
for (ApplicationRelease appRelease: application.getApplicationReleases()){
if (AppLifecycleState.PUBLISHED.toString().equals(appRelease.getCurrentState())){
if (AppLifecycleState.PUBLISHED.toString()
.equals(appRelease.getLifecycleState().getCurrentState())) {
publishedApplicationRelease.add(appRelease);
}
}
@ -110,7 +111,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
}
for (ApplicationRelease appRelease : application.getApplicationReleases()) {
if (AppLifecycleState.PUBLISHED.toString().equals(appRelease.getCurrentState())){
if (AppLifecycleState.PUBLISHED.toString().equals(appRelease.getLifecycleState().getCurrentState())){
publishedApplicationRelease.add(appRelease);
}
}

Loading…
Cancel
Save