This notebook is a collection of code snippets and technical "how to" instructions.
Search This Blog
HTML link to open email client
by: Zainab Aziz<a href="mailto:YourName@me.com?subject=Hi" >email link </a>
Hibernate Detached criteria with projections (GROUP BY)
by: Zainab Azizpublic List
fetchDetailMetrics(Date dateFrom, Date dateTo, String navPage, String navOption, OrganizationDTO org) {
List
pageViews = new ArrayList (); log.warn("Date from " + dateFrom + " to " + dateTo);
DetachedCriteria metrics = DetachedCriteria.forClass(MetricsForUserSession.class);
metrics.add(Expression.between("dateTime", dateFrom, dateTo));
metrics.add(Expression.eq("navOption", navOption));
metrics.add(Expression.eq("navPage", navPage));
if (org != null)
{
log.warn(" org " + org.getName());
metrics.add(Expression.eq("organization.id", org.getId()));
}
ProjectionList projectList = Projections.projectionList();
// group by
projectList.add(Projections.groupProperty("entityId"));
// alias of the column head
projectList.add(Projections.alias(Projections.rowCount(), "count"));
metrics.setProjection(projectList);
// order by, sorting
metrics.addOrder(Order.desc("count"));
List
if (results == null || results.size() <>
log.warn("fetched nothing");
else
log.warn("fetched " + results.size());
log.warn("fetched navPages " + results.size());
for (Object[] column : results)
{
log.warn(column[0] + " " + column[1]);
PageView pageView = new PageView();
determineDescription(pageView, column, navPage);
pageView.setViewCount(new Integer(column[1].toString()));
pageViews.add(pageView);
}
return pageViews;
}
Converting string value to an int
by: Zainab Aziznew Integer( numericValueObject.toString() )
GWT: Migrate GWT from 1.4 to 1.5
by: Zainab Azizmvn install:install-file -DgroupId=net.sf.hibernate4gwt -DartifactId=hibernate4gwt -Dversion=1.1b -Dpackaging=jar -Dfile="path to jar"/hibernate4gwt-1.1b.jar
Java Date
by: Zainab Aziz/** Format: May 16, 2008 */ public static String formatDefaultUSA(Date date) { String countryCode = "US"; String languageCode = "en"; return convertToLocalized(date, countryCode, languageCode, DateFormat.DEFAULT); } public static String convertToLocalized(Date date, String countryCode, String languageCode, int format) { Locale locale = new Locale(languageCode, countryCode); DateFormat df = DateFormat.getDateInstance(format, locale); return df.format(date); } /** Format: 5/14/08 */ public static String formatShortUsa(Date date) { String countryCode = "US"; String languageCode = "en"; int format = DateFormat.SHORT; return convertToLocalized(date, countryCode, languageCode, format); }
Buying iPhone 3G with GPS
by: Uki D. LucasMySQL creating a dump (backup)
by: Uki D. LucasHow to publish Javadoc on Google Code
by: David Wolverton- Upload the javadocs to the google code svn repository for the project.
- Change the MIME type of these javadoc pages from text/plain to text/html and text/css. This is done with subclipse (in Eclipse) as follows
- Right-click the folder that contains the javadocs. Select [Team] -> [Set Property...].
- Name: "svn:mime-type", Value: "text/html".
- Select "Set property recursively" and click OK.
- Set the property for the individual css file in the same way to "text/css".
- Commit the changes to the svn repository.
- In Google Code, browse the project source to the index.html of the javadoc.
- Select "View raw file". Just link to that URL as your published Javadoc.
I got all my information here:
http://stuffthathappens.com/blog/2007/11/09/howto-publish-javadoc-on-google-code/