List of usage examples for org.hibernate.type StringType INSTANCE
StringType INSTANCE
To view the source code for org.hibernate.type StringType INSTANCE.
Click Source Link
From source file:org.yamj.core.database.dao.CommonDao.java
License:Open Source License
public List<ApiCertificationDTO> getCertifications(ApiWrapperList<ApiCertificationDTO> wrapper) { OptionsSingleType options = (OptionsSingleType) wrapper.getOptions(); SqlScalars sqlScalars = new SqlScalars(); sqlScalars.addToSql("SELECT DISTINCT cert.id, cert.country_code as countryCode, cert.certificate "); String sortBy = options.getSortby(); if ("certificate".equalsIgnoreCase(sortBy)) { sortBy = "certificate_order"; // TODO certificate_order until now just tested with MySQL sqlScalars.addToSql(/* ww w . j a va 2 s . c o m*/ ", CASE WHEN cast(certificate as signed)>0 THEN cast(certificate as signed) ELSE ascii(substring(lower(certificate),1,1))*1000+ascii(substring(lower(certificate),2,1)) END as certificate_order "); } sqlScalars.addToSql("FROM certification cert "); if (options.getType() != null) { if (MetaDataType.MOVIE == options.getType()) { sqlScalars.addToSql("JOIN videodata_certifications vc ON cert.id=vc.cert_id "); } else { sqlScalars.addToSql("JOIN series_certifications sc ON cert.id=sc.cert_id "); } } sqlScalars.addToSql(options.getSearchString(true)); sqlScalars.addToSql(options.getSortString(sortBy)); sqlScalars.addScalar("id", LongType.INSTANCE); sqlScalars.addScalar("countryCode", StringType.INSTANCE); sqlScalars.addScalar("certificate", StringType.INSTANCE); return executeQueryWithTransform(ApiCertificationDTO.class, sqlScalars, wrapper); }
From source file:org.yamj.core.database.dao.CommonDao.java
License:Open Source License
public List<ApiRatingDTO> getRatings(ApiWrapperList<ApiRatingDTO> wrapper) { OptionsRating options = (OptionsRating) wrapper.getOptions(); boolean justMovie = (MetaDataType.MOVIE == options.getType()); boolean justSeries = (MetaDataType.SERIES == options.getType()); StringBuilder sb = new StringBuilder(); sb.append("SELECT DISTINCT "); sb.append("grouped.type as type, "); sb.append("grouped.sourcedb as source "); if (options.getRating() == null || options.getRating()) { sb.append(", round(grouped.rating/10) as rating "); }// w ww . j a v a 2 s . c o m sb.append("FROM ( "); if (!justSeries) { // not just series if (StringUtils.isBlank(options.getSource())) { sb.append("select distinct '"); sb.append(MetaDataType.MOVIE.toString()); sb.append("' as type, v1.rating, v1.sourcedb, v1.videodata_id, 2 as ordering "); sb.append("from videodata_ratings v1 "); sb.append("UNION "); sb.append("select distinct '"); sb.append(MetaDataType.MOVIE.toString()); sb.append( "' as type, avg(v2.rating) as rating, 'combined' as sourcedb, v2.videodata_id, 1 as ordering "); sb.append("from videodata_ratings v2 "); sb.append("group by v2.videodata_id "); } else if ("combined".equalsIgnoreCase(options.getSource())) { sb.append("select distinct '"); sb.append(MetaDataType.MOVIE.toString()); sb.append( "' as type, avg(v2.rating) as rating, 'combined' as sourcedb, v2.videodata_id, 1 as ordering "); sb.append("from videodata_ratings v2 "); sb.append("group by v2.videodata_id "); } else { sb.append("select distinct '"); sb.append(MetaDataType.MOVIE.toString()); sb.append("' as type, v1.rating, v1.sourcedb, v1.videodata_id, 2 as ordering "); sb.append("from videodata_ratings v1 "); sb.append("where v1.sourcedb='"); sb.append(options.getSource().toLowerCase()); sb.append("' "); } } if (!justMovie) { if (!justSeries) { sb.append("UNION "); } // not just movies if (StringUtils.isBlank(options.getSource())) { sb.append("select distinct '"); sb.append(MetaDataType.SERIES.toString()); sb.append("' as type, s1.rating, s1.sourcedb, s1.series_id, 2 as ordering "); sb.append("from series_ratings s1 "); sb.append("UNION "); sb.append("select distinct '"); sb.append(MetaDataType.SERIES.toString()); sb.append( "' as type, avg(s2.rating) as rating, 'combined' as sourcedb, s2.series_id, 1 as ordering "); sb.append("from series_ratings s2 "); sb.append("group by s2.series_id"); } else if ("combined".equalsIgnoreCase(options.getSource())) { sb.append("select distinct '"); sb.append(MetaDataType.SERIES.toString()); sb.append( "' as type, avg(s2.rating) as rating, 'combined' as sourcedb, s2.series_id, 1 as ordering "); sb.append("from series_ratings s2 "); sb.append("group by s2.series_id "); } else { sb.append("select distinct '"); sb.append(MetaDataType.SERIES.toString()); sb.append("' as type, s1.rating, s1.sourcedb, s1.series_id, 2 as ordering "); sb.append("from series_ratings s1 "); sb.append("where s1.sourcedb='"); sb.append(options.getSource().toLowerCase()); sb.append("' "); } } sb.append(") as grouped "); // order by sb.append("order by type, grouped.ordering, source"); if (options.getRating() == null || options.getRating()) { sb.append(", rating"); } sb.append("DESC".equalsIgnoreCase(options.getSortdir()) ? " DESC" : " ASC"); // add scalars SqlScalars sqlScalars = new SqlScalars(sb); sqlScalars.addScalar("type", StringType.INSTANCE); sqlScalars.addScalar("source", StringType.INSTANCE); if (options.getRating() == null || options.getRating()) { sqlScalars.addScalar("rating", IntegerType.INSTANCE); } return executeQueryWithTransform(ApiRatingDTO.class, sqlScalars, wrapper); }
From source file:org.yamj.core.database.dao.MediaDao.java
License:Open Source License
public List<ApiNameDTO> getVideoSources(ApiWrapperList<ApiNameDTO> wrapper) { OptionsSingleType options = (OptionsSingleType) wrapper.getOptions(); SqlScalars sqlScalars = new SqlScalars(); sqlScalars.addToSql("SELECT DISTINCT mf.video_source as name "); sqlScalars.addToSql("FROM mediafile mf "); if (options.getType() != null) { sqlScalars.addToSql("JOIN mediafile_videodata mv ON mf.id=mv.mediafile_id "); if (MetaDataType.MOVIE == options.getType()) { sqlScalars.addToSql("JOIN videodata vd ON vd.id=mv.videodata_id and vd.episode < 0 "); } else {//from ww w . j av a 2 s .c o m sqlScalars.addToSql("JOIN videodata vd ON vd.id=mv.videodata_id and vd.episode > -1 "); } } sqlScalars.addToSql("WHERE mf.video_source is not null "); sqlScalars.addToSql(options.getSortString("mf.video_source")); sqlScalars.addScalar("name", StringType.INSTANCE); return executeQueryWithTransform(ApiNameDTO.class, sqlScalars, wrapper); }
From source file:org.zanata.magpie.model.type.LocaleCodeType.java
License:Open Source License
public LocaleCodeType() { super(StringType.INSTANCE.getSqlTypeDescriptor(), LocaleCodeTypeDescriptor.INSTANCE); }
From source file:org.zanata.model.type.ConditionRuleActionType.java
License:Open Source License
public ConditionRuleActionType() { super(StringType.INSTANCE.getSqlTypeDescriptor(), ConditionRuleActionTypeDescriptor.INSTANCE); }
From source file:org.zanata.model.type.ContentTypeType.java
License:Open Source License
public ContentTypeType() { super(StringType.INSTANCE.getSqlTypeDescriptor(), ContentTypeTypeDescriptor.INSTANCE); }
From source file:org.zanata.model.type.EntityStatusType.java
License:Open Source License
public EntityStatusType() { super(StringType.INSTANCE.getSqlTypeDescriptor(), EntityStatusTypeDescriptor.INSTANCE); }
From source file:org.zanata.model.type.EntityTypeType.java
License:Open Source License
public EntityTypeType() { super(StringType.INSTANCE.getSqlTypeDescriptor(), EntityTypeTypeDescriptor.INSTANCE); }
From source file:org.zanata.model.type.LocaleIdType.java
License:Open Source License
public LocaleIdType() { super(StringType.INSTANCE.getSqlTypeDescriptor(), LocaleIdTypeDescriptor.INSTANCE); }
From source file:org.zanata.model.type.LocaleRoleType.java
License:Open Source License
public LocaleRoleType() { super(StringType.INSTANCE.getSqlTypeDescriptor(), LocaleRoleDescriptor.INSTANCE); }