ngs-doo / revenj

DSL Platform compatible backend

Home Page:https://dsl-platform.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

snowflake with sorting and paging

araneta opened this issue · comments

Is it possible to create a snowflake with sorting and paging? please give me some examples
Thanks

i want the order by is using parameter is it possible?

commented

Query API can be used for custom sorting. https://github.com/ngs-doo/revenj/blob/master/java/test/src/test/java/org/revenj/TestQuery.java#L388
Cube also has it's own (simpler) sorting

i want to put sorting and paging inside specification filterSearch, because search usually have sort and paging. is it possible?
Thanks
snowflake CourseOfferedList from CourseOffered{
ID;
University.ID as UniversityID;
Program.ID as ProgramID;
code;
name;
credit;
CourseType.ID as CourseTypeID;
CourseType.name as CourseType;

	specification filterSearch 'it =>
		it.UniversityID == univId &&
		it.ProgramID == programId && (
			filter == null ||
			filter == "" ||
			it.code.ToLower().Contains(filter.ToLower()) ||
			it.name.ToLower().Contains(filter.ToLower()))' {
		int     univId;
		int programId;
		String? filter;
	}
}
commented

Specification is just a predicate. If you wish to have filter + sort + paging you will have to provide additional parameters alongside specification.
If you want such definition inside DSL then you can write report, eg: https://github.com/ngs-doo/revenj/blob/master/java/test/src/test/resources/model.dsl#L121
You can use params for limit/offset

ok i will try it. Thanks

snowflake CourseOfferedList from CourseOffered{
ID;
University.ID as UniversityID;
Program.ID as ProgramID;
code;
name;
credit;
CourseType.ID as CourseTypeID;
CourseType.name as CourseType;

	specification findByUniversity 'it => it.UniversityID == univId'
	{
		int univId;
	}
	specification findByProgram 'it => it.UniversityID == univId && it.ProgramID == programId'
	{
		int univId;
		int programId;
	}
	specification findByCourseType 'it => it.UniversityID == univId && it.CourseTypeID == courseTypeId'
	{
		int univId;
		int courseTypeId;
	}
	specification filterSearch 'it =>
		it.UniversityID == univId &&
		it.ProgramID == programId && (
			filter == null ||
			filter == "" ||
			it.code.ToLower().Contains(filter.ToLower()) ||
			it.name.ToLower().Contains(filter.ToLower()))' {
		int     univId;
		int programId;
		String? filter;
	}
	order by code asc;
}

why this order by code asc; does not work?
it generates this view

CREATE OR REPLACE VIEW university."CourseOfferedList" AS
SELECT _entity."ID"::text AS "URI",
_entity."ID",
"_entity_University"."ID" AS "UniversityID",
"_entity_Program"."ID" AS "ProgramID",
_entity.code,
_entity.name,
_entity.credit,
"_entity_CourseType"."ID" AS "CourseTypeID",
"_entity_CourseType".name AS "CourseType"
FROM university."CourseOffered_entity" _entity
JOIN university."University_entity" "_entity_University" ON "_entity_University"."ID" = _entity."UniversityID"
JOIN university."Program_entity" "_entity_Program" ON "_entity_Program"."ID" = _entity."ProgramID"
JOIN university."CourseType_entity" "_entity_CourseType" ON "_entity_CourseType"."ID" = _entity."CourseTypeID";

ALTER TABLE university."CourseOfferedList"
OWNER TO postgres;
COMMENT ON VIEW university."CourseOfferedList"
IS 'NGS volatile';

commented

It works, but it's not in the view.

so i have to use report instead of snowflake to use sorting and paging?

commented

no? you can use query api to get that also. see link above to query test

ok i will use query