| 1 | |
package org.kuali.student.lum.program.client; |
| 2 | |
|
| 3 | |
import com.google.gwt.event.shared.EventHandler; |
| 4 | |
import com.google.gwt.event.shared.GwtEvent; |
| 5 | |
|
| 6 | |
import org.kuali.student.common.assembly.data.Data; |
| 7 | |
import org.kuali.student.common.ui.client.application.Application; |
| 8 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
| 9 | |
|
| 10 | |
import java.util.ArrayList; |
| 11 | |
import java.util.HashMap; |
| 12 | |
import java.util.List; |
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | 0 | public class ProgramRegistry { |
| 18 | |
|
| 19 | |
private static Data data; |
| 20 | |
|
| 21 | |
private static int row; |
| 22 | |
|
| 23 | |
private static Enum<?> section; |
| 24 | |
|
| 25 | 0 | private static HashMap<GwtEvent.Type, EventHandler> specializationHandlers = new HashMap<GwtEvent.Type, EventHandler>(); |
| 26 | |
|
| 27 | 0 | private static boolean createNew = false; |
| 28 | |
|
| 29 | |
public static Data getData() { |
| 30 | 0 | return data; |
| 31 | |
} |
| 32 | |
|
| 33 | |
public static void setData(Data data) { |
| 34 | 0 | ProgramRegistry.data = data; |
| 35 | 0 | } |
| 36 | |
|
| 37 | |
public static int getRow() { |
| 38 | 0 | return row; |
| 39 | |
} |
| 40 | |
|
| 41 | |
public static void setRow(int row) { |
| 42 | 0 | ProgramRegistry.row = row; |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
public static Enum<?> getSection() { |
| 46 | 0 | return section; |
| 47 | |
} |
| 48 | |
|
| 49 | |
public static void setSection(Enum<?> section) { |
| 50 | 0 | ProgramRegistry.section = section; |
| 51 | 0 | } |
| 52 | |
|
| 53 | |
public static void addHandler(GwtEvent.Type<?> type, EventHandler handler) { |
| 54 | 0 | specializationHandlers.put(type, handler); |
| 55 | 0 | } |
| 56 | |
|
| 57 | |
public static HashMap<GwtEvent.Type, EventHandler> getSpecializationHandlers() { |
| 58 | 0 | return specializationHandlers; |
| 59 | |
} |
| 60 | |
|
| 61 | |
public static boolean isCreateNew() { |
| 62 | 0 | return createNew; |
| 63 | |
} |
| 64 | |
|
| 65 | |
public static void setCreateNew(boolean createNew) { |
| 66 | 0 | ProgramRegistry.createNew = createNew; |
| 67 | 0 | } |
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
public static List<ValidationResultInfo> getVariationWarnings(){ |
| 75 | 0 | String variationPath = ProgramConstants.VARIATIONS+"/"+org.kuali.student.lum.program.client.ProgramRegistry.getRow()+"/"; |
| 76 | 0 | List<ValidationResultInfo> validationWarnings = Application.getApplicationContext().getValidationWarnings(); |
| 77 | 0 | List<ValidationResultInfo> variationWarnings = new ArrayList<ValidationResultInfo>(); |
| 78 | 0 | for (ValidationResultInfo vr:validationWarnings){ |
| 79 | 0 | if (vr.getElement().contains(variationPath)){ |
| 80 | 0 | ValidationResultInfo newVr = new ValidationResultInfo(vr.getElement().substring(variationPath.length())); |
| 81 | 0 | newVr.setWarning(vr.getMessage()); |
| 82 | 0 | variationWarnings.add(newVr); |
| 83 | 0 | } |
| 84 | |
} |
| 85 | |
|
| 86 | 0 | return variationWarnings; |
| 87 | |
} |
| 88 | |
} |