com.pureinfo.srmcenter.datasync.client.domain.impl.SyncConfigInfoMgrImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.pureinfo.srmcenter.datasync.client.domain.impl.SyncConfigInfoMgrImpl.java

Source

/**
 * PureInfo QuakeCenter
 * @(#)SyncConfigInfoMgrImpl.java   1.0 Dec 2, 2005
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

package com.pureinfo.srmcenter.datasync.client.domain.impl;

import org.apache.commons.lang.time.DateUtils;

import com.pureinfo.ark.content.domain.impl.ContentMgrImpl;
import com.pureinfo.dolphin.model.IObjects;
import com.pureinfo.dolphin.persister.IStatement;
import com.pureinfo.force.exception.PureException;
import com.pureinfo.srmcenter.datasync.client.domain.ISyncConfigInfoMgr;
import com.pureinfo.srmcenter.datasync.client.model.SyncConfigInfo;

/**
 * <P>
 * Created on Dec 2, 2005 10:43:15 AM <BR>
 * Last modified on Dec 2, 2005
 * </P>
 * 
 * @author Freeman.Hu
 * @version 1.0, Dec 2, 2005
 * @since QuakeCenter 1.0
 */
public class SyncConfigInfoMgrImpl extends ContentMgrImpl implements ISyncConfigInfoMgr {

    public SyncConfigInfo lookupBySchoolCode(String _sSchoolCode) throws PureException {
        IStatement query = null;
        IObjects objects = null;
        try {
            String Sql = "select * from {this} where {this.schoolCode} = ?";
            query = createQuery(Sql, 1);
            query.setString(0, _sSchoolCode);
            objects = query.executeQuery();
            SyncConfigInfo syncConfig = (SyncConfigInfo) objects.next();
            if (syncConfig == null) {
                syncConfig = new SyncConfigInfo();
                syncConfig.setSchoolCode(_sSchoolCode);
                syncConfig.setActiveInterval(DateUtils.MILLIS_PER_HOUR);
                syncConfig.setSyncInterval(DateUtils.MILLIS_PER_DAY);
                save(syncConfig);
            }
            return syncConfig;
        } finally {
            if (query != null)
                query.clear();
            if (objects != null)
                objects.clear();
        }
    }
}