Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2003 Draagon Software LLC. All Rights Reserved.
*
* This software is the proprietary information of Draagon Software LLC.
* Use is subject to license terms.
*/
package com.draagon.meta.manager.xml;
import com.draagon.meta.*;
import com.draagon.meta.manager.*;
import com.draagon.meta.manager.exp.Expression;
import com.draagon.meta.manager.exp.Range;
import com.draagon.meta.manager.exp.SortOrder;
import com.draagon.util.xml.XMLFileReader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.*;
import java.util.*;
// import javax.servlet.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//import org.xml.sax.InputSource;
//import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
//import org.xml.sax.SAXParseException;
//import org.xml.sax.SAXNotRecognizedException;
//import org.xml.sax.SAXNotSupportedException;
/**
* The Object Manager Base is able to add, update, delete,
* and retrieve objects of those types from a datastore.
*/
public class ObjectManagerXML extends ObjectManager
{
private static Log log = LogFactory.getLog( ObjectManagerXML.class );
private Map> tables = new Hashtable>();
private String mRoot = null;
public ObjectManagerXML()
{
}
public void setLocation( String root )
{
mRoot = root;
}
public String getLocation()
{
return mRoot;
}
///////////////////////////////////////////////////////
// CONNECTION HANDLING METHODS
//
/**
* Retrieves a connection object representing the datastore
*/
public ObjectConnection getConnection()
throws MetaException
{
return new ObjectConnectionXML( tables );
}
public void releaseConnection( ObjectConnection oc )
throws MetaException
{
oc.close();
}
///////////////////////////////////////////////////////
// PERSISTENCE METHODS
//
/** Is this a createable class */
public boolean isCreateableClass( MetaClass mc ) {
return true;
}
/** Is this a readable class */
public boolean isReadableClass( MetaClass mc ) {
return true;
}
/** Gets the update mapping to the DB */
public boolean isUpdateableClass( MetaClass mc ) {
return true;
}
/** Gets the delete mapping to the DB */
public boolean isDeleteableClass( MetaClass mc ) {
return true;
}
//protected MappingHandler getDefaultMappingHandler() {
// return new SimpleMappingHandlerXML();
//}
/**
* Retrieves the fields of a MetaClass which are persistable
*/
@SuppressWarnings("unchecked")
public Collection getWriteableFields( MetaClass mc )
{
final String KEY = "getWriteableFields()";
ArrayList fields = (ArrayList) mc.getCacheValue( KEY );
if ( fields == null )
{
fields = new ArrayList();
for( Iterator i = mc.getMetaFields().iterator(); i.hasNext(); )
{
MetaField f = (MetaField) i.next();
if ( isWriteableField( f )) fields.add( f );
}
mc.setCacheValue( KEY, fields );
}
/*if ( fields.size() == 0 )
throw new MetaException( "No persistable fields for MetaClass [" + mc + "]" );*/
return fields;
}
/**
* Retrieves the fields of a MetaClass which are persistable
*/
@SuppressWarnings("unchecked")
public Collection getReadableFields( MetaClass mc )
{
final String KEY = "getReadableFields()";
ArrayList fields = (ArrayList) mc.getCacheValue( KEY );
if ( fields == null )
{
fields = new ArrayList();
for( Iterator i = mc.getMetaFields().iterator(); i.hasNext(); )
{
MetaField f = (MetaField) i.next();
if ( isReadableField( f )) fields.add( f );
}
mc.setCacheValue( KEY, fields );
}
/*if ( fields.size() == 0 )
throw new MetaException( "No persistable fields for MetaClass [" + mc + "]" );*/
return fields;
}
/**
* Returns whether the metafield is persistable or not
*/
public boolean isReadableField( MetaField mf )
{
return true;
}
/**
* Returns whether the metafield is persistable or not
*/
public boolean isWriteableField( MetaField mf )
{
if ( isReadOnly( mf )) return false;
return true;
}
protected String getNextFieldId( ObjectConnection c, MetaClass mc, MetaField f ) throws MetaException
{
long id = 0;
List