public float[] getAllWorstScores() {
return allWorstScores;
}
private void initialize() throws Exception {
ArtifactWeight weight = collabReview.getMeasurementsManager().getArtifactWeight();
Repository repository = collabReview.getRepository();
reviewsByUser = repository.listReviewsBy(user).toArray(new Review[repository.listReviewsBy(user).size()]);
allActiveArtifactIds = repository.listNonObsoleteArtifacts(null).toArray(new ArtifactIdentifier[repository.listNonObsoleteArtifacts(null).size()]);
Set<Review> allReviewsTemp = new HashSet<Review>();
for (ArtifactIdentifier ai : allActiveArtifactIds) {
allReviewsTemp.addAll(repository.listReviews(ai.getName(), ai.getBranch()));
}
allReviews = allReviewsTemp.toArray(new Review[allReviewsTemp.size()]);
//Review[] reviewsUser = Review.listReviewsFrom(user);
//Review[] reviewsAll = Review.listAllReviews();
//Revision[] revisionsUser = Revision.listRevisionsFrom(user);
//Revision[] revisionsAll = Revision.listAllRevisions();
//Set<Document> participateDocumentsUser = new HashSet<Document>();
//Set<Document> participateDocumentsAll = new HashSet<Document>();
//lists all documents which are not deleted
//Document[] documents = Document.listDocuments();
// ******************************************
// **** determine best-worst documents ****
// ******************************************
// Some kind of sweep algorithm that finds the 5 best/worst documents and sorts them into an array using bubble sort
myWorstDocuments = new Artifact[5];
allWorstDocuments = new Artifact[5];
myBestDocuments = new Artifact[5];
allBestDocuments = new Artifact[5];
myBestScores = new float[5];
myWorstScores = new float[5];
allBestScores = new float[5];
allWorstScores = new float[5];
// Fills the best/worst score arrays with an extreme value
for (int i = 0; i < 5; i++) {
allBestScores[i] = -11;
allWorstScores[i] = +11;
myBestScores[i] = -11;
myWorstScores[i] = +11;
}
myFatalDocument = null;
allFatalDocument = null;
int myReviewTendency = 0;
int allReviewTendency = 0;
int myOverallResponsibilityScore = 0;
int allOverallResponsibilityScore = 0;
float myWeightedReviewCount = 0;
float allWeightedReviewCount = 0;
float myFatalDocumentScore = Float.MAX_VALUE;
float allFatalDocumentScore = Float.MAX_VALUE;
double myOverallQualityScore = 0;
double allOverallQualityScore = 0;
if (reviewsByUser.length > 0) {
for (Review reviewUser : reviewsByUser) {
myReviewTendency += reviewUser.getRating();
myWeightedReviewCount += reviewUser.getTimeliness();
}
myReviewTendency /= reviewsByUser.length;
}
if (allReviews.length > 0) {
for (Review reviewAll : allReviews) {
allReviewTendency += reviewAll.getRating();
allWeightedReviewCount += reviewAll.getTimeliness();
}
allReviewTendency /= allReviews.length;
}
for (ArtifactIdentifier artId : allActiveArtifactIds) {
Artifact artifact = repository.getLatestForName(artId.getName(), artId.getBranch());
Float artifactQuality = collabReview.getMeasurementsManager().getArtifactQualityAssessor().assessQuality(artId);
if (artifactQuality == null) {
continue;
}
float myResponsibilityScore = weight.measure(artifact) * collabReview.getMeasurementsManager().getArtifactResponsibility().assessResponsibility(artifact, user);
if (myResponsibilityScore != 0) {
// DocumentLength * Participation * QualityRating
float myQualityScore = myResponsibilityScore * artifactQuality;
// checks if the current document score is worse than one of the five worst scores
// if yes: score and document will be added to the according tables for worst rated documents
if (artifactQuality < myWorstScores[4]) {
myWorstScores[4] = artifactQuality;
myWorstDocuments[4] = artifact;
for (int j = 4; j > 0; j--) {
if (myWorstScores[j] < myWorstScores[j - 1]) {
float score = myWorstScores[j];
Artifact a = myWorstDocuments[j];
myWorstScores[j] = myWorstScores[j - 1];
myWorstScores[j - 1] = score;
myWorstDocuments[j] = myWorstDocuments[j - 1];
myWorstDocuments[j - 1] = a;
}
}
}
// checks if the current document score is better than one of the five best scores
// if yes: score and document will be added to the according tables for best rated documents
if (artifactQuality > myBestScores[4]) {
myBestScores[4] = artifactQuality;
myBestDocuments[4] = artifact;
for (int j = 4; j > 0; j--) {
if (myBestScores[j] > myBestScores[j - 1]) {
float score = myBestScores[j];
Artifact a = myBestDocuments[j];
myBestScores[j] = myBestScores[j - 1];
myBestScores[j - 1] = score;
myBestDocuments[j] = myBestDocuments[j - 1];
myBestDocuments[j - 1] = a;
}
}
}
if (myQualityScore < myFatalDocumentScore) {
myFatalDocumentScore = myQualityScore;
myFatalDocument = artifact;
}
// overall scores
myOverallQualityScore += myQualityScore;
myOverallResponsibilityScore += myResponsibilityScore;
}
// DocumentLength * Participation * QualityRating
float qualityScore = weight.measure(artifact) * artifactQuality;
if (qualityScore < allWorstScores[4]) {
allWorstScores[4] = qualityScore;
allWorstDocuments[4] = artifact;
for (int j = 4; j > 0; j--) {
if (allWorstScores[j] < allWorstScores[j - 1]) {