if(getVm().equalsIgnoreCase("non-search")){
}else if(getVm().equalsIgnoreCase("search")){
LogInformation logInfo;
CollectionSelectedDetail SelectedDetail;
if("".equals(getId())){
setSelectedDetails( getManager().getList("SELECT w FROM "+CollectionSelectedDetail.class.getName()+" w WHERE w.collection.id='"+getCollection().getId()+"'",null, null));
if(!getSelectedDetails().isEmpty()){
ranking = getSelectedDetails().size()+1;
}else{
ranking = 1;
}
logInfo = new LogInformation();
SelectedDetail = new CollectionSelectedDetail();
logInfo.setCreateBy(sess.getCurrentUser().getId());
logInfo.setCreateDate(new Timestamp(System.currentTimeMillis()));
SelectedDetail.setRank(ranking);
}
else{
SelectedDetail = (CollectionSelectedDetail) getManager().getById(CollectionSelectedDetail.class, getId());
logInfo = SelectedDetail.getLogInformation();
}
logInfo.setActiveFlag(getCollection().getLogInformation().getActiveFlag());
logInfo.setLastUpdateDate(new Timestamp(System.currentTimeMillis()));
if(getModuleDescriptorId() != null && !"".equalsIgnoreCase(getModuleDescriptorId())){
descriptor = (Descriptor) getManager().getById(Descriptor.class, getModuleDescriptorId());
}else {
descriptor = null;
}
if(getCollection().getId() != null && !"".equalsIgnoreCase(getCollection().getId())){
collection = (ACollection) getManager().getById(ACollection.class, getCollection().getId());
}else{
collection = null;
}
if(getArticleId() != null && !"".equalsIgnoreCase(getArticleId())){
article = (Article) getManager().getById(Article.class, getArticleId());
}else{
article = null;
}
SelectedDetail.setDescriptor(descriptor);
SelectedDetail.setCollection(collection);
SelectedDetail.setArticleId(getArticleId());
SelectedDetail.setArticleName(getArticleDescription());
SelectedDetail.setLogInformation(logInfo);
getManager().save(SelectedDetail);
setId("");
setArticleId("");
setArticleDescription("");