Skip to content
Snippets Groups Projects
Commit aa34c664 authored by ginquin's avatar ginquin
Browse files

Bsuqeda de publicaciones con detalle, cambio en tema

parent 61519347
No related branches found
No related tags found
No related merge requests found
Showing
with 2476 additions and 77 deletions
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<dependency> <dependency>
<groupId>org.zkoss.theme</groupId> <groupId>org.zkoss.theme</groupId>
<artifactId>atlantic</artifactId> <artifactId>breeze</artifactId>
<version>${zk.version}</version> <version>${zk.version}</version>
</dependency> </dependency>
......
...@@ -10,6 +10,7 @@ import org.zkoss.zk.ui.select.annotation.VariableResolver; ...@@ -10,6 +10,7 @@ import org.zkoss.zk.ui.select.annotation.VariableResolver;
import org.zkoss.zk.ui.select.annotation.Wire; import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zkplus.spring.DelegatingVariableResolver; import org.zkoss.zkplus.spring.DelegatingVariableResolver;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.East; import org.zkoss.zul.East;
import org.zkoss.zul.Label; import org.zkoss.zul.Label;
import org.zkoss.zul.ListModelList; import org.zkoss.zul.ListModelList;
...@@ -18,6 +19,11 @@ import org.zkoss.zul.Textbox; ...@@ -18,6 +19,11 @@ import org.zkoss.zul.Textbox;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.Article; import es.uva.inf.tfg.ginquin.smellswisdom.domain.Article;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.Authorinstitution; import es.uva.inf.tfg.ginquin.smellswisdom.domain.Authorinstitution;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.DesignSmellRelatedActivity;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.PublicationType;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.Smell;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.TypeOfApproach;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.TypeOfArtefact;
import es.uva.inf.tfg.ginquin.smellswisdom.services.ArticleService; import es.uva.inf.tfg.ginquin.smellswisdom.services.ArticleService;
@VariableResolver(DelegatingVariableResolver.class) @VariableResolver(DelegatingVariableResolver.class)
...@@ -34,10 +40,14 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component> ...@@ -34,10 +40,14 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component>
@Wire @Wire
Textbox descripcionBusqueda; Textbox descripcionBusqueda;
@Wire
Combobox publicationTypesComboBox;
@WireVariable @WireVariable
ArticleService articleService; ArticleService articleService;
ListModelList<Article> articlesListModel; ListModelList<Article> articlesListModel;
ListModelList<PublicationType> publicationTypesListModel;
/** /**
...@@ -47,12 +57,29 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component> ...@@ -47,12 +57,29 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component>
East selectedArticleBlock; East selectedArticleBlock;
@Wire @Wire
Label articleTitle; Label titleArticle;
@Wire @Wire
Label annoArticle; Label annoArticle;
@Wire
Label automationApproach;
@Wire
Label mainActivityApproach;
@Wire
Label techniquesApproach;
@Wire
Listbox typeOfAprroachListbox;
@Wire @Wire
Listbox authorInstituionListBox; Listbox authorInstituionListBox;
@Wire
Listbox otherActivitiesApproachListbox;
@Wire
Listbox artefactsApproachListbox;
@Wire
Listbox smellsListBox;
@Wire @Wire
Label namePublication; Label namePublication;
...@@ -61,15 +88,22 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component> ...@@ -61,15 +88,22 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component>
@Wire @Wire
Label publisherPublication; Label publisherPublication;
ListModelList<TypeOfApproach> typeOfAprroachListModel;
ListModelList<Authorinstitution> authorInstituionListModel; ListModelList<Authorinstitution> authorInstituionListModel;
ListModelList<DesignSmellRelatedActivity> otherActivitiesApproachListModel;
ListModelList<TypeOfArtefact> artefactsApproachListModel;
ListModelList<Smell> smellsListModel;
Article selectedArticle; Article selectedArticle;
@Override @Override
public void doAfterCompose(Component comp) throws Exception { public void doAfterCompose(Component comp) throws Exception {
// TODO Auto-generated method stub
super.doAfterCompose(comp); super.doAfterCompose(comp);
publicationTypesListModel = new ListModelList<PublicationType>(PublicationType.values());
publicationTypesComboBox.setModel(publicationTypesListModel);
//Cargamos todos articulos
List<Article> allArticles = articleService List<Article> allArticles = articleService
.getArticles(); .getArticles();
articlesListModel = new ListModelList<Article>(allArticles); articlesListModel = new ListModelList<Article>(allArticles);
...@@ -77,7 +111,7 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component> ...@@ -77,7 +111,7 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component>
} }
@Listen("onSelect=#articlesListBox") @Listen("onSelect=#articlesListBox")
public void doSelectPublicacion() { public void doSelectArticle() {
if (articlesListModel.isSelectionEmpty()) { if (articlesListModel.isSelectionEmpty()) {
selectedArticle = null; selectedArticle = null;
...@@ -94,19 +128,39 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component> ...@@ -94,19 +128,39 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component>
public void doSearchArticle() { public void doSearchArticle() {
String keyWord = descripcionBusqueda.getValue().toUpperCase(); String keyWord = descripcionBusqueda.getValue().toUpperCase();
int posicion=publicationTypesComboBox.getSelectedIndex();
PublicationType type= null;
if(posicion!=-1)
type= publicationTypesListModel.get(posicion);
List<Article> allArticles=null; List<Article> allArticles=null;
//si no se ha introducido nada //si no se ha introducido nada
if (Strings.isBlank(keyWord)) { if (Strings.isBlank(keyWord) && publicationTypesListModel.isSelectionEmpty()==true) {
allArticles = articleService.getArticles(); allArticles = articleService.getArticles();
} }
// filtra los articulos por titulo. // filtra los articulos por titulo.
if (!Strings.isBlank(keyWord)) { if (!Strings.isBlank(keyWord) && publicationTypesListModel.isSelectionEmpty()==true) {
allArticles= articleService.searchArticles(keyWord); allArticles= articleService.searchArticles(keyWord, type, 1);
}
// filtra los articulos por tipo.
if (Strings.isBlank(keyWord) && publicationTypesListModel.isSelectionEmpty()==false) {
allArticles= articleService.searchArticles(keyWord, type, 2);
}
// filtra los articulos por titulo y titulo.
if (!Strings.isBlank(keyWord) && publicationTypesListModel.isSelectionEmpty()==false) {
allArticles= articleService.searchArticles(keyWord, type, 3);
} }
articlesListModel = new ListModelList<Article>(allArticles); articlesListModel = new ListModelList<Article>(allArticles);
articlesListBox.setModel(articlesListModel); articlesListBox.setModel(articlesListModel);
publicationTypesListModel.clearSelection();
//Refrescamos la vista al hacer la búsqueda.
selectedArticle=null;
refreshArticlesView();
} }
@Listen("onClick=#cancelDetail") @Listen("onClick=#cancelDetail")
...@@ -119,27 +173,61 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component> ...@@ -119,27 +173,61 @@ public class BusquedaDesignSmellsController extends SelectorComposer<Component>
} }
/**
* Permite refrescar la vista, dependiendo del articulo seleccionado.
*/
private void refreshArticlesView() { private void refreshArticlesView() {
if (selectedArticle == null) { if (selectedArticle == null) {
// Hace invisible la vista detalle. // Hace invisible la vista detalle.
selectedArticleBlock.setVisible(false); selectedArticleBlock.setVisible(false);
articleTitle.setValue(""); titleArticle.setValue("");
annoArticle.setValue("");
automationApproach.setValue("");
mainActivityApproach.setValue("");
techniquesApproach.setValue("");
typeOfAprroachListModel = null;
typeOfAprroachListbox.setModel(typeOfAprroachListModel);
otherActivitiesApproachListModel = null;
otherActivitiesApproachListbox.setModel(otherActivitiesApproachListModel);
artefactsApproachListModel = null;
artefactsApproachListbox.setModel(artefactsApproachListModel);
authorInstituionListModel = null; authorInstituionListModel = null;
authorInstituionListBox.setModel(authorInstituionListModel); authorInstituionListBox.setModel(authorInstituionListModel);
namePublication.setValue(""); namePublication.setValue("");
typePublication.setValue(""); typePublication.setValue("");
publisherPublication.setValue("");
} else { } else {
// Hace visible la vista detalle. // Hace visible la vista detalle.
selectedArticleBlock.setVisible(true); selectedArticleBlock.setVisible(true);
articleTitle.setValue(selectedArticle.getTitle()); titleArticle.setValue(selectedArticle.getTitle());
annoArticle.setValue(""+selectedArticle.getYear()); annoArticle.setValue(""+selectedArticle.getYear());
automationApproach.setValue(selectedArticle.getAutomation().getName());
mainActivityApproach.setValue(selectedArticle.getMainActivity().getName());
techniquesApproach.setValue(selectedArticle.getTechniques());
typeOfAprroachListModel = new ListModelList<TypeOfApproach>(selectedArticle.getTypeOfAprroach());
typeOfAprroachListbox.setModel(typeOfAprroachListModel);
otherActivitiesApproachListModel = null;
otherActivitiesApproachListModel = new ListModelList<DesignSmellRelatedActivity>(selectedArticle.getotherActivities());
otherActivitiesApproachListbox.setModel(otherActivitiesApproachListModel);
artefactsApproachListModel = new ListModelList<TypeOfArtefact>(selectedArticle.getTypeOfArtefacts());
artefactsApproachListbox.setModel(artefactsApproachListModel);
authorInstituionListModel = new ListModelList<Authorinstitution>(selectedArticle.getAuthorinstitutions()); authorInstituionListModel = new ListModelList<Authorinstitution>(selectedArticle.getAuthorinstitutions());
authorInstituionListBox.setModel(authorInstituionListModel); authorInstituionListBox.setModel(authorInstituionListModel);
smellsListModel = new ListModelList<Smell>(selectedArticle.getSmells());
smellsListBox.setModel(smellsListModel);
namePublication.setValue(selectedArticle.getNamePublication()); namePublication.setValue(selectedArticle.getNamePublication());
typePublication.setValue(""+selectedArticle.getPublicationType()); typePublication.setValue(""+selectedArticle.getType());
publisherPublication.setValue(selectedArticle.getPublication().getPublisher()); publisherPublication.setValue(selectedArticle.getPublication().getPublisher());
} }
......
package es.uva.inf.tfg.ginquin.smellswisdom.domain;
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
/**
* The persistent class for the approach database table.
*
*/
@Entity
@NamedQuery(name="Approach.findAll", query="SELECT a FROM Approach a")
public class Approach implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="approach_id")
private Integer approachId;
//indica si tiene(1) o no(0) ejemplos
private Integer presentexamples;
private String techniques;
@OneToOne(mappedBy = "approach")
private Article article;
@Column(name="automation_id")
private DegreeOfAutomation degreeOfAutomation;
@ElementCollection
@CollectionTable(name = "approachtypeofartefact", joinColumns={
@JoinColumn(name="approach_id")
})
@Column(name="typeofartefact_id")
List<TypeOfArtefact> typeOfArtefact;
@ElementCollection
@CollectionTable(name = "approachtypeofapproach", joinColumns={
@JoinColumn(name="approach_id")
})
@Column(name="typeofapproach_id")
List<TypeOfApproach> type;
@Column(name="mainactivity_id")
private DesignSmellRelatedActivity mainActivity;
@ElementCollection
@CollectionTable(name = "approachdesignsmellrelatedactivity", joinColumns={
@JoinColumn(name="approach_id")
})
@Column(name="designsmellrelatedactivity_id")
List<DesignSmellRelatedActivity> otherActivities;
public Approach() {
}
public Integer getApproachId() {
return this.approachId;
}
public void setApproachId(Integer approachId) {
this.approachId = approachId;
}
public Integer getPresentexamples() {
return this.presentexamples;
}
public void setPresentexamples(Integer presentexamples) {
this.presentexamples = presentexamples;
}
public String getTechniques() {
return this.techniques;
}
public void setTechniques(String techniques) {
this.techniques = techniques;
}
public Article getArticle() {
return article;
}
public void setArticle(Article article) {
this.article = article;
}
public DegreeOfAutomation getDegreeOfAutomation() {
return degreeOfAutomation;
}
public void setDegreeOfAutomation(DegreeOfAutomation degreeOfAutomation) {
this.degreeOfAutomation = degreeOfAutomation;
}
public List<TypeOfArtefact> getTypeOfArtefact() {
return typeOfArtefact;
}
public void setTypeOfArtefact(List<TypeOfArtefact> typeOfArtefact) {
this.typeOfArtefact = typeOfArtefact;
}
public List<TypeOfApproach> getType() {
return type;
}
public void setType(List<TypeOfApproach> type) {
this.type = type;
}
public DesignSmellRelatedActivity getMainActivity() {
return mainActivity;
}
public void setMainActivity(DesignSmellRelatedActivity mainActivity) {
this.mainActivity = mainActivity;
}
public List<DesignSmellRelatedActivity> getOtherActivities() {
return otherActivities;
}
public void setOtherActivities(List<DesignSmellRelatedActivity> otherActivities) {
this.otherActivities = otherActivities;
}
}
\ No newline at end of file
...@@ -6,7 +6,6 @@ import javax.persistence.*; ...@@ -6,7 +6,6 @@ import javax.persistence.*;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
* The persistent class for the article database table. * The persistent class for the article database table.
* *
...@@ -21,10 +20,8 @@ public class Article implements Serializable { ...@@ -21,10 +20,8 @@ public class Article implements Serializable {
@Column(name = "article_id") @Column(name = "article_id")
private Integer articleId; private Integer articleId;
@Column(name="approach_id") @Column(name="publicationtype_id")
private Integer approachId; private PublicationType type;
private PublicationType publicationtype_id;
private String title; private String title;
...@@ -39,6 +36,22 @@ public class Article implements Serializable { ...@@ -39,6 +36,22 @@ public class Article implements Serializable {
@JoinColumn(name = "publication_id") @JoinColumn(name = "publication_id")
private Publication publication; private Publication publication;
@ManyToMany
@JoinTable(
name="articlesmell"
, joinColumns={
@JoinColumn(name="article_id", nullable=false)
}
, inverseJoinColumns={
@JoinColumn(name="smell_id", nullable=false)
}
)
private List<Smell> smells;
@OneToOne
@JoinColumn(name = "approach_id")
private Approach approach;
public Article() { public Article() {
} }
...@@ -50,20 +63,12 @@ public class Article implements Serializable { ...@@ -50,20 +63,12 @@ public class Article implements Serializable {
this.articleId = articleId; this.articleId = articleId;
} }
public Integer getApproachId() { public PublicationType getType() {
return this.approachId; return type;
} }
public void setApproachId(Integer approachId) { public void setType(PublicationType type) {
this.approachId = approachId; this.type = type;
}
public PublicationType getPublicationType() {
return this.publicationtype_id;
}
public void setPublicationtypeId(PublicationType publicationType) {
this.publicationtype_id = publicationType;
} }
public String getTitle() { public String getTitle() {
...@@ -116,6 +121,14 @@ public class Article implements Serializable { ...@@ -116,6 +121,14 @@ public class Article implements Serializable {
return this.authorinstitutions; return this.authorinstitutions;
} }
public Approach getApproach() {
return approach;
}
public void setApproach(Approach approach) {
this.approach = approach;
}
public String getAutores() { public String getAutores() {
String autores = ""; String autores = "";
Iterator<Authorinstitution> iter = this.authorinstitutions.iterator(); Iterator<Authorinstitution> iter = this.authorinstitutions.iterator();
...@@ -135,16 +148,73 @@ public class Article implements Serializable { ...@@ -135,16 +148,73 @@ public class Article implements Serializable {
autores += auins.getFullNameAuthor() + "\n"; autores += auins.getFullNameAuthor() + "\n";
nRes--; nRes--;
} }
if (iter.hasNext()) autores += "..."; if (iter.hasNext())
autores += "...";
return autores; return autores;
} }
/** /**
* Obtiene el nombre de la publicación. * Obtiene el nombre de la publicación.
*
* @return nombre de la publicación. * @return nombre de la publicación.
*/ */
public String getNamePublication() { public String getNamePublication() {
return this.publication.getFullNamePublication(); return this.publication.getFullNamePublication();
} }
/**
* Obtiene los tipos de artefactos.
* @return tipos de artefactos.
*/
public List<TypeOfArtefact> getTypeOfArtefacts(){
return approach.getTypeOfArtefact();
}
/**
* Obtiene los tipos de approach.
* @return tipos de approach.
*/
public List<TypeOfApproach> getTypeOfAprroach() {
return approach.getType();
}
/**
* Obtiene el grado de automatización.
* @return grado de automatización.
*/
public DegreeOfAutomation getAutomation() {
return approach.getDegreeOfAutomation();
}
/**
* Obtiene la actividad principal.
* @return actividad principal.
*/
public DesignSmellRelatedActivity getMainActivity() {
return approach.getMainActivity();
}
/**
* obtiene las otras actividades.
* @return otras actividades.
*/
public List<DesignSmellRelatedActivity> getotherActivities() {
return approach.getOtherActivities();
}
/**
* Técnicas.
* @return técnicas.
*/
public String getTechniques() {
return approach.getTechniques();
}
public List<Smell> getSmells() {
return smells;
}
public void setSmells(List<Smell> smells) {
this.smells = smells;
}
} }
\ No newline at end of file
package es.uva.inf.tfg.ginquin.smellswisdom.domain;
public enum DegreeOfAutomation {
Fullyautomatic("Fully automatic"),
Semiautomatic("Semi automatic"),
Computeraided("Computer aided"),
Manualguideline("Manual guideline"),
UnknownOther("Unknown/Other");
private final String name;
DegreeOfAutomation(String name) {
this.name=name;
}
public String getName() {return name;}
}
package es.uva.inf.tfg.ginquin.smellswisdom.domain;
public enum DesignSmellRelatedActivity {
Specification("Smell Specification"),
Detection("Smell Detection"),
Correction("Smell Correction"),
Visualisation("Smell Visualisation"),
ImpactAnalysis("Smell Impact Analysis"),
Prioritization("Smell Prioritization"),
UnknownOther("Unknown/Other");
private final String name;
DesignSmellRelatedActivity(String name) {
this.name = name;
}
public String getName() {return name;}
}
package es.uva.inf.tfg.ginquin.smellswisdom.domain;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQuery;
/**
* The persistent class for the smell database table.
*
*/
@Entity
@NamedQuery(name="Smell.findAll", query="SELECT s FROM Smell s")
public class Smell implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="smell_id")
private Integer smellId;
private String description;
private String name;
//bi-directional many-to-many association to User
@ManyToMany(mappedBy="smells")
private List<Article> articles;
public Smell() {
}
public Integer getSmellId() {
return this.smellId;
}
public void setSmellId(Integer smellId) {
this.smellId = smellId;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public List<Article> getArticles() {
return articles;
}
public void setArticles(List<Article> articles) {
this.articles = articles;
}
}
\ No newline at end of file
package es.uva.inf.tfg.ginquin.smellswisdom.domain;
public enum TypeOfApproach {
MetricsBased("Metrics based"),
LogicalRuleBased("Rule based"),
SearchBased("Search based"),
MachineLearningBased("Machine learning based"),
GraphBased("Graph based"),
VisualizationBased("Visualization based"),
ModelBased("Model bases"),
ClusteringAnalysisBaed("Clustering analysis based"),
CollaborativeBased("Collaborative based"),
DependencyAnalysisBased("Dependency analysis based"),
ContextFeedbackAwareBased("Feedback based"),
FilterBased("Filter Based"),
HistoricalInformationBased("Historical information based"),
MultiCriteriaBased("Multi-criteria based"),
ProbabilityMatrixBased("Probability matrix based"),
GenerativeFromSpecification("Generative from Specification"),
SyntacticBased("Syntactic based"),
TextualBased("Textual based"),
UnknownOther("Unknown/Other");
private final String name;
TypeOfApproach(String name) {
this.name=name;
}
public String getName() {return name;}
}
package es.uva.inf.tfg.ginquin.smellswisdom.domain;
public enum TypeOfArtefact {
ExecutableorBynarycode("Executable or Binary Code"),
SourceCode("Source Code"),
Classdiagram("Class Diagram"),
CommunicationDiagram("Communication Diagram"),
ProcessDiagram("Process Diagram"),
TestCase("Test case"),
Ontology("Ontology"),
UknownOther("Unknown/Other");
private final String name;
TypeOfArtefact(String name) {
this.name=name;
}
public String getName() {return name;}
}
package es.uva.inf.tfg.ginquin.smellswisdom.domain.converters;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.DegreeOfAutomation;
@Converter(autoApply = true)
public class DegreeOfAutomationConverter implements AttributeConverter<DegreeOfAutomation,Integer> {
@Override
public Integer convertToDatabaseColumn(DegreeOfAutomation attribute) {
switch (attribute) {
case Fullyautomatic:
return 1;
case Semiautomatic:
return 2;
case Computeraided:
return 3;
case Manualguideline:
return 4;
case UnknownOther:
return 100;
default:
throw new IllegalArgumentException("Unknown" + attribute);
}
}
@Override
public DegreeOfAutomation convertToEntityAttribute(Integer dbData) {
switch (dbData) {
case 1:
return DegreeOfAutomation.Fullyautomatic;
case 2:
return DegreeOfAutomation.Semiautomatic;
case 3:
return DegreeOfAutomation.Computeraided;
case 4:
return DegreeOfAutomation.Manualguideline;
case 100:
return DegreeOfAutomation.UnknownOther;
default:
throw new IllegalArgumentException("Unknown" + dbData);
}
}
}
package es.uva.inf.tfg.ginquin.smellswisdom.domain.converters;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.DesignSmellRelatedActivity;
@Converter(autoApply = true)
public class DesignSmellRelatedActivityConverter
implements AttributeConverter<DesignSmellRelatedActivity,Integer> {
@Override
public Integer convertToDatabaseColumn(DesignSmellRelatedActivity attribute) {
switch (attribute) {
case Specification:
return 1;
case Detection:
return 2;
case Correction:
return 3;
case Visualisation:
return 4;
case ImpactAnalysis:
return 5;
case Prioritization:
return 6;
case UnknownOther:
return 100;
default:
throw new IllegalArgumentException("Unknown" + attribute);
}
}
@Override
public DesignSmellRelatedActivity convertToEntityAttribute(Integer dbData) {
switch (dbData) {
case 1:
return DesignSmellRelatedActivity.Specification;
case 2:
return DesignSmellRelatedActivity.Detection;
case 3:
return DesignSmellRelatedActivity.Correction;
case 4:
return DesignSmellRelatedActivity.Visualisation;
case 5:
return DesignSmellRelatedActivity.ImpactAnalysis;
case 6:
return DesignSmellRelatedActivity.Prioritization;
case 100:
return DesignSmellRelatedActivity.UnknownOther;
default:
throw new IllegalArgumentException("Unknown" + dbData);
}
}
}
package es.uva.inf.tfg.ginquin.smellswisdom.domain; package es.uva.inf.tfg.ginquin.smellswisdom.domain.converters;
import javax.persistence.AttributeConverter; import javax.persistence.AttributeConverter;
import javax.persistence.Converter; import javax.persistence.Converter;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.PublicationType;
@Converter(autoApply = true) @Converter(autoApply = true)
public class PublicationTypeConverter implements AttributeConverter<PublicationType, Integer> { public class PublicationTypeConverter implements AttributeConverter<PublicationType, Integer> {
......
package es.uva.inf.tfg.ginquin.smellswisdom.domain.converters;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.TypeOfApproach;
@Converter(autoApply=true)
public class TypeOfApproachConverter implements AttributeConverter<TypeOfApproach, Integer>{
@Override
public Integer convertToDatabaseColumn(TypeOfApproach attribute) {
switch (attribute) {
case MetricsBased:
return 1;
case LogicalRuleBased:
return 2;
case SearchBased:
return 3;
case MachineLearningBased:
return 4;
case GraphBased:
return 5;
case VisualizationBased:
return 6;
case ModelBased:
return 7;
case ClusteringAnalysisBaed:
return 8;
case CollaborativeBased:
return 9;
case DependencyAnalysisBased:
return 11;
case ContextFeedbackAwareBased:
return 12;
case FilterBased:
return 13;
case HistoricalInformationBased:
return 14;
case MultiCriteriaBased:
return 16;
case ProbabilityMatrixBased:
return 17;
case GenerativeFromSpecification:
return 18;
case SyntacticBased:
return 19;
case TextualBased:
return 20;
case UnknownOther:
return 100;
default:
throw new IllegalArgumentException("Unknown" + attribute);
}
}
@Override
public TypeOfApproach convertToEntityAttribute(Integer dbData) {
switch (dbData) {
case 1:
return TypeOfApproach.MetricsBased;
case 2:
return TypeOfApproach.LogicalRuleBased;
case 3:
return TypeOfApproach.SearchBased;
case 4:
return TypeOfApproach.MachineLearningBased;
case 5:
return TypeOfApproach.GraphBased;
case 6:
return TypeOfApproach.VisualizationBased;
case 7:
return TypeOfApproach.ModelBased;
case 8:
return TypeOfApproach.ClusteringAnalysisBaed;
case 9:
return TypeOfApproach.CollaborativeBased;
case 11:
return TypeOfApproach.DependencyAnalysisBased;
case 12:
return TypeOfApproach.ContextFeedbackAwareBased;
case 13:
return TypeOfApproach.FilterBased;
case 14:
return TypeOfApproach.HistoricalInformationBased;
case 16:
return TypeOfApproach.MultiCriteriaBased;
case 17:
return TypeOfApproach.ProbabilityMatrixBased;
case 18:
return TypeOfApproach.GenerativeFromSpecification;
case 19:
return TypeOfApproach.SyntacticBased;
case 20:
return TypeOfApproach.TextualBased;
case 100:
return TypeOfApproach.UnknownOther;
default:
throw new IllegalArgumentException("Unknown" + dbData);
}
}
}
package es.uva.inf.tfg.ginquin.smellswisdom.domain.converters;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.TypeOfArtefact;
@Converter(autoApply=true)
public class TypeOfArtefactConverter<Y> implements AttributeConverter<TypeOfArtefact, Integer> {
@Override
public Integer convertToDatabaseColumn(TypeOfArtefact attribute) {
switch (attribute) {
case ExecutableorBynarycode:
return 1;
case SourceCode:
return 2;
case Classdiagram:
return 3;
case CommunicationDiagram:
return 4;
case ProcessDiagram:
return 5;
case TestCase:
return 6;
case Ontology:
return 7;
case UknownOther:
return 100;
default:
throw new IllegalArgumentException("Unknown" + attribute);
}
}
@Override
public TypeOfArtefact convertToEntityAttribute(Integer dbData) {
switch (dbData) {
case 1:
return TypeOfArtefact.ExecutableorBynarycode;
case 2:
return TypeOfArtefact.SourceCode;
case 3:
return TypeOfArtefact.Classdiagram;
case 4:
return TypeOfArtefact.CommunicationDiagram;
case 5:
return TypeOfArtefact.ProcessDiagram;
case 6:
return TypeOfArtefact.TestCase;
case 7:
return TypeOfArtefact.Ontology;
case 100:
return TypeOfArtefact.UknownOther;
default:
throw new IllegalArgumentException("Unknown" + dbData);
}
}
}
...@@ -3,6 +3,7 @@ package es.uva.inf.tfg.ginquin.smellswisdom.services; ...@@ -3,6 +3,7 @@ package es.uva.inf.tfg.ginquin.smellswisdom.services;
import java.util.List; import java.util.List;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.Article; import es.uva.inf.tfg.ginquin.smellswisdom.domain.Article;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.PublicationType;
public interface ArticleService { public interface ArticleService {
/** /**
...@@ -23,5 +24,5 @@ public interface ArticleService { ...@@ -23,5 +24,5 @@ public interface ArticleService {
* @param keyWord palabra clave de búsqueda. * @param keyWord palabra clave de búsqueda.
* @return lista de articulos que coinciden. * @return lista de articulos que coinciden.
*/ */
List<Article> searchArticles(String keyWord); List<Article> searchArticles(String keyWord,PublicationType type,int caso);
} }
...@@ -4,13 +4,13 @@ import java.util.List; ...@@ -4,13 +4,13 @@ import java.util.List;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import javax.persistence.Query; import javax.persistence.TypedQuery;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.Article; import es.uva.inf.tfg.ginquin.smellswisdom.domain.Article;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.PublicationType;
@Repository @Repository
public class ArticleDao { public class ArticleDao {
...@@ -20,7 +20,7 @@ public class ArticleDao { ...@@ -20,7 +20,7 @@ public class ArticleDao {
@Transactional(readOnly = true) @Transactional(readOnly = true)
public List<Article> queryAll() { public List<Article> queryAll() {
Query query = em.createQuery("SELECT a FROM Article a"); TypedQuery<Article> query = em.createQuery("SELECT a FROM Article a",Article.class);
List<Article> result = query.getResultList(); List<Article> result = query.getResultList();
return result; return result;
} }
...@@ -31,18 +31,45 @@ public class ArticleDao { ...@@ -31,18 +31,45 @@ public class ArticleDao {
} }
@Transactional @Transactional
public List<Article> searchGlobalArticles(String keyWord) { public List<Article> searchGlobalArticles(String keyWord, PublicationType type, int caso) {
String consulta = ""; String consulta = "";
switch (caso) {
case 1:
// recupera los articulos por título. // recupera los articulos por título.
consulta = "SELECT ar From Article ar where UPPER(ar.title) LIKE '%" consulta = "SELECT ar From Article ar where UPPER(ar.title) LIKE :keyWord";
+ keyWord + "%'" ; break;
case 2:
// recupera los articulos por tipo.
consulta = "SELECT ar From Article ar where ar.type=:type";
break;
case 3:
consulta = "SELECT ar From Article ar " + "where UPPER(ar.title) LIKE :keyWord and ar.type=:type";
break;
default:
break;
}
TypedQuery<Article> query = em.createQuery(consulta, Article.class);
switch (caso) {
case 1:
query.setParameter("keyWord", "%"+keyWord+"%");
break;
case 2:
query.setParameter("type", type);
break;
case 3:
query.setParameter("keyWord", "%"+keyWord+"%");
query.setParameter("type", type);
break;
default:
break;
}
Query query = em.createQuery(consulta);
List<Article> result = query.getResultList(); List<Article> result = query.getResultList();
return result; return result;
} }
} }
...@@ -8,6 +8,7 @@ import org.springframework.context.annotation.ScopedProxyMode; ...@@ -8,6 +8,7 @@ import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.Article; import es.uva.inf.tfg.ginquin.smellswisdom.domain.Article;
import es.uva.inf.tfg.ginquin.smellswisdom.domain.PublicationType;
import es.uva.inf.tfg.ginquin.smellswisdom.services.ArticleService; import es.uva.inf.tfg.ginquin.smellswisdom.services.ArticleService;
@Service("articleService") @Service("articleService")
...@@ -19,20 +20,17 @@ public class ArticleServiceImpl implements ArticleService{ ...@@ -19,20 +20,17 @@ public class ArticleServiceImpl implements ArticleService{
@Override @Override
public List<Article> getArticles() { public List<Article> getArticles() {
// TODO Auto-generated method stub
return dao.queryAll(); return dao.queryAll();
} }
@Override @Override
public Article getArticle(Integer article_id) { public Article getArticle(Integer article_id) {
// TODO Auto-generated method stub
return dao.getArticle(article_id); return dao.getArticle(article_id);
} }
@Override @Override
public List<Article> searchArticles(String keyWord) { public List<Article> searchArticles(String keyWord,PublicationType type,int caso) {
// TODO Auto-generated method stub return dao.searchGlobalArticles(keyWord,type, caso);
return dao.searchGlobalArticles(keyWord);
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment