Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
srenberg committed Jan 11, 2012
1 parent 042633f commit 2218898
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 54 deletions.
Binary file added src/.DS_Store
Binary file not shown.
Expand Up @@ -76,7 +76,7 @@
<targetField>Project_Snapshot__c.Date__c</targetField>
</mappings>
<name>Project Status Analytic Snapshot</name>
<runningUser>labs@labs.116</runningUser>
<runningUser>labs03s@labs.com</runningUser>
<sourceReport>Milestone_Project_Management/Project_Snapshot</sourceReport>
<targetObject>Project_Snapshot__c</targetObject>
</AnalyticSnapshot>
35 changes: 27 additions & 8 deletions src/classes/Milestone1_Charts_GanttController.cls
Expand Up @@ -28,17 +28,24 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
*/
public with sharing class Milestone1_Charts_GanttController {

public String mytarget {get; set;}
public String mytarget {get;
set{
this.mytarget = value;
init();
}
}
public String objectType {get;set;}
public String startDateFieldName {get;set;}
public String endDateFieldName {get;set;}
public String idFieldName {get;set;}
public String fullViewURL {get;set;}
public String projectGanttJson{get;set;}

private String nameFieldName;
private String completedFieldName;
private String filterFieldName;


private List<Sobject> sobjectList;
private static final String REGEXP_QUOTES = '(?<!\\\\)"';

Expand All @@ -47,14 +54,26 @@ public with sharing class Milestone1_Charts_GanttController {
public static final String COLOR_FUTURE = '#666666';
public static final String COLOR_CURRENT = '#2299bb';

public String getProjectGanttJson() {
public Milestone1_Charts_GanttController()
{
init();
}

private void init()
{
if (myTarget != null)
{
initFieldNames();
retrieveData();
projectGanttJson = toJSon();

String ret;
initFieldNames();
retrieveData();
ret = toJSon();
}
}

public String getProjectGanttJson() {

return ret;
init();
return projectGanttJson;
}

/*
Expand Down Expand Up @@ -209,7 +228,7 @@ public with sharing class Milestone1_Charts_GanttController {
Milestone1_Charts_GanttController cls = new Milestone1_Charts_GanttController();
cls.mytarget = m2.Id;
String ret = cls.getProjectGanttJson();

System.debug(LoggingLevel.Info, '12345:' + ret);

System.assert(ret.indexOf(COLOR_FUTURE) > -1);
Expand Down
10 changes: 8 additions & 2 deletions src/classes/Milestone1_Milestone_Trigger_Utility.cls
Expand Up @@ -146,8 +146,14 @@ public with sharing class Milestone1_Milestone_Trigger_Utility {
Integer deadlineShift = oldRec.Deadline__c.daysBetween(newRec.Deadline__c);
if(kickoffShift == deadlineShift && deadlineShift != 0 && taskMap.containsKey(newRec.Id)) {
for(Milestone1_Task__c task: taskMap.get(newRec.Id)) {
task.Start_Date__c = task.Start_Date__c.addDays(deadlineShift);
task.Due_Date__c = task.Due_Date__c.addDays(deadlineShift);
if (task.Start_Date__c != null)
{
task.Start_Date__c = task.Start_Date__c.addDays(deadlineShift);
}
if (task.Due_Date__c != null)
{
task.Due_Date__c = task.Due_Date__c.addDays(deadlineShift);
}
}
tasksToUpdate.addAll(taskMap.get(newRec.Id));
}
Expand Down
196 changes: 178 additions & 18 deletions src/classes/Milestone1_Summary2.cls
Expand Up @@ -35,6 +35,7 @@ public with sharing class Milestone1_Summary2 {
public List<Milestone1_Milestone__c> milestoneResults {get; private set;}
public List<Milestone1_Task__c> taskResults {get; private set;}
public boolean displaySearchError {private get; private set;}
public boolean searchLengthError {private get; private set;}
public List<Pair> recentItems {get; private set;}

public boolean hasSearchResultsError {
Expand All @@ -43,6 +44,12 @@ public with sharing class Milestone1_Summary2 {
}
}

public boolean hasSearchLengthError{
get{
return searchLengthError != null && searchLengthError == true;
}
}

public boolean hasProjectResults {
get {
return projectResults != null && !projectResults.isEmpty();
Expand All @@ -61,21 +68,77 @@ public with sharing class Milestone1_Summary2 {
}
}

public boolean hasSettings{
get{
return settings != null;
}
}

public boolean isDeployed{
get{
Id myProfileId = UserInfo.getProfileId();
Profile myProfile = [Select Id, Name from Profile where Id=:myProfileId];

Boolean objectsDeployed = true;
if (myProfile.Name != 'System Administrator')
{

try{

Schema.DescribeFieldResult F = Schema.SObjectType.Milestone1_Milestone__C.fields.Name;
if ( F.isAccessible() == true)
{
return true;
}
else
{
return false;
}
return true;
}
catch (System.UnexpectedException e)
{


return false;
}

}
return objectsDeployed;
}
}



public Milestone1_Settings__c settings = Milestone1_Settings__c.getInstance();

public void initialize() {
List<Milestone1_Project__c> recentProjects = [Select Id, Name from Milestone1_Project__c order by LastModifiedDate desc limit 5];
List<Milestone1_Milestone__c> recentMilestones = [Select Id, Name from Milestone1_Milestone__c order by LastModifiedDate desc limit 50];
List<Milestone1_Task__c> recentTasks = [Select Id, Name from Milestone1_Task__c order by LastModifiedDate desc limit 100];

this.recentItems = new List<Pair>();
this.recentItems.addAll(createPairObjects(recentProjects, 'Project: '));
this.recentItems.addAll(createPairObjects(recentMilestones, 'Milestone: '));
this.recentItems.addAll(createPairObjects(recentTasks, 'Task: '));

if (isDeployed)
{
List<Milestone1_Project__c> recentProjects = [Select Id, Name from Milestone1_Project__c order by LastModifiedDate desc limit 5];
List<Milestone1_Milestone__c> recentMilestones = [Select Id, Name from Milestone1_Milestone__c order by LastModifiedDate desc limit 50];
List<Milestone1_Task__c> recentTasks = [Select Id, Name from Milestone1_Task__c order by LastModifiedDate desc limit 100];

this.recentItems = new List<Pair>();
this.recentItems.addAll(createPairObjects(recentProjects, 'Project: '));
this.recentItems.addAll(createPairObjects(recentMilestones, 'Milestone: '));
this.recentItems.addAll(createPairObjects(recentTasks, 'Task: '));
}
}


public void searchProjects() {
if (searchText.length() < 2)
{
this.searchLengthError = true;
return;
}
else
{
this.searchLengthError = false;
}

List<List<SObject>> searchList = [FIND :searchText in all fields returning
Milestone1_Project__c (Id, Name, Owner.Name, Status__c LIMIT 5),
Milestone1_Milestone__c (Id, Name, Project__r.Name LIMIT 10),
Expand Down Expand Up @@ -106,17 +169,88 @@ public with sharing class Milestone1_Summary2 {

public List<Milestone1_Project__c> getProjects() {

List<Milestone1_Project__c> activeProjects = [Select m.Id, m.Total_Open_Task_Count__c, m.Total_Complete_Task_Count__c,
m.Total_Blocked_Task_Count__c, m.Total_Late_Task_Count__c, m.Status_TasksOpenBlockedLate__c,
m.Total_Hours_Budget__c, m.Total_Hours_Budget_from_Milestones__c, m.Total_Hours_Estimate__c, m.Total_Hours_Incurred__c,
m.Status_BudgetMiletoneEstimate__c, m.Status_BudgetExpenseSummary__c, m.Name, m.Deadline__c, m.Kickoff__c,
m.Duration__c, m.GoogleGanntUrl__c
From Milestone1_Project__c m where m.status__c = 'Active'];


return activeProjects;

return (List<Milestone1_Project__c>) setCon.getRecords();

}


public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[Select m.Id, m.Total_Open_Task_Count__c, m.Total_Complete_Task_Count__c,
m.Total_Blocked_Task_Count__c, m.Total_Late_Task_Count__c, m.Status_TasksOpenBlockedLate__c,
m.Total_Hours_Budget__c, m.Total_Hours_Budget_from_Milestones__c, m.Total_Hours_Estimate__c, m.Total_Hours_Incurred__c,
m.Status_BudgetMiletoneEstimate__c, m.Status_BudgetExpenseSummary__c, m.Name, m.Deadline__c, m.Kickoff__c,
m.Duration__c, m.GoogleGanntUrl__c
From Milestone1_Project__c m where m.status__c = 'Active']));
setCon.setPageSize(20);
}
return setCon;
}
set;
}


//Boolean to check if there are more records after the present displaying records
public Boolean hasNext
{
get
{
return setCon.getHasNext();
}
set;
}

//Boolean to check if there are more records before the present displaying records
public Boolean hasPrevious
{
get
{
return setCon.getHasPrevious();
}
set;
}

//Page number of the current displaying records
public Integer pageNumber
{
get
{
return setCon.getPageNumber();
}
set;
}

public Integer totalPages
{
get
{
Integer pages = (setCon.getResultSize() / 20);
if (math.mod(setCon.getResultSize(), 20) != 0)
{
pages += 1;
}
return pages;
}
set;
}

//Returns the previous page of records
public void previous()
{
setCon.previous();
}

//Returns the next page of records
public void next()
{
setCon.next();
}



public Pagereference view() {

return new Pagereference('/' + targetProject);
Expand All @@ -127,6 +261,7 @@ public with sharing class Milestone1_Summary2 {
}

public Pagereference viewBlockedTasks() {

return new Pagereference('/' + settings.Report_Id_Blocked_Tasks_by_Project__c + '?pv0=' + String.valueOf(targetProject).substring(0,15) );
}

Expand All @@ -143,18 +278,22 @@ public with sharing class Milestone1_Summary2 {
}

public Pagereference incompleteTasksByProject() {

return new Pagereference('/' + settings.Report_Id_My_Tasks_By_Project_Milesto__c + '?pv0=' + Encodingutil.urlEncode(''+UserInfo.getName(), 'UTF-8' ));
}

public Pagereference incompleteTasksByPriority() {

return new Pagereference('/' + settings.Report_Id_My_Tasks_By_Priority_Project__c + '?pv0=' + Encodingutil.urlEncode(''+UserInfo.getName(), 'UTF-8' ) );
}

public Pagereference summaryMyLateTasks() {

return new Pagereference('/' + settings.Report_Id_My_Late_Tasks__c + '?pv0=' + Encodingutil.urlEncode(''+UserInfo.getName(), 'UTF-8' ) );
}

public Pagereference summaryMyBlockedTasks() {

return new Pagereference('/' + settings.Report_Id_My_Blocked_Tasks__c + '?pv0=' + Encodingutil.urlEncode(''+UserInfo.getName(), 'UTF-8' ) );
}

Expand Down Expand Up @@ -190,7 +329,8 @@ public with sharing class Milestone1_Summary2 {
insert p1;
Integer i2 = summary2.getProjects().size();

System.assert(i2 == i+1);
System.assert(i2 == 20);


//make sure we get page references back
summary2.targetProject = p1.id;
Expand All @@ -204,12 +344,32 @@ public with sharing class Milestone1_Summary2 {
System.assert(summary2.recentItems != null);

//Test.setFixedSearchResults(new Id[] {p1.Id});
summary2.searchText = 's';
summary2.searchProjects();
System.assertEquals(true, summary2.hasSearchLengthError);


summary2.searchText = 'Test';
summary2.searchProjects();
System.assert(summary2.hasSearchResultsError);
System.assert(!summary2.hasProjectResults);
System.assert(!summary2.hasMilestoneResults);
System.assert(!summary2.hasTaskResults);



System.assertEquals(1, summary2.pageNumber);


if(summary2.hasNext == true)
{
summary2.next();
}
if(summary2.hasPrevious == true)
{
summary2.previous();
}

}

}
17 changes: 0 additions & 17 deletions src/classes/Milestone1_Test_Task_Dependency.cls
Expand Up @@ -85,23 +85,6 @@ private class Milestone1_Test_Task_Dependency {

}

/**
* Create a batch of tasks
*/
public static Map<String,Milestone1_Task__c> manyTasks(Milestone1_Milestone__c parentMilestone, Integer size){

Map<String,Milestone1_Task__c> tasksMap = new Map<String,Milestone1_Task__c>();
Milestone1_Task__c task;
List<Milestone1_Task__c> tasks = new List<Milestone1_Task__c>();
for(Integer i = 0; i < size; i++){
task = Milestone1_Test_Utility.sampleTask(parentMilestone.Id);
task.Name = 'ts'+i;
tasksMap.put(task.Name,task);
}
insert tasksMap.values();
return tasksMap;
}

public static void areShiftedMilestones (Map<String,Milestone1_Milestone__c> milestonesOriginal,
Map<String,Milestone1_Milestone__c> milestones, Integer numberOfDaysShifted){

Expand Down

0 comments on commit 2218898

Please sign in to comment.