Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static ArrayList<MethodWrapper> getMethods(ArrayList<Pair<String, String>
for (MethodWrapper method : methods.values()) {


if (method.getUpdateOperation().equals(Constants.METHOD_DELETED) || method.isTrainingMethod())
if (method.getUpdateOperation().equals(Constants.METHOD_DELETED))
continue;

filteredList.add(method);
Expand Down Expand Up @@ -187,20 +187,31 @@ private static ArrayList<MethodWrapper> filterList(ArrayList<Pair<String, String

for (String methodSignature : methods.keySet()) {

if ((filters.contains(Constants.FILE_FILTER) && !methodSignature.contains(currentFile))
|| (!filters.contains(Constants.DELETED_FILTER) && methods.get(methodSignature).getUpdateOperation().equals(Constants.METHOD_DELETED))
|| (methods.get(methodSignature).isTrainingMethod() && !filters.contains(Constants.TRAIN_FILTER)))
continue;

for (Category category : methods.get(methodSignature).getCategories()) {

if ((filters.contains(Constants.DELETED_FILTER) && methods.get(methodSignature).getUpdateOperation().equals(Constants.METHOD_DELETED))
|| filters.contains(new Pair<>(Constants.FILTER_TYPE, Formatter.toTitleCase(category.toString())))
|| filters.contains(new Pair<>(Constants.FILTER_CWE, Formatter.toTitleCase(category.toString())))
|| (methods.get(methodSignature).isTrainingMethod() && filters.contains(Constants.TRAIN_FILTER))) {

filteredList.add(methods.get(methodSignature));
break;
if(filters.size()==1 && filters.contains(Constants.TRAIN_FILTER) && methods.get(methodSignature).isTrainingMethod()){
filteredList.add(methods.get(methodSignature));
}else if((filters.contains(Constants.FILE_FILTER) && !methodSignature.contains(currentFile))
|| (!filters.contains(Constants.DELETED_FILTER) && methods.get(methodSignature).getUpdateOperation().equals(Constants.METHOD_DELETED))){
} else if (filters.size()>1 && filters.contains(Constants.TRAIN_FILTER)) {
for (Category category : methods.get(methodSignature).getCategories()) {
Pair<String, String> typePair = new Pair<>(Constants.FILTER_TYPE, Formatter.toTitleCase(category.toString()));
Pair<String, String> cwePair = new Pair<>(Constants.FILTER_CWE, Formatter.toTitleCase(category.toString()));
boolean isDeleted = filters.contains(Constants.DELETED_FILTER) && methods.get(methodSignature).getUpdateOperation().equals(Constants.METHOD_DELETED);
boolean isTypeFilter = filters.contains(typePair) || filters.contains(cwePair);
if ((isDeleted || isTypeFilter) && methods.get(methodSignature).isTrainingMethod()){
filteredList.add(methods.get(methodSignature));
break;
}
}
} else{
for (Category category : methods.get(methodSignature).getCategories()) {
Pair<String, String> typePair = new Pair<>(Constants.FILTER_TYPE, Formatter.toTitleCase(category.toString()));
Pair<String, String> cwePair = new Pair<>(Constants.FILTER_CWE, Formatter.toTitleCase(category.toString()));
boolean isDeleted = filters.contains(Constants.DELETED_FILTER) && methods.get(methodSignature).getUpdateOperation().equals(Constants.METHOD_DELETED);
boolean isTypeFilter = filters.contains(typePair) || filters.contains(cwePair);
if (isDeleted || isTypeFilter ){
filteredList.add(methods.get(methodSignature));
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,12 @@ private void loadMethods() {

classNode.add(addCategoriesToNode(method));

if (method.getMethod().isKnown())
if (method.getMethod().isKnown()) {
method.setTrainingMethod(true);
standardSrms.add(classNode);
else
}else{
currentProject.add(classNode);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.fraunhofer.iem.swan.assist.util;

import java.util.Objects;

public class Pair<T,U> {
private final T key;
private final U value;
Expand All @@ -16,4 +18,31 @@ public T getKey() {
public U getValue() {
return this.value;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

if (obj == null || getClass() != obj.getClass()) {
return false;
}

Pair<?, ?> pair = (Pair<?, ?>) obj;

if (!Objects.equals(key, pair.key)) {
return false;
}

return Objects.equals(value, pair.value);
}

@Override
public int hashCode() {
int result = key != null ? key.hashCode() : 0;
result = 31 * result + (value != null ? value.hashCode() : 0);
return result;
}

}