Created
April 17, 2017 23:51
-
-
Save bryceosterhaus/ed973066ac32a4a424e9622c42f72c92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void viewLoopDivisionHierarchy() throws Exception { | |
if (!isRespondingTo("json")) { | |
return; | |
} | |
LoopDivision loopDivision = LoopDivisionUtil.fetchLoopDivision(request, themeDisplay); | |
_validateView(loopDivision); | |
JSONArray childLoopDivisionJSONArray = JSONFactoryUtil.createJSONArray(); | |
int type = ParamUtil.getInteger(request, "type"); | |
if (!ArrayUtil.contains(LoopDivisionConstants.TYPES, type)) { | |
type = loopDivision.getType(); | |
} | |
List<LoopDivision> childLoopDivisions = alloyServiceInvoker.executeDynamicQuery(new Object[] {"companyId", themeDisplay.getCompanyId(), "parentLoopDivisionId", loopDivision.getLoopDivisionId(), "type", type}); | |
for (LoopDivision childLoopDivision : childLoopDivisions) { | |
childLoopDivisionJSONArray.put(getHierarchyJSONObject(childLoopDivision, JSONFactoryUtil.createJSONArray())); | |
} | |
JSONObject loopDivisionHierarchyJSONObject = getHierarchyJSONObject(loopDivision, childLoopDivisionJSONArray); | |
while (loopDivision.getType() != LoopDivisionConstants.TYPE_ROOT) { | |
LoopDivision parentLoopDivision = LoopDivisionLocalServiceUtil.fetchLoopDivision(loopDivision.getParentLoopDivisionId()); | |
loopDivisionHierarchyJSONObject = getHierarchyJSONObject(parentLoopDivision, _getSiblingLoopDivisionCompositeJSONArray(loopDivision, loopDivisionHierarchyJSONObject)); | |
loopDivision = parentLoopDivision; | |
} | |
respondWith(loopDivisionHierarchyJSONObject); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment