// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java
// public class PersistenceException extends Exception {
// 
// 	/** Copyright notice. */
// 	public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009";
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private String errorMessage = null;
// 	private int errorCode = 0;
// 	private String sqlState = null;
// 
// 	/**
// 	 * 
// 	 */
// 	public PersistenceException() {
// 	}
// 
// 	/**
// 	 * 
// 	 * @param msg
// 	 */
// 	public PersistenceException(String msg) {
// 		super(msg);
// 	}
// 
// 	/**
// 	 * 
// 	 * @param detailMessage
// 	 * @param throwable
// 	 */
// 	public PersistenceException(String detailMessage, Throwable throwable) {
// 		super(detailMessage, throwable);
// 	}
// 
// 	/**
// 	 * 
// 	 * @param throwable
// 	 */
// 	public PersistenceException(Throwable throwable) {
// 		super(throwable);
// 	}
// 
// 	/**
// 	 * 
// 	 * @param message
// 	 * @param errorMessage
// 	 * @param errorCode
// 	 * @param sqlState
// 	 */
// 	public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) {
// 		super(message);
// 
// 		this.errorMessage = errorMessage;
// 		this.errorCode = errorCode;
// 		this.sqlState = sqlState;
// 	}
// 
// 	/**
// 	 * 
// 	 * @return
// 	 */
// 	public int getErrorCode() {
// 		return errorCode;
// 	}
// 
// 	/**
// 	 * 
// 	 * @param errorCode
// 	 */
// 	public void setErrorCode(int errorCode) {
// 		this.errorCode = errorCode;
// 	}
// 
// 	/**
// 	 * 
// 	 * @return
// 	 */
// 	public String getErrorMessage() {
// 		return errorMessage;
// 	}
// 
// 	/**
// 	 * 
// 	 * @param errorMessage
// 	 */
// 	public void setErrorMessage(String errorMessage) {
// 		this.errorMessage = errorMessage;
// 	}
// 
// 	/**
// 	 * 
// 	 * @return
// 	 */
// 	public String getSqlState() {
// 		return sqlState;
// 	}
// 
// 	/**
// 	 * 
// 	 * @param sqlState
// 	 */
// 	public void setSqlState(String sqlState) {
// 		this.sqlState = sqlState;
// 	}
// }


import java.util.logging.Level;
import fabric.Fabric;
import fabric.registry.FabricRegistry;
import fabric.registry.QueryScope;
import fabric.registry.RegistryObject;
import fabric.registry.Type;
import fabric.registry.TypeFactory;
import fabric.registry.exception.DuplicateKeyException;
import fabric.registry.exception.IncompleteObjectException;
import fabric.registry.exception.PersistenceException;
import fabric.registry.exception.RegistryQueryException;
import fabric.registry.persistence.IPersistenceResultRow;
        SELECT_ALL_QUERY_SERVICE_TYPES = Fabric.format("select * from %s", FabricRegistry.FEED_TYPES);
        SELECT_ALL_QUERY_NODE_TYPES = Fabric.format("select * from %s", FabricRegistry.NODE_TYPES);
        SELECT_ALL_QUERY_PLATFORM_TYPES = Fabric.format("select * from %s", FabricRegistry.PLATFORM_TYPES);
        SELECT_ALL_QUERY_SYSTEM_TYPES = Fabric.format("select * from %s", FabricRegistry.SYSTEM_TYPES);
        SELECT_ALL_SERVICE_WIRING = Fabric.format("select * from %s", FabricRegistry.SYSTEM_WIRING);

        BY_ID_QUERY_ACTOR_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.ACTOR_TYPES);
        BY_ID_QUERY_SERVICE_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.FEED_TYPES);
        BY_ID_QUERY_NODE_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.NODE_TYPES);
        BY_ID_QUERY_PLATFORM_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'",
                FabricRegistry.PLATFORM_TYPES);
        BY_ID_QUERY_SYSTEM_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.SYSTEM_TYPES);

        PREDICATE_QUERY_ACTOR_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.ACTOR_TYPES);
        PREDICATE_QUERY_SERVICE_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.FEED_TYPES);
        PREDICATE_QUERY_NODE_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.NODE_TYPES);
        PREDICATE_QUERY_PLATFORM_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.PLATFORM_TYPES);
        PREDICATE_QUERY_SYSTEM_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.SYSTEM_TYPES);
    }

    public static TypeFactory getInstance(QueryScope queryScope) {

        if (queryScope == QueryScope.LOCAL) {
            return localQueryInstance;
        } else {
            return remoteQueryInstance;
        }
    }

    @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java
// public class PersistenceException extends Exception {
// 
// 	/** Copyright notice. */
// 	public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009";
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private String errorMessage = null;
// 	private int errorCode = 0;
// 	private String sqlState = null;
// 
// 	/**
// 	 * 
// 	 */
// 	public PersistenceException() {
// 	}
// 
// 	/**
// 	 * 
// 	 * @param msg
// 	 */
// 	public PersistenceException(String msg) {
// 		super(msg);
// 	}
// 
// 	/**
// 	 * 
// 	 * @param detailMessage
// 	 * @param throwable
// 	 */
// 	public PersistenceException(String detailMessage, Throwable throwable) {
// 		super(detailMessage, throwable);
// 	}
// 
// 	/**
// 	 * 
// 	 * @param throwable
// 	 */
// 	public PersistenceException(Throwable throwable) {
// 		super(throwable);
// 	}
// 
// 	/**
// 	 * 
// 	 * @param message
// 	 * @param errorMessage
// 	 * @param errorCode
// 	 * @param sqlState
// 	 */
// 	public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) {
// 		super(message);
// 
// 		this.errorMessage = errorMessage;
// 		this.errorCode = errorCode;
// 		this.sqlState = sqlState;
// 	}
// 
// 	/**
// 	 * 
// 	 * @return
// 	 */
// 	public int getErrorCode() {
// 		return errorCode;
// 	}
// 
// 	/**
// 	 * 
// 	 * @param errorCode
// 	 */
// 	public void setErrorCode(int errorCode) {
// 		this.errorCode = errorCode;
// 	}
// 
// 	/**
// 	 * 
// 	 * @return
// 	 */
// 	public String getErrorMessage() {
// 		return errorMessage;
// 	}
// 
// 	/**
// 	 * 
// 	 * @param errorMessage
// 	 */
// 	public void setErrorMessage(String errorMessage) {
// 		this.errorMessage = errorMessage;
// 	}
// 
// 	/**
// 	 * 
// 	 * @return
// 	 */
// 	public String getSqlState() {
// 		return sqlState;
// 	}
// 
// 	/**
// 	 * 
// 	 * @param sqlState
// 	 */
// 	public void setSqlState(String sqlState) {
// 		this.sqlState = sqlState;
// 	}
// }


// Path: fabric.lib/src/fabric/registry/impl/TypeFactoryImpl.java
import java.util.logging.Level;
import fabric.Fabric;
import fabric.registry.FabricRegistry;
import fabric.registry.QueryScope;
import fabric.registry.RegistryObject;
import fabric.registry.Type;
import fabric.registry.TypeFactory;
import fabric.registry.exception.DuplicateKeyException;
import fabric.registry.exception.IncompleteObjectException;
import fabric.registry.exception.PersistenceException;
import fabric.registry.exception.RegistryQueryException;
import fabric.registry.persistence.IPersistenceResultRow;

        SELECT_ALL_QUERY_SERVICE_TYPES = Fabric.format("select * from %s", FabricRegistry.FEED_TYPES);
        SELECT_ALL_QUERY_NODE_TYPES = Fabric.format("select * from %s", FabricRegistry.NODE_TYPES);
        SELECT_ALL_QUERY_PLATFORM_TYPES = Fabric.format("select * from %s", FabricRegistry.PLATFORM_TYPES);
        SELECT_ALL_QUERY_SYSTEM_TYPES = Fabric.format("select * from %s", FabricRegistry.SYSTEM_TYPES);
        SELECT_ALL_SERVICE_WIRING = Fabric.format("select * from %s", FabricRegistry.SYSTEM_WIRING);

        BY_ID_QUERY_ACTOR_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.ACTOR_TYPES);
        BY_ID_QUERY_SERVICE_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.FEED_TYPES);
        BY_ID_QUERY_NODE_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.NODE_TYPES);
        BY_ID_QUERY_PLATFORM_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'",
                FabricRegistry.PLATFORM_TYPES);
        BY_ID_QUERY_SYSTEM_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.SYSTEM_TYPES);

        PREDICATE_QUERY_ACTOR_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.ACTOR_TYPES);
        PREDICATE_QUERY_SERVICE_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.FEED_TYPES);
        PREDICATE_QUERY_NODE_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.NODE_TYPES);
        PREDICATE_QUERY_PLATFORM_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.PLATFORM_TYPES);
        PREDICATE_QUERY_SYSTEM_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.SYSTEM_TYPES);
    }

    public static TypeFactory getInstance(QueryScope queryScope) {

        if (queryScope == QueryScope.LOCAL) {
            return localQueryInstance;
        } else {
            return remoteQueryInstance;
        }
    }

    @Override
    public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {