USRE-87 Merge Changes and move folder

This commit is contained in:
YuCheng Hu 2021-12-02 09:52:25 -05:00
commit beee194dc3
95 changed files with 2 additions and 6822 deletions

View File

@ -2,7 +2,6 @@ package com.ossez.usreio.client;
import java.util.Map; import java.util.Map;
import com.ossez.usreio.common.rets.RetsVersion;
import com.ossez.usreio.tests.common.metadata.Metadata; import com.ossez.usreio.tests.common.metadata.Metadata;
import com.ossez.usreio.tests.common.metadata.MetadataException; import com.ossez.usreio.tests.common.metadata.MetadataException;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;

View File

@ -5,7 +5,6 @@ import java.io.FileWriter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.ossez.usreio.common.rets.RetsVersion;
import com.ossez.usreio.tests.common.metadata.JDomCompactBuilder; import com.ossez.usreio.tests.common.metadata.JDomCompactBuilder;
import com.ossez.usreio.tests.common.metadata.JDomStandardBuilder; import com.ossez.usreio.tests.common.metadata.JDomStandardBuilder;
import com.ossez.usreio.tests.common.metadata.Metadata; import com.ossez.usreio.tests.common.metadata.Metadata;

View File

@ -7,7 +7,7 @@ package com.ossez.usreio.client.retsapi;
//import com.aftexsw.util.bzip.CBZip2InputStream; //import com.aftexsw.util.bzip.CBZip2InputStream;
import com.ossez.usreio.common.rets.RetsConfigurator; import com.ossez.usreio.common.util.RETSConfigurator;
import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.GetMethod;
@ -32,7 +32,7 @@ public class RETSConnection extends java.lang.Object {
private final static Logger logger = LoggerFactory.getLogger(RETSConnection.class); private final static Logger logger = LoggerFactory.getLogger(RETSConnection.class);
static { static {
RetsConfigurator.configure(); RETSConfigurator.configure();
} }
//Key value pairs for request header. //Key value pairs for request header.

View File

@ -1,16 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata;
import java.io.Serializable;
public interface AttrType<T> extends Serializable {
public T parse(String value, boolean strict) throws MetaParseException;
public Class<T> getType();
public String render(T value);
}

View File

@ -1,702 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.*;
import com.ossez.usreio.tests.common.metadata.types.MClass;
import com.ossez.usreio.tests.common.metadata.types.MEditMask;
import com.ossez.usreio.tests.common.metadata.types.MLookup;
import com.ossez.usreio.tests.common.metadata.types.MLookupType;
import com.ossez.usreio.tests.common.metadata.types.MObject;
import com.ossez.usreio.tests.common.metadata.types.MResource;
import com.ossez.usreio.tests.common.metadata.types.MSearchHelp;
import com.ossez.usreio.tests.common.metadata.types.MSystem;
import com.ossez.usreio.tests.common.metadata.types.MTable;
import com.ossez.usreio.tests.common.metadata.types.MUpdate;
import com.ossez.usreio.tests.common.metadata.types.MUpdateType;
import com.ossez.usreio.tests.common.metadata.types.MValidationExpression;
import com.ossez.usreio.tests.common.metadata.types.MValidationExternal;
import com.ossez.usreio.tests.common.metadata.types.MValidationExternalType;
import com.ossez.usreio.tests.common.metadata.types.MValidationLookup;
import com.ossez.usreio.tests.common.metadata.types.MValidationLookupType;
import org.dom4j.io.SAXReader;
import org.xml.sax.InputSource;
public class JDomCompactBuilder extends MetadataBuilder {
public static final String CONTAINER_PREFIX = "METADATA-";
public static final String CONTAINER_ROOT = "RETS";
public static final String CONTAINER_METADATA = "METADATA";
public static final String CONTAINER_SYSTEM = "METADATA-SYSTEM";
public static final String CONTAINER_RESOURCE = "METADATA-RESOURCE";
public static final String CONTAINER_FOREIGNKEY = "METADATA-FOREIGN_KEY";
public static final String CONTAINER_CLASS = "METADATA-CLASS";
public static final String CONTAINER_TABLE = "METADATA-TABLE";
public static final String CONTAINER_UPDATE = "METADATA-UPDATE";
public static final String CONTAINER_UPDATETYPE = "METADATA-UPDATE_TYPE";
public static final String CONTAINER_OBJECT = "METADATA-OBJECT";
public static final String CONTAINER_SEARCHHELP = "METADATA-SEARCH_HELP";
public static final String CONTAINER_EDITMASK = "METADATA-EDITMASK";
public static final String CONTAINER_UPDATEHELP = "METADATA-UPDATE_HELP";
public static final String CONTAINER_LOOKUP = "METADATA-LOOKUP";
public static final String CONTAINER_LOOKUPTYPE = "METADATA-LOOKUP_TYPE";
public static final String CONTAINER_VALIDATIONLOOKUP = "METADATA-VALIDATION_LOOKUP";
public static final String CONTAINER_VALIDATIONLOOKUPTYPE = "METADATA-VALIDATION_LOOKUP_TYPE";
public static final String CONTAINER_VALIDATIONEXPRESSION = "METADATA-VALIDATION_EXPRESSION";
public static final String CONTAINER_VALIDATIONEXTERNAL = "METADATA-VALIDATION_EXTERNAL";
public static final String CONTAINER_VALIDATIONEXTERNALTYPE = "METADATA-VALIDATION_EXTERNAL_TYPE";
public static final String ELEMENT_SYSTEM = "SYSTEM";
public static final String COLUMNS = "COLUMNS";
public static final String DATA = "DATA";
public static final String ATTRIBUTE_RESOURCE = "Resource";
public static final String ATTRIBUTE_CLASS = "Class";
public static final String ATTRIBUTE_UPDATE = "Update";
public static final String ATTRIBUTE_LOOKUP = "Lookup";
public static final String ATTRIBUTE_VALIDATIONEXTERNAL = "ValidationExternal";
public static final String ATTRIBUTE_VALIDATIONLOOKUP = "ValidationLookup";
private static final Log LOG = LogFactory.getLog(JDomCompactBuilder.class);
@Override
public Metadata doBuild(Object src) throws MetadataException {
return build((Document) src);
}
public Metadata build(InputSource source) throws MetadataException {
SAXReader builder = new SAXReader();
Document document;
try {
document = builder.read(source);
} catch (DocumentException e) {
throw new MetadataException("Couldn't build document", e);
}
return build(document);
}
@Override
public MetaObject[] parse(Object src) throws MetadataException {
return parse((Document) src);
}
public MetaObject[] parse(Document src) throws MetadataException {
Element root = src.getRootElement();
if (!root.getName().equals(CONTAINER_ROOT)) {
throw new MetadataException("Invalid root element");
}
Element container = root.element(CONTAINER_SYSTEM);
if (container != null) {
MSystem sys = processSystem(container);
if (root.element(CONTAINER_RESOURCE) != null) {
Metadata m = new Metadata(sys);
recurseAll(m, root);
}
return new MetaObject[] { sys };
}
container = root.element(CONTAINER_RESOURCE);
if (container != null) {
return processResource(container);
}
container = root.element(CONTAINER_CLASS);
if (container != null) {
return processClass(container);
}
container = root.element(CONTAINER_TABLE);
if (container != null) {
return processTable(container);
}
container = root.element(CONTAINER_UPDATE);
if (container != null) {
return processUpdate(container);
}
container = root.element(CONTAINER_UPDATETYPE);
if (container != null) {
return processUpdateType(container);
}
container = root.element(CONTAINER_OBJECT);
if (container != null) {
return processObject(container);
}
container = root.element(CONTAINER_SEARCHHELP);
if (container != null) {
return processSearchHelp(container);
}
container = root.element(CONTAINER_EDITMASK);
if (container != null) {
return processEditMask(container);
}
container = root.element(CONTAINER_LOOKUP);
if (container != null) {
return processLookup(container);
}
container = root.element(CONTAINER_LOOKUPTYPE);
if (container != null) {
return processLookupType(container);
}
container = root.element(CONTAINER_VALIDATIONLOOKUP);
if (container != null) {
return processValidationLookup(container);
}
container = root.element(CONTAINER_VALIDATIONLOOKUPTYPE);
if (container != null) {
return processValidationLookupType(container);
}
container = root.element(CONTAINER_VALIDATIONEXTERNAL);
if (container != null) {
return processValidationExternal(container);
}
container = root.element(CONTAINER_VALIDATIONEXTERNALTYPE);
if (container != null) {
return processValidationExternalType(container);
}
container = root.element(CONTAINER_VALIDATIONEXPRESSION);
if (container != null) {
return processValidationExpression(container);
}
return null;
}
public Metadata build(Document src) throws MetadataException {
Element root = src.getRootElement();
if (!root.getName().equals(CONTAINER_ROOT)) {
throw new MetadataException("Invalid root element");
}
Element element = root.element(CONTAINER_SYSTEM);
if (element == null) {
throw new MetadataException("Missing element " + CONTAINER_SYSTEM);
}
MSystem sys = processSystem(element);
Metadata metadata;
metadata = new Metadata(sys);
recurseAll(metadata, root);
return metadata;
}
private void recurseAll(Metadata metadata, Element root) throws MetaParseException {
attachResource(metadata, root);
attachClass(metadata, root);
attachTable(metadata, root);
attachUpdate(metadata, root);
attachUpdateType(metadata, root);
attachObject(metadata, root);
attachSearchHelp(metadata, root);
attachEditMask(metadata, root);
attachLookup(metadata, root);
attachLookupType(metadata, root);
attachValidationLookup(metadata, root);
attachValidationLookupType(metadata, root);
attachValidationExternal(metadata, root);
attachValidationExternalType(metadata, root);
attachValidationExpression(metadata, root);
}
private void setAttributes(MetaObject obj, String[] columns, String[] data) {
int count = columns.length;
if (count > data.length) {
count = data.length;
}
for (int i = 0; i < count; i++) {
String column = columns[i];
String datum = data[i];
if (!datum.equals("")) {
setAttribute(obj, column, datum);
}
}
}
private String[] getColumns(Element el) {
Element cols = el.element(COLUMNS);
return split(cols);
}
/** do NOT use string.split() unless your prepared to deal with loss due to token boundary conditions */
private String[] split(Element el) {
if( el == null ) return null;
final String delimiter = "\t";
StringTokenizer tkn = new StringTokenizer(el.getText(), delimiter, true);
List list = new LinkedList();
tkn.nextToken(); // junk the first element
String last = null;
while (tkn.hasMoreTokens()) {
String next = tkn.nextToken();
if (next.equals(delimiter)) {
if (last == null) {
list.add("");
} else {
last = null;
}
} else {
list.add(next);
last = next;
}
}
return (String[]) list.toArray(new String[0]);
}
/**
* Gets an attribute that is not expected to be null (i.e. an attribute that
* MUST exist).
*
* @param element Element
* @param name Attribute name
* @return value of attribute
* @throws MetaParseException if the value is null.
*/
private String getNonNullAttribute(Element element, String name) throws MetaParseException {
String value = element.attributeValue(name);
if (value == null) {
throw new MetaParseException("Attribute '" + name + "' not found on tag " + toString(element));
}
return value;
}
private String toString(Element element) {
StringBuffer buffer = new StringBuffer();
List attributes = element.attributes();
buffer.append("'").append(element.getName()).append("'");
buffer.append(", attributes: ").append(attributes);
return buffer.toString();
}
private MSystem processSystem(Element container) {
Element element = container.element(ELEMENT_SYSTEM);
MSystem system = buildSystem();
// system metadata is such a hack. the first one here is by far my favorite
String comment = container.elementText(MSystem.COMMENTS);
String systemId = element.attributeValue(MSystem.SYSTEMID);
String systemDescription = element.attributeValue(MSystem.SYSTEMDESCRIPTION);
String version = container.attributeValue(MSystem.VERSION);
String date = container.attributeValue(MSystem.DATE);
setAttribute(system, MSystem.COMMENTS, comment);
setAttribute(system, MSystem.SYSTEMID, systemId);
setAttribute(system, MSystem.SYSTEMDESCRIPTION, systemDescription);
setAttribute(system, MSystem.VERSION, version);
setAttribute(system, MSystem.DATE, date);
return system;
}
private void attachResource(Metadata metadata, Element root) {
MSystem system = metadata.getSystem();
List containers = root.elements(CONTAINER_RESOURCE);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MResource[] resources = this.processResource(container);
for (int j = 0; j < resources.length; j++) {
system.addChild(MetadataType.RESOURCE, resources[j]);
}
}
}
private MResource[] processResource(Element resourceContainer) {
String[] columns = getColumns(resourceContainer);
List rows = resourceContainer.elements(DATA);
MResource[] resources = new MResource[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MResource resource = buildResource();
setAttributes(resource, columns, data);
resources[i] = resource;
}
return resources;
}
private void attachClass(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_CLASS);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
String resourceId = getNonNullAttribute(container, ATTRIBUTE_RESOURCE);
MResource resource = metadata.getResource(resourceId);
MClass[] classes = processClass(container);
for (int j = 0; j < classes.length; j++) {
resource.addChild(MetadataType.CLASS, classes[j]);
}
}
}
private MClass[] processClass(Element classContainer) throws MetaParseException {
String name = classContainer.getName();
String resourceId = getNonNullAttribute(classContainer, ATTRIBUTE_RESOURCE);
LOG.debug("resource name: " + resourceId + " for container " + name);
String[] columns = getColumns(classContainer);
List rows = classContainer.elements(DATA);
MClass[] classes = new MClass[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MClass clazz = buildClass();
setAttributes(clazz, columns, data);
classes[i] = clazz;
}
return classes;
}
private void attachTable(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_TABLE);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
String resourceId = getNonNullAttribute(container, ATTRIBUTE_RESOURCE);
String className = getNonNullAttribute(container, ATTRIBUTE_CLASS);
MClass clazz = metadata.getMClass(resourceId, className);
if (clazz == null) {
//MarketLinx Strikes!!!
LOG.warn("Found table metadata for resource class: " + resourceId + ":" + className
+ " but there is no class metadata for " + resourceId + ":" + className);
continue;
}
MTable[] fieldMetadata = processTable(container);
for (int j = 0; j < fieldMetadata.length; j++) {
clazz.addChild(MetadataType.TABLE, fieldMetadata[j]);
}
}
}
private MTable[] processTable(Element tableContainer) {
String[] columns = getColumns(tableContainer);
List rows = tableContainer.elements(DATA);
MTable[] fieldMetadata = new MTable[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MTable mTable = buildTable();
setAttributes(mTable, columns, data);
fieldMetadata[i] = mTable;
}
return fieldMetadata;
}
private void attachUpdate(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_UPDATE);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MClass parent = metadata.getMClass(getNonNullAttribute(container, ATTRIBUTE_RESOURCE), getNonNullAttribute(
container, ATTRIBUTE_CLASS));
MUpdate[] updates = processUpdate(container);
for (int j = 0; j < updates.length; j++) {
parent.addChild(MetadataType.UPDATE, updates[j]);
}
}
}
private MUpdate[] processUpdate(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MUpdate[] updates = new MUpdate[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MUpdate update = buildUpdate();
setAttributes(update, columns, data);
updates[i] = update;
}
return updates;
}
private void attachUpdateType(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_UPDATETYPE);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MUpdate parent = metadata.getUpdate(getNonNullAttribute(container, ATTRIBUTE_RESOURCE),
getNonNullAttribute(container, ATTRIBUTE_CLASS), getNonNullAttribute(container, ATTRIBUTE_UPDATE));
MUpdateType[] updateTypes = processUpdateType(container);
for (int j = 0; j < updateTypes.length; j++) {
parent.addChild(MetadataType.UPDATE_TYPE, updateTypes[j]);
}
}
}
private MUpdateType[] processUpdateType(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MUpdateType[] updateTypes = new MUpdateType[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MUpdateType updateType = buildUpdateType();
setAttributes(updateType, columns, data);
updateTypes[i] = updateType;
}
return updateTypes;
}
private void attachObject(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_OBJECT);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MResource parent = metadata.getResource(getNonNullAttribute(container, ATTRIBUTE_RESOURCE));
MObject[] objects = processObject(container);
for (int j = 0; j < objects.length; j++) {
parent.addChild(MetadataType.OBJECT, objects[j]);
}
}
}
private MObject[] processObject(Element objectContainer) {
String[] columns = getColumns(objectContainer);
List rows = objectContainer.elements(DATA);
MObject[] objects = new MObject[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MObject object = buildObject();
setAttributes(object, columns, data);
objects[i] = object;
}
return objects;
}
private void attachSearchHelp(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_SEARCHHELP);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MResource parent = metadata.getResource(getNonNullAttribute(container, ATTRIBUTE_RESOURCE));
MSearchHelp[] searchHelps = processSearchHelp(container);
for (int j = 0; j < searchHelps.length; j++) {
parent.addChild(MetadataType.SEARCH_HELP, searchHelps[j]);
}
}
}
private MSearchHelp[] processSearchHelp(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MSearchHelp[] searchHelps = new MSearchHelp[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MSearchHelp searchHelp = buildSearchHelp();
setAttributes(searchHelp, columns, data);
searchHelps[i] = searchHelp;
}
return searchHelps;
}
private void attachEditMask(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_EDITMASK);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MResource parent = metadata.getResource(getNonNullAttribute(container, ATTRIBUTE_RESOURCE));
MEditMask[] editMasks = processEditMask(container);
for (int j = 0; j < editMasks.length; j++) {
parent.addChild(MetadataType.EDITMASK, editMasks[j]);
}
}
}
private MEditMask[] processEditMask(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MEditMask[] editMasks = new MEditMask[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MEditMask editMask = buildEditMask();
setAttributes(editMask, columns, data);
editMasks[i] = editMask;
}
return editMasks;
}
private void attachLookup(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_LOOKUP);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MResource parent = metadata.getResource(getNonNullAttribute(container, ATTRIBUTE_RESOURCE));
MLookup[] lookups = processLookup(container);
for (int j = 0; j < lookups.length; j++) {
parent.addChild(MetadataType.LOOKUP, lookups[j]);
}
}
}
private MLookup[] processLookup(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MLookup[] lookups = new MLookup[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MLookup lookup = buildLookup();
setAttributes(lookup, columns, data);
lookups[i] = lookup;
}
return lookups;
}
private void attachLookupType(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_LOOKUPTYPE);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MLookup parent = metadata.getLookup(getNonNullAttribute(container, ATTRIBUTE_RESOURCE),
getNonNullAttribute(container, ATTRIBUTE_LOOKUP));
if (parent == null) {
LOG.warn("Skipping lookup type: could not find lookup for tag " + toString(container));
continue;
}
MLookupType[] lookupTypes = processLookupType(container);
for (int j = 0; j < lookupTypes.length; j++) {
parent.addChild(MetadataType.LOOKUP_TYPE, lookupTypes[j]);
}
}
}
private MLookupType[] processLookupType(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MLookupType[] lookupTypes = new MLookupType[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MLookupType lookupType = buildLookupType();
setAttributes(lookupType, columns, data);
lookupTypes[i] = lookupType;
}
return lookupTypes;
}
private void attachValidationLookup(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_VALIDATIONLOOKUP);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MResource parent = metadata.getResource(getNonNullAttribute(container, ATTRIBUTE_RESOURCE));
MValidationLookup[] validationLookups = processValidationLookup(container);
for (int j = 0; j < validationLookups.length; j++) {
parent.addChild(MetadataType.VALIDATION_LOOKUP, validationLookups[j]);
}
}
}
private MValidationLookup[] processValidationLookup(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MValidationLookup[] validationLookups = new MValidationLookup[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MValidationLookup validationLookup = buildValidationLookup();
setAttributes(validationLookup, columns, data);
validationLookups[i] = validationLookup;
}
return validationLookups;
}
private void attachValidationLookupType(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_VALIDATIONLOOKUPTYPE);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MValidationLookup parent = metadata.getValidationLookup(getNonNullAttribute(container, ATTRIBUTE_RESOURCE),
getNonNullAttribute(container, ATTRIBUTE_VALIDATIONLOOKUP));
MValidationLookupType[] validationLookupTypes = processValidationLookupType(container);
for (int j = 0; j < validationLookupTypes.length; j++) {
parent.addChild(MetadataType.VALIDATION_LOOKUP_TYPE, validationLookupTypes[j]);
}
}
}
private MValidationLookupType[] processValidationLookupType(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MValidationLookupType[] validationLookupTypes = new MValidationLookupType[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MValidationLookupType validationLookupType = buildValidationLookupType();
setAttributes(validationLookupType, columns, data);
validationLookupTypes[i] = validationLookupType;
}
return validationLookupTypes;
}
private void attachValidationExternal(Metadata metadata, Element root) {
List containers = root.elements(CONTAINER_VALIDATIONEXTERNAL);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MResource parent = metadata.getResource(container.attributeValue(ATTRIBUTE_RESOURCE));
MValidationExternal[] validationExternals = processValidationExternal(container);
for (int j = 0; j < validationExternals.length; j++) {
parent.addChild(MetadataType.VALIDATION_EXTERNAL, validationExternals[j]);
}
}
}
private MValidationExternal[] processValidationExternal(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MValidationExternal[] validationExternals = new MValidationExternal[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MValidationExternal validationExternal = buildValidationExternal();
setAttributes(validationExternal, columns, data);
validationExternals[i] = validationExternal;
}
return validationExternals;
}
private void attachValidationExternalType(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_VALIDATIONEXTERNALTYPE);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MValidationExternal parent = metadata.getValidationExternal(getNonNullAttribute(container,
ATTRIBUTE_RESOURCE), getNonNullAttribute(container, ATTRIBUTE_VALIDATIONEXTERNAL));
MValidationExternalType[] validationExternalTypes = processValidationExternalType(container);
for (int j = 0; j < validationExternalTypes.length; j++) {
parent.addChild(MetadataType.VALIDATION_EXTERNAL_TYPE, validationExternalTypes[j]);
}
}
}
private MValidationExternalType[] processValidationExternalType(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MValidationExternalType[] validationExternalTypes = new MValidationExternalType[rows.size()];
for (int i = 0; i < rows.size(); i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MValidationExternalType validationExternalType = buildValidationExternalType();
setAttributes(validationExternalType, columns, data);
validationExternalTypes[i] = validationExternalType;
}
return validationExternalTypes;
}
private void attachValidationExpression(Metadata metadata, Element root) throws MetaParseException {
List containers = root.elements(CONTAINER_VALIDATIONEXPRESSION);
for (int i = 0; i < containers.size(); i++) {
Element container = (Element) containers.get(i);
MResource parent = metadata.getResource(getNonNullAttribute(container, ATTRIBUTE_RESOURCE));
MValidationExpression[] expressions = processValidationExpression(container);
for (int j = 0; j < expressions.length; j++) {
parent.addChild(MetadataType.VALIDATION_EXPRESSION, expressions[j]);
}
}
}
private MValidationExpression[] processValidationExpression(Element container) {
String[] columns = getColumns(container);
List rows = container.elements(DATA);
MValidationExpression[] expressions = new MValidationExpression[rows.size()];
for (int i = 0; i < expressions.length; i++) {
Element element = (Element) rows.get(i);
String[] data = split(element);
MValidationExpression expression = buildValidationExpression();
setAttributes(expression, columns, data);
expressions[i] = expression;
}
return expressions;
}
}

View File

@ -1,628 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import com.ossez.usreio.tests.common.metadata.types.MClass;
import com.ossez.usreio.tests.common.metadata.types.MEditMask;
import com.ossez.usreio.tests.common.metadata.types.MForeignKey;
import com.ossez.usreio.tests.common.metadata.types.MLookup;
import com.ossez.usreio.tests.common.metadata.types.MLookupType;
import com.ossez.usreio.tests.common.metadata.types.MObject;
import com.ossez.usreio.tests.common.metadata.types.MResource;
import com.ossez.usreio.tests.common.metadata.types.MSearchHelp;
import com.ossez.usreio.tests.common.metadata.types.MSystem;
import com.ossez.usreio.tests.common.metadata.types.MTable;
import com.ossez.usreio.tests.common.metadata.types.MUpdate;
import com.ossez.usreio.tests.common.metadata.types.MUpdateHelp;
import com.ossez.usreio.tests.common.metadata.types.MUpdateType;
import com.ossez.usreio.tests.common.metadata.types.MValidationExpression;
import com.ossez.usreio.tests.common.metadata.types.MValidationExternal;
import com.ossez.usreio.tests.common.metadata.types.MValidationExternalType;
import com.ossez.usreio.tests.common.metadata.types.MValidationLookup;
import com.ossez.usreio.tests.common.metadata.types.MValidationLookupType;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
/** Parses apart a complete Standard-XML response, returns a Metadata object */
public class JDomStandardBuilder extends MetadataBuilder {
public static final String ELEMENT_SYSTEM = "System";
public static final String ELEMENT_RESOURCE = "Resource";
public static final String ELEMENT_FOREIGNKEY = "ForeignKey";
public static final String ELEMENT_CLASS = "Class";
public static final String ELEMENT_TABLE = "Field";
public static final String ELEMENT_UPDATE = "UpdateType";
public static final String ELEMENT_UPDATETYPE = "UpdateField";
public static final String ELEMENT_OBJECT = "Object";
public static final String ELEMENT_SEARCHHELP = "SearchHelp";
public static final String ELEMENT_EDITMASK = "EditMask";
public static final String ELEMENT_UPDATEHELP = "UpdateHelp";
public static final String ELEMENT_LOOKUP = "Lookup";
public static final String ELEMENT_LOOKUPTYPE = "LookupType";
public static final String ELEMENT_VALIDATIONLOOKUP = "ValidationLookup";
public static final String ELEMENT_VALIDATIONLOOKUPTYPE = "ValidationLookupType";
public static final String ELEMENT_VALIDATIONEXPRESSION = "ValidationExpression";
public static final String ELEMENT_VALIDATIONEXTERNAL = "ValidationExternalType";
public static final String ELEMENT_VALIDATIONEXTERNALTYPE = "ValidationExternal";
public static final String ATTRIBUTE_RESOURCEID = ELEMENT_RESOURCE;
public static final String ATTRIBUTE_CLASSNAME = ELEMENT_CLASS;
public static final String ATTRIBUTE_UPDATE = ELEMENT_UPDATE;
public static final String ATTRIBUTE_LOOKUP = ELEMENT_LOOKUP;
public static final String ATTRIBUTE_VALIDATIONLOOKUP = ELEMENT_VALIDATIONLOOKUP;
public static final String ATTRIBUTE_VALIDATIONEXTERNAL = ELEMENT_VALIDATIONEXTERNAL;
public static final Map sType2Element = new HashMap();
static {
sType2Element.put(MetadataType.SYSTEM, ELEMENT_SYSTEM);
sType2Element.put(MetadataType.RESOURCE, ELEMENT_RESOURCE);
sType2Element.put(MetadataType.FOREIGNKEYS, ELEMENT_FOREIGNKEY);
sType2Element.put(MetadataType.CLASS, ELEMENT_CLASS);
sType2Element.put(MetadataType.TABLE, ELEMENT_TABLE);
sType2Element.put(MetadataType.UPDATE, ELEMENT_UPDATE);
sType2Element.put(MetadataType.UPDATE_TYPE, ELEMENT_UPDATETYPE);
sType2Element.put(MetadataType.SEARCH_HELP, ELEMENT_SEARCHHELP);
sType2Element.put(MetadataType.EDITMASK, ELEMENT_EDITMASK);
sType2Element.put(MetadataType.UPDATE_HELP, ELEMENT_UPDATEHELP);
sType2Element.put(MetadataType.LOOKUP, ELEMENT_LOOKUP);
sType2Element.put(MetadataType.LOOKUP_TYPE, ELEMENT_LOOKUPTYPE);
sType2Element.put(MetadataType.VALIDATION_LOOKUP, ELEMENT_VALIDATIONLOOKUP);
sType2Element.put(MetadataType.VALIDATION_LOOKUP_TYPE, ELEMENT_VALIDATIONLOOKUPTYPE);
sType2Element.put(MetadataType.VALIDATION_EXTERNAL, ELEMENT_VALIDATIONEXTERNAL);
sType2Element.put(MetadataType.VALIDATION_EXTERNAL_TYPE, ELEMENT_VALIDATIONEXTERNALTYPE);
sType2Element.put(MetadataType.VALIDATION_EXPRESSION, ELEMENT_VALIDATIONEXPRESSION);
}
@Override
public Metadata doBuild(Object src) throws MetadataException {
return build((Document) src);
}
public Metadata build(Document src) throws MetadataException {
Element element = src.getRootElement();
expectElement(element, CONTAINER_ROOT);
element = getElement(element, CONTAINER_METADATA);
return build(element);
}
@Override
public MetaObject[] parse(Object src) throws MetadataException {
return parse((Document) src);
}
public MetaObject[] parse(Document src) throws MetadataException {
Element element = src.getRootElement();
expectElement(element, CONTAINER_ROOT);
Element container = getElement(element, CONTAINER_METADATA);
boolean recurse = checkForRecursion(container);
List list = container.elements();
if (list.size() == 0) {
return null;
}
return processContainer(null, (Element) list.get(0), recurse);
}
/**
* Function to determine if a request contains recursive data or not.
* This is done here instead of inside processContainer because, well,
* it's easier and more reliable (processContainer might not figure out
* that a request is recursive until the third or 4th child if there are
* no children for the first couple of elements.
*
* @param top The outside METADATA container.
* @return true if the request is recursive
*
*/
private boolean checkForRecursion(Element top) {
/*
* this seems like a really nasty loop. However, if there are a
* lot of recursive elements, we'll find out pretty quickly, and if
* we fall all the way to the end then there probably wasn't that
* much to look through.
*/
Iterator children = top.elements().iterator();
while (children.hasNext()) {
/* each of these is a container (METADATA-*) type */
Element element = (Element) children.next();
Iterator iterator = element.elements().iterator();
while (iterator.hasNext()) {
/* each of these is an item element */
Element child = (Element) iterator.next();
Iterator subtypes = child.elements().iterator();
while (subtypes.hasNext()) {
Element subtype = (Element) subtypes.next();
if (subtype.getName().startsWith(CONTAINER_PREFIX)) {
return true;
}
}
}
}
return false;
}
private MetaObject[] processContainer(MetaObject parent, Element container, boolean recursion) {
MetadataType type = (MetadataType) sContainer2Type.get(container.getName());
if (type == null) {
throw new RuntimeException("no matching type for container " + container.getName());
}
List elements = container.elements((String) sType2Element.get(type));
String path = getPath(container);
List output = null;
if (parent == null) {
output = new LinkedList();
}
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MetaObject obj = newType(type);
setAttributes(obj, element);
if (output != null) {
output.add(obj);
}
if (parent != null) {
parent.addChild(type, obj);
} else {
/**
* Weirdness abounds. There IS an ID attribute of System,
* and the SystemID is included in the Metadata container
* attributes, but the system id is not part of the metadata
* request path for a getMetadata request, so we ignore it.
*/
if (!type.equals(MetadataType.SYSTEM)) {
obj.setPath(path);
}
}
if (recursion) {
MetadataType[] childTypes = obj.getChildTypes();
for (int j = 0; j < childTypes.length; j++) {
MetadataType childType = childTypes[j];
Element childContainer = element.element(CONTAINER_PREFIX + childType.name());
if (childContainer == null) {
obj.addChild(childType, null);
} else {
processContainer(obj, childContainer, true);
}
}
}
}
if (output == null) {
return null;
}
return (MetaObject[]) output.toArray(new MetaObject[0]);
}
String getPath(Element container) {
String resource = container.attributeValue(ATTRIBUTE_RESOURCEID);
if (resource == null) {
return null;
}
String classname = container.attributeValue(ATTRIBUTE_CLASSNAME);
if (classname != null) {
String update = container.attributeValue(ATTRIBUTE_UPDATE);
if (update != null) {
return resource + ":" + classname + ":" + update;
}
return resource + ":" + classname;
}
String lookup = container.attributeValue(ATTRIBUTE_LOOKUP);
if (lookup != null) {
return resource + ":" + lookup;
}
String vallkp = container.attributeValue(ATTRIBUTE_VALIDATIONLOOKUP);
if (vallkp != null) {
return resource + ":" + vallkp;
}
String vale = container.attributeValue(ATTRIBUTE_VALIDATIONEXTERNAL);
if (vale != null) {
return resource + ":" + vale;
}
return resource;
}
public Metadata build(Element element) throws MetadataException {
expectElement(element, CONTAINER_METADATA);
element = getElement(element, CONTAINER_SYSTEM);
//maybe i get the attribute here
MSystem sys = processSystem(element);
return new Metadata(sys);
}
private Element getElement(Element parent, String type) throws MetadataException {
Element element = parent.element(type);
if (element == null) {
throw new MetadataException("Missing element " + type);
}
return element;
}
private void expectElement(Element element, String type) throws MetadataException {
if (!element.getName().equalsIgnoreCase(type)) {// changed to ignore case
throw new MetadataException("Expecting element " + type + ", got " + element.getName());
}
}
private void setAttributes(MetaObject obj, Element el) {
List children = el.elements();
for (int i = 0; i < children.size(); i++) {
Element child = (Element) children.get(i);
String name = child.getName();
if (!name.startsWith(CONTAINER_PREFIX)) {
String value = child.getTextTrim();
setAttribute(obj, name, value);
} else {
// LOG.info("skipping container element " + name);
}
}
}
//when atrributes from the xml element are needed
public void setAttributesFromXMLAttr(MetaObject obj, Element el) {
Iterator attrIter = el.getParent().attributes().iterator();
while(attrIter.hasNext()){
Attribute attr = (Attribute) attrIter.next();
String name = attr.getName();
String value= attr.getValue().trim();
setAttribute(obj, name, value);
}
}
/**
* If we're a recursive request, initialize all possible child types so
* we don't have to try to pull them later, dynamically
*/
private void init(MetaObject item) {
MetadataType[] childTypes = item.getChildTypes();
for (int i = 0; i < childTypes.length; i++) {
MetadataType type = childTypes[i];
item.addChild(type, null);
}
}
private MSystem processSystem(Element container) {
Element element = container.element(ELEMENT_SYSTEM);
if (element == null){
element = container.element(ELEMENT_SYSTEM.toUpperCase());
}
MSystem system = buildSystem();
init(system);
setAttributesFromXMLAttr(system, element);
setAttributes(system, element);
Element child;
child = element.element(CONTAINER_RESOURCE);
if (child != null) {
processResource(system, child);
}
child = element.element(CONTAINER_FOREIGNKEY);
if (child != null) {
processForeignKey(system, child);
}
return system;
}
private void processResource(MSystem system, Element container) {
List resources = container.elements(ELEMENT_RESOURCE);
for (int i = 0; i < resources.size(); i++) {
Element element = (Element) resources.get(i);
MResource resource = buildResource();
init(resource);
setAttributes(resource, element);
system.addChild(MetadataType.RESOURCE, resource);
Element child;
child = element.element(CONTAINER_CLASS);
if (child != null) {
processClass(resource, child);
}
child = element.element(CONTAINER_OBJECT);
if (child != null) {
processObject(resource, child);
}
child = element.element(CONTAINER_SEARCH_HELP);
if (child != null) {
processSearchHelp(resource, child);
}
child = element.element(CONTAINER_EDITMASK);
if (child != null) {
processEditMask(resource, child);
}
child = element.element(CONTAINER_LOOKUP);
if (child != null) {
processLookup(resource, child);
}
child = element.element(CONTAINER_UPDATEHELP);
if (child != null) {
processUpdateHelp(resource, child);
}
child = element.element(CONTAINER_VALIDATIONLOOKUP);
if (child != null) {
processValidationLookup(resource, child);
}
child = element.element(CONTAINER_VALIDATIONEXPRESSION);
if (child != null) {
processValidationExpression(resource, child);
}
child = element.element(CONTAINER_VALIDATIONEXTERNAL);
if (child != null) {
processValidationExternal(resource, child);
}
}
}
private void processEditMask(MResource parent, Element container) {
List elements = container.elements(ELEMENT_EDITMASK);
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MEditMask mask = buildEditMask();
setAttributes(mask, element);
parent.addChild(MetadataType.EDITMASK, mask);
}
}
private void processLookup(MResource parent, Element container) {
List elements15 = container.elements(ELEMENT_LOOKUP);
List elements17 = container.elements(ELEMENT_LOOKUPTYPE);
List elements;
//some Rets Servers have lookuptype and lookup elements interchanged
if (elements15.isEmpty()){
elements = elements17;
} else {
elements = elements15;
}
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MLookup lookup = buildLookup();
init(lookup);
setAttributes(lookup, element);
parent.addChild(MetadataType.LOOKUP, lookup);
Element child = element.element(CONTAINER_LOOKUPTYPE);
if (child != null) {
processLookupType(lookup, child);
}
}
}
private void processLookupType(MLookup parent, Element container) {
List elements15 = container.elements(ELEMENT_LOOKUPTYPE);// check spec
List elements17 = container.elements(ELEMENT_LOOKUP);
List elements;
//some Rets Servers have lookuptype and lookup elements interchanged
if (elements15.isEmpty()){
elements = elements17;
} else {
elements = elements15;
}
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MLookupType type = buildLookupType();
setAttributes(type, element);
parent.addChild(MetadataType.LOOKUP_TYPE, type);
}
}
private void processUpdateHelp(MResource parent, Element container) {
List elements = container.elements(ELEMENT_UPDATEHELP);
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MUpdateHelp help = buildUpdateHelp();
setAttributes(help, element);
parent.addChild(MetadataType.UPDATE_HELP, help);
}
}
private void processValidationLookup(MResource parent, Element container) {
List elements = container.elements(ELEMENT_VALIDATIONLOOKUP);
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MValidationLookup lookup = buildValidationLookup();
init(lookup);
setAttributes(lookup, element);
parent.addChild(MetadataType.VALIDATION_LOOKUP, lookup);
Element child = element.element(CONTAINER_VALIDATIONLOOKUPTYPE);
if (child != null) {
processValidationLookupType(lookup, child);
}
}
}
private void processValidationLookupType(MValidationLookup parent, Element container) {
List elements = container.elements(ELEMENT_VALIDATIONLOOKUPTYPE);
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MValidationLookupType lookupType = buildValidationLookupType();
setAttributes(lookupType, element);
parent.addChild(MetadataType.VALIDATION_LOOKUP_TYPE, lookupType);
}
}
private void processValidationExpression(MResource parent, Element container) {
List elements = container.elements(ELEMENT_VALIDATIONEXPRESSION);
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MValidationExpression expression = buildValidationExpression();
setAttributes(expression, element);
parent.addChild(MetadataType.VALIDATION_EXPRESSION, expression);
}
}
private void processValidationExternal(MResource parent, Element container) {
List elements = container.elements(ELEMENT_VALIDATIONEXTERNAL);
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MValidationExternal external = buildValidationExternal();
init(external);
setAttributes(external, element);
parent.addChild(MetadataType.VALIDATION_EXTERNAL, external);
Element child = element.element(CONTAINER_VALIDATIONEXTERNALTYPE);
if (child != null) {
processValidationExternalType(external, child);
}
}
}
private void processValidationExternalType(MValidationExternal parent, Element container) {
List elements = container.elements(ELEMENT_VALIDATIONEXTERNALTYPE);
for (int i = 0; i < elements.size(); i++) {
Element element = (Element) elements.get(i);
MValidationExternalType type = buildValidationExternalType();
setAttributes(type, element);
parent.addChild(MetadataType.VALIDATION_EXTERNAL_TYPE, type);
}
}
private void processSearchHelp(MResource parent, Element container) {
List searchhelps = container.elements(ELEMENT_SEARCHHELP);
for (int i = 0; i < searchhelps.size(); i++) {
Element element = (Element) searchhelps.get(i);
MSearchHelp searchhelp = buildSearchHelp();
setAttributes(searchhelp, element);
parent.addChild(MetadataType.SEARCH_HELP, searchhelp);
}
}
private void processObject(MResource parent, Element container) {
List objects = container.elements(ELEMENT_OBJECT);
for (int i = 0; i < objects.size(); i++) {
Element element = (Element) objects.get(i);
MObject obj = buildObject();
setAttributes(obj, element);
parent.addChild(MetadataType.OBJECT, obj);
}
}
private void processClass(MResource parent, Element container) {
List classes = container.elements(ELEMENT_CLASS);
for (int i = 0; i < classes.size(); i++) {
Element element = (Element) classes.get(i);
MClass clazz = buildClass();
init(clazz);
setAttributes(clazz, element);
parent.addChild(MetadataType.CLASS, clazz);
Element child;
child = element.element(CONTAINER_TABLE);
if (child != null) {
processTable(clazz, child);
}
child = element.element(CONTAINER_UPDATE);
if (child != null) {
processUpdate(clazz, child);
}
}
}
private void processTable(MClass parent, Element container) {
List tables = container.elements(ELEMENT_TABLE);
for (int i = 0; i < tables.size(); i++) {
Element element = (Element) tables.get(i);
MTable table = buildTable();
setAttributes(table, element);
parent.addChild(MetadataType.TABLE, table);
}
}
private void processUpdate(MClass parent, Element container) {
List updates = container.elements(ELEMENT_UPDATE);
for (int i = 0; i < updates.size(); i++) {
Element element = (Element) updates.get(i);
MUpdate update = buildUpdate();
init(update);
setAttributes(update, element);
parent.addChild(MetadataType.UPDATE, update);
Element child = element.element(CONTAINER_UPDATE_TYPE);
if (child != null) {
processUpdateType(update, child);
}
}
}
private void processUpdateType(MUpdate parent, Element container) {
List updateFields = container.elements(ELEMENT_UPDATETYPE);
for (int i = 0; i < updateFields.size(); i++) {
Element element = (Element) updateFields.get(i);
MUpdateType updateType = buildUpdateType();
parent.addChild(MetadataType.UPDATE_TYPE, updateType);
setAttributes(updateType, element);
}
}
private void processForeignKey(MSystem system, Element container) {
List fkeys = container.elements("ForeignKey");
for (int i = 0; i < fkeys.size(); i++) {
Element element = (Element) fkeys.get(i);
MForeignKey foreignKey = buildForeignKey();
setAttributes(foreignKey, element);
system.addChild(MetadataType.FOREIGNKEYS, foreignKey);
}
}
public static final String CONTAINER_PREFIX = "METADATA-";
public static final String CONTAINER_ROOT = "RETS";
public static final String CONTAINER_METADATA = "METADATA";
public static final String CONTAINER_SYSTEM = "METADATA-SYSTEM";
public static final String CONTAINER_RESOURCE = "METADATA-RESOURCE";
public static final String CONTAINER_FOREIGNKEY = "METADATA-FOREIGN_KEYS";
public static final String CONTAINER_CLASS = "METADATA-CLASS";
public static final String CONTAINER_TABLE = "METADATA-TABLE";
public static final String CONTAINER_UPDATE = "METADATA-UPDATE";
public static final String CONTAINER_UPDATE_TYPE = "METADATA-UPDATE_TYPE";
public static final String CONTAINER_OBJECT = "METADATA-OBJECT";
public static final String CONTAINER_SEARCH_HELP = "METADATA-SEARCH_HELP";
public static final String CONTAINER_EDITMASK = "METADATA-EDITMASK";
public static final String CONTAINER_UPDATEHELP = "METADATA-UPDATE_HELP";
public static final String CONTAINER_LOOKUP = "METADATA-LOOKUP";
public static final String CONTAINER_LOOKUPTYPE = "METADATA-LOOKUP_TYPE";
public static final String CONTAINER_VALIDATIONLOOKUP = "METADATA-VALIDATION_LOOKUP";
public static final String CONTAINER_VALIDATIONLOOKUPTYPE = "METADATA-VALIDATION_LOOKUP_TYPE";
public static final String CONTAINER_VALIDATIONEXPRESSION = "METADATA-VALIDATION_EXPRESSION";
public static final String CONTAINER_VALIDATIONEXTERNAL = "METADATA-VALIDATION_EXTERNAL";
public static final String CONTAINER_VALIDATIONEXTERNALTYPE = "METADATA-VALIDATION_EXTERNAL_TYPE";
public static final Map sContainer2Type = new HashMap();
static {
for (int i = 0; i < MetadataType.values().length; i++) {
MetadataType type = MetadataType.values()[i];
sContainer2Type.put(CONTAINER_PREFIX + type.name(), type);
}
/* you have got to be kidding me. The spec (compact) says
METADATA-FOREIGNKEYS and that's the request type but the DTD says
METADATA-FOREIGN_KEY.
I think I'm going to be sick.
*/
sContainer2Type.remove(CONTAINER_PREFIX + MetadataType.FOREIGNKEYS.name());
sContainer2Type.put(CONTAINER_FOREIGNKEY, MetadataType.FOREIGNKEYS);
}
}

View File

@ -1,20 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata;
import java.io.Serializable;
/** Interface for Metadata objects to collect their children. */
public interface MetaCollector extends Serializable {
/**
* @param path path to the parent object.
*/
public MetaObject[] getMetadata(MetadataType type, String path) throws MetadataException;
public MetaObject[] getMetadataRecursive(MetadataType type, String path) throws MetadataException;
}

View File

@ -1,366 +0,0 @@
package com.ossez.usreio.tests.common.metadata;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
//import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import com.ossez.usreio.common.util.CaseInsensitiveTreeMap;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.ossez.usreio.tests.common.metadata.attrib.AttrAlphanum;
import com.ossez.usreio.tests.common.metadata.attrib.AttrBoolean;
import com.ossez.usreio.tests.common.metadata.attrib.AttrDate;
import com.ossez.usreio.tests.common.metadata.attrib.AttrNumeric;
import com.ossez.usreio.tests.common.metadata.attrib.AttrNumericPositive;
import com.ossez.usreio.tests.common.metadata.attrib.AttrPlaintext;
import com.ossez.usreio.tests.common.metadata.attrib.AttrText;
import com.ossez.usreio.tests.common.metadata.attrib.AttrVersion;
public abstract class MetaObject implements Serializable {
private static final Log LOG = LogFactory.getLog(MetaObject.class);
/** a standard parser used by different child types */
protected static final AttrType sAlphanum = new AttrAlphanum(0, 0);
protected static final AttrType sAlphanum64 = new AttrAlphanum(1, 64);
protected static final AttrType sAlphanum32 = new AttrAlphanum(1, 32);
protected static final AttrType sAlphanum24 = new AttrAlphanum(1, 24);
protected static final AttrType sAlphanum10 = new AttrAlphanum(1, 10);
protected static final AttrType sPlaintext = new AttrPlaintext(0, 0);
protected static final AttrType sPlaintext1024 = new AttrPlaintext(1, 1024);
protected static final AttrType sPlaintext512 = new AttrPlaintext(1, 512);
protected static final AttrType sPlaintext128 = new AttrPlaintext(1, 128);
protected static final AttrType sPlaintext64 = new AttrPlaintext(1, 64);
protected static final AttrType sPlaintext32 = new AttrPlaintext(1, 32);
protected static final AttrType sText = new AttrText(0, 0);
protected static final AttrType sText1024 = new AttrText(1, 1024);
protected static final AttrType sText512 = new AttrText(1, 512);
protected static final AttrType sText256 = new AttrText(1, 256);
protected static final AttrType sText128 = new AttrText(1, 128);
protected static final AttrType sText64 = new AttrText(1, 64);
protected static final AttrType sText32 = new AttrText(1, 32);
protected static final AttrType sAttrBoolean = new AttrBoolean();
protected static final AttrType sAttrDate = new AttrDate();
protected static final AttrType sAttrNumeric = new AttrNumeric();
protected static final AttrType sAttrNumericPositive = new AttrNumericPositive();
protected static final AttrType sAttrVersion = new AttrVersion();
protected static final AttrType sAttrMetadataEntryId = sAlphanum32;
protected static final MetadataType[] sNoChildren = new MetadataType[0];
protected static final AttrType retsid = sAlphanum32;
protected static final AttrType retsname = sAlphanum64;
public static final boolean STRICT_PARSING = true;
public static final boolean LOOSE_PARSING = false;
public static final boolean DEFAULT_PARSING = LOOSE_PARSING;
/** the metdata path to this object */
protected String path;
/** map of child type to map of child id to child object */
protected Map childTypes;
/** map of attribute name to attribute object (as parsed by attrtype) */
protected Map attributes;
/** map of attribute name to AttrType parser */
protected Map attrTypes;
private static Map<CacheKey,Map> sAttributeMapCache = new HashMap<CacheKey,Map>();
private MetaCollector mCollector;
private boolean strict;
public MetaObject(boolean strictParsing) {
this.strict = strictParsing;
if (strictParsing) {
this.attributes = new HashMap();
} else {
this.attributes = new CaseInsensitiveTreeMap();
}
this.attrTypes = this.getAttributeMap(strictParsing);
MetadataType[] types = getChildTypes();
this.childTypes = new HashMap();
for (int i = 0; i < types.length; i++) {
this.childTypes.put(types[i], null);
}
}
private Map getAttributeMap(boolean strictParsing) {
synchronized (sAttributeMapCache) {
Map<CacheKey,Map> map = sAttributeMapCache.get(new CacheKey(this, strictParsing));
if (map == null) {
if (strictParsing) {
map = new HashMap();
} else {
map = new CaseInsensitiveTreeMap();
}
addAttributesToMap(map);
// Let's make sure no one mucks with the map later
map = Collections.unmodifiableMap(map);
sAttributeMapCache.put(new CacheKey(this, strictParsing), map);
if (LOG.isDebugEnabled()) {
LOG.debug("Adding to attribute cache: " + this.getClass().getName() + ", " + strictParsing);
}
}
return map;
}
}
public static void clearAttributeMapCache() {
synchronized (sAttributeMapCache) {
sAttributeMapCache.clear();
}
}
public Collection getChildren(MetadataType type) {
if (!this.childTypes.containsKey(type)) {
// throw new IllegalArgumentException?
return null;
}
Object o = this.childTypes.get(type);
if (o == null) {
if (!fetchChildren(type)) {
return Collections.EMPTY_SET;
}
o = this.childTypes.get(type);
}
if (o instanceof Map) {
Map m = (Map) o;
return m.values();
}
return (Collection) o;
}
private boolean fetchChildren(MetadataType type) {
this.childTypes.put(type, new HashMap());
try {
MetaObject[] children = null;
if (this.mCollector != null) {
children = this.mCollector.getMetadata(type, getPath());
}
if (children == null) {
return false;
}
for (int i = 0; i < children.length; i++) {
MetaObject child = children[i];
addChild(type, child);
}
} catch (MetadataException e) {
LOG.error(toString() + " unable to fetch " + type.name() + " children");
return false;
}
return true;
}
public MetaObject getChild(MetadataType type, String id) {
if (id == null) {
return null;
}
try {
if (this.childTypes.get(type) == null && this.mCollector != null) {
if (!fetchChildren(type)) {
return null;
}
}
Map m = (Map) this.childTypes.get(type);
if (m == null) {
return null;
}
return (MetaObject) m.get(id);
} catch (ClassCastException e) {
return null;
}
}
public Object getAttribute(String key) {
return this.attributes.get(key);
}
public Set getKnownAttributes() {
return this.attrTypes.keySet();
}
public String getAttributeAsString(String key) {
Object value = this.attributes.get(key);
if (value == null) {
return null;
}
if (this.attrTypes.containsKey(key)) {
AttrType type = (AttrType) this.attrTypes.get(key);
return type.render(value);
}
return value.toString();
}
protected Object getTypedAttribute(String key, Class type) {
AttrType atype = (AttrType) this.attrTypes.get(key);
if (atype == null) {
return null;
}
if (atype.getType() == type) {
return this.attributes.get(key);
}
LOG.warn("type mismatch, expected " + type.getName() + " but" + " got " + atype.getType().getName());
return null;
}
public String getDateAttribute(String key) {
return (String) getTypedAttribute(key, String.class);
}
public String getStringAttribute(String key) {
return (String) getTypedAttribute(key, String.class);
}
public int getIntAttribute(String key) {
Integer i = (Integer) getTypedAttribute(key, Integer.class);
if (i == null) {
return 0;
}
return i.intValue();
}
public boolean getBooleanAttribute(String key) {
Boolean b = (Boolean) getTypedAttribute(key, Boolean.class);
if (b == null) {
return false;
}
return b.booleanValue();
}
public void setAttribute(String key, String value) {
if (value == null) {
// LOG.warning()
return;
}
if (this.attrTypes.containsKey(key)) {
AttrType type = (AttrType) this.attrTypes.get(key);
try {
this.attributes.put(key, type.parse(value,this.strict));
} catch (MetaParseException e) {
LOG.warn(toString() + " couldn't parse attribute " + key + ", value " + value + ": " + e.getMessage());
}
} else {
this.attributes.put(key, value);
LOG.warn("Unknown key (" + toString() + "): " + key);
}
}
public void addChild(MetadataType type, MetaObject child) {
if (this.childTypes.containsKey(type)) {
Object obj = this.childTypes.get(type);
Map map;
if (obj == null) {
map = new HashMap();
this.childTypes.put(type, map);
} else {
map = (Map) obj;
}
if (child == null) {
return;
}
String id = child.getId();
child.setPath(this.getPath());
child.setCollector(this.mCollector);
if (id != null) {
map.put(id, child);
}
return;
}
}
public String getId() {
String idAttr = getIdAttr();
if (idAttr == null) {
/** cheap hack so everything's a damn map */
return Integer.toString(hashCode());
}
return getAttributeAsString(idAttr);
}
public String getPath() {
return this.path;
}
protected void setPath(String parent) {
if (parent == null || parent.equals("")) {
this.path = getId();
} else {
this.path = parent + ":" + getId();
}
}
@Override
public String toString() {
ToStringBuilder tsb = new ToStringBuilder(this);
Iterator iter = getKnownAttributes().iterator();
while (iter.hasNext()) {
String key = (String) iter.next();
tsb.append(key, getAttributeAsString(key));
}
return tsb.toString();
}
public void setCollector(MetaCollector c) {
this.mCollector = c;
Iterator iterator = this.childTypes.keySet().iterator();
while (iterator.hasNext()) {
MetadataType type = (MetadataType) iterator.next();
Map map = (Map) this.childTypes.get(type);
if (map == null) {
continue;
}
Collection children = map.values();
for (Iterator iter = children.iterator(); iter.hasNext();) {
MetaObject object = (MetaObject) iter.next();
object.setCollector(c);
}
}
}
public abstract MetadataType[] getChildTypes();
protected abstract String getIdAttr();
/**
* Adds attributes to an attribute map. This is called by the MetaObject
* constructor to initialize a map of atributes. This map may be cached,
* so this method may not be called for every object construction.
*
* @param attributeMap Map to add attributes to
*/
protected abstract void addAttributesToMap(Map attributeMap);
}
class CacheKey {
private Class mClass;
private boolean strictParsing;
public CacheKey(MetaObject metaObject, boolean strictParsing) {
this.mClass = metaObject.getClass();
this.strictParsing = strictParsing;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof CacheKey)) {
return false;
}
CacheKey rhs = (CacheKey) obj;
return new EqualsBuilder().append(this.mClass, rhs.mClass).append(this.strictParsing, rhs.strictParsing).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(this.mClass).append(this.strictParsing).toHashCode();
}
}

View File

@ -1,26 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata;
public class MetaParseException extends MetadataException {
public MetaParseException() {
super();
}
public MetaParseException(String msg) {
super(msg);
}
public MetaParseException(Throwable cause) {
super(cause);
}
public MetaParseException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -1,154 +0,0 @@
package com.ossez.usreio.tests.common.metadata;
import java.io.Serializable;
import com.ossez.usreio.tests.common.metadata.types.MSystem;
import com.ossez.usreio.tests.common.metadata.types.MResource;
import com.ossez.usreio.tests.common.metadata.types.MForeignKey;
import com.ossez.usreio.tests.common.metadata.types.MClass;
import com.ossez.usreio.tests.common.metadata.types.MTable;
import com.ossez.usreio.tests.common.metadata.types.MUpdate;
import com.ossez.usreio.tests.common.metadata.types.MUpdateType;
import com.ossez.usreio.tests.common.metadata.types.MObject;
import com.ossez.usreio.tests.common.metadata.types.MValidationExternal;
import com.ossez.usreio.tests.common.metadata.types.MValidationLookup;
import com.ossez.usreio.tests.common.metadata.types.MLookup;
import com.ossez.usreio.tests.common.metadata.types.MSearchHelp;
public class Metadata implements Serializable {
protected MSystem system;
public Metadata(MetaCollector collector) throws MetadataException {
MetaObject[] sys = collector.getMetadata(MetadataType.SYSTEM, null);
if (sys != null && sys.length == 1) {
try {
this.system = (MSystem) sys[0];
} catch (ClassCastException e) {
throw new MetadataException(e);
}
this.system.setCollector(collector);
}
}
public Metadata(MSystem system) {
this.system = system;
}
public MSystem getSystem() {
return this.system;
}
public MResource getResource(String resourceId) {
return this.system.getMResource(resourceId);
}
public MForeignKey getForeignKey(String foreignKeyId) {
return this.system.getMForeignKey(foreignKeyId);
}
public MClass getMClass(String resourceId, String className) {
MResource resource = getResource(resourceId);
if (resource == null) {
return null;
}
return resource.getMClass(className);
}
public MTable getTable(String resourceId, String className, String systemName) {
MClass clazz = getMClass(resourceId, className);
if (clazz == null) {
return null;
}
return clazz.getMTable(systemName);
}
public MUpdate getUpdate(String resourceId, String className, String updateName) {
MClass clazz = getMClass(resourceId, className);
if (clazz == null) {
return null;
}
return clazz.getMUpdate(updateName);
}
public MUpdateType getUpdateType(String resourceId, String className, String updateName, String systemName) {
MUpdate update = getUpdate(resourceId, className, updateName);
if (update == null) {
return null;
}
return update.getMUpdateType(systemName);
}
public MObject getObject(String resourceId, String objectType) {
MResource resource = getResource(resourceId);
if (resource == null) {
return null;
}
return resource.getMObject(objectType);
}
public MLookup getLookup(String resourceId, String lookupName) {
MResource resource = getResource(resourceId);
if (resource == null) {
return null;
}
return resource.getMLookup(lookupName);
}
public MSearchHelp getSearchHelp(String resourceId, String searchHelpId) {
MResource resource = getResource(resourceId);
if (resource == null) {
return null;
}
return resource.getMSearchHelp(searchHelpId);
}
public MValidationExternal getValidationExternal(String resourceId, String validationExternalName) {
MResource resource = getResource(resourceId);
if (resource == null) {
return null;
}
return resource.getMValidationExternal(validationExternalName);
}
public MValidationLookup getValidationLookup(String resourceId, String validationLookupName) {
MResource resource = getResource(resourceId);
if (resource == null) {
return null;
}
return resource.getMValidationLookup(validationLookupName);
}
private String getResourceId(MetaObject obj) {
String path = obj.getPath();
int index = path.indexOf(':');
if (index == -1) {
return null;
}
String resource = path.substring(0, index);
return resource;
}
public MResource getResource(MTable field) {
String resource = getResourceId(field);
return getResource(resource);
}
public MLookup getLookup(MTable field) {
String resource = getResourceId(field);
return getLookup(resource, field.getLookupName());
}
public MSearchHelp getSearchHelp(MTable field) {
String searchHelpID = field.getSearchHelpID();
if (searchHelpID == null) {
return null;
}
String resource = getResourceId(field);
return getSearchHelp(resource, searchHelpID);
}
public MResource getResource(MClass clazz) {
return getResource(getResourceId(clazz));
}
}

View File

@ -1,203 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata;
import com.ossez.usreio.tests.common.metadata.types.MClass;
import com.ossez.usreio.tests.common.metadata.types.MEditMask;
import com.ossez.usreio.tests.common.metadata.types.MForeignKey;
import com.ossez.usreio.tests.common.metadata.types.MLookup;
import com.ossez.usreio.tests.common.metadata.types.MLookupType;
import com.ossez.usreio.tests.common.metadata.types.MObject;
import com.ossez.usreio.tests.common.metadata.types.MResource;
import com.ossez.usreio.tests.common.metadata.types.MSearchHelp;
import com.ossez.usreio.tests.common.metadata.types.MSystem;
import com.ossez.usreio.tests.common.metadata.types.MTable;
import com.ossez.usreio.tests.common.metadata.types.MUpdate;
import com.ossez.usreio.tests.common.metadata.types.MUpdateHelp;
import com.ossez.usreio.tests.common.metadata.types.MUpdateType;
import com.ossez.usreio.tests.common.metadata.types.MValidationExpression;
import com.ossez.usreio.tests.common.metadata.types.MValidationExternal;
import com.ossez.usreio.tests.common.metadata.types.MValidationExternalType;
import com.ossez.usreio.tests.common.metadata.types.MValidationLookup;
import com.ossez.usreio.tests.common.metadata.types.MValidationLookupType;
public abstract class MetadataBuilder {
protected MetadataBuilder() {
this.mStrict = false;
}
public boolean isStrict() {
return this.mStrict;
}
public void setStrict(boolean strict) {
this.mStrict = strict;
}
protected Metadata finish(MSystem system) {
return new Metadata(system);
}
protected static void setAttribute(MetaObject obj, String key, String value) {
obj.setAttribute(key, value);
}
protected MSystem buildSystem() {
MSystem system = new MSystem(this.mStrict);
return system;
}
protected MResource buildResource() {
MResource resource = new MResource(this.mStrict);
return resource;
}
protected MForeignKey buildForeignKey() {
MForeignKey key = new MForeignKey(this.mStrict);
return key;
}
protected MClass buildClass() {
MClass clazz = new MClass(this.mStrict);
return clazz;
}
protected MTable buildTable() {
MTable table = new MTable(this.mStrict);
return table;
}
protected MUpdate buildUpdate() {
MUpdate update = new MUpdate(this.mStrict);
return update;
}
protected MUpdateType buildUpdateType() {
MUpdateType updatetype = new MUpdateType(this.mStrict);
return updatetype;
}
protected MObject buildObject() {
MObject obj = new MObject(this.mStrict);
return obj;
}
protected MSearchHelp buildSearchHelp() {
MSearchHelp help = new MSearchHelp(this.mStrict);
return help;
}
protected MEditMask buildEditMask() {
MEditMask mask = new MEditMask(this.mStrict);
return mask;
}
protected MLookup buildLookup() {
MLookup lookup = new MLookup(this.mStrict);
return lookup;
}
protected MLookupType buildLookupType() {
MLookupType type = new MLookupType(this.mStrict);
return type;
}
protected MUpdateHelp buildUpdateHelp() {
MUpdateHelp help = new MUpdateHelp(this.mStrict);
return help;
}
protected MValidationLookup buildValidationLookup() {
MValidationLookup lookup = new MValidationLookup(this.mStrict);
return lookup;
}
protected MValidationExternalType buildValidationExternalType() {
MValidationExternalType type = new MValidationExternalType(this.mStrict);
return type;
}
protected MValidationExpression buildValidationExpression() {
MValidationExpression expression = new MValidationExpression(this.mStrict);
return expression;
}
protected MValidationExternal buildValidationExternal() {
MValidationExternal external = new MValidationExternal(this.mStrict);
return external;
}
protected MValidationLookupType buildValidationLookupType() {
MValidationLookupType lookupType = new MValidationLookupType(this.mStrict);
return lookupType;
}
public abstract Metadata doBuild(Object src) throws MetadataException;
public abstract MetaObject[] parse(Object src) throws MetadataException;
protected MetaObject newType(MetadataType type) {
if (type == MetadataType.SYSTEM) {
return buildSystem();
}
if (type == MetadataType.RESOURCE) {
return buildResource();
}
if (type == MetadataType.FOREIGNKEYS) {
return buildForeignKey();
}
if (type == MetadataType.CLASS) {
return buildClass();
}
if (type == MetadataType.TABLE) {
return buildTable();
}
if (type == MetadataType.UPDATE) {
return buildUpdate();
}
if (type == MetadataType.UPDATE_TYPE) {
return buildUpdateType();
}
if (type == MetadataType.OBJECT) {
return buildObject();
}
if (type == MetadataType.SEARCH_HELP) {
return buildSearchHelp();
}
if (type == MetadataType.EDITMASK) {
return buildEditMask();
}
if (type == MetadataType.UPDATE_HELP) {
return buildUpdateHelp();
}
if (type == MetadataType.LOOKUP) {
return buildLookup();
}
if (type == MetadataType.LOOKUP_TYPE) {
return buildLookupType();
}
if (type == MetadataType.VALIDATION_LOOKUP) {
return buildValidationLookup();
}
if (type == MetadataType.VALIDATION_LOOKUP_TYPE) {
return buildValidationLookupType();
}
if (type == MetadataType.VALIDATION_EXTERNAL) {
return buildValidationExternal();
}
if (type == MetadataType.VALIDATION_EXTERNAL_TYPE) {
return buildValidationExternalType();
}
if (type == MetadataType.VALIDATION_EXPRESSION) {
return buildValidationExpression();
}
throw new RuntimeException("No metadata type class found for " + type.name());
}
private boolean mStrict;
}

View File

@ -1,31 +0,0 @@
package com.ossez.usreio.tests.common.metadata;
public enum MetadataElement {
SYSTEM("System"),// might need to provide enumeration for different versions 1.5 vs 1.7
RESOURCE("Resource"),
FOREIGNKEY("ForeignKey"),
CLASS("Class"),
TABLE("Field"),
UPDATE("UpdateType"),
UPDATETYPE("UpdateField"),
OBJECT("Object"),
SEARCHHELP("SearchHelp"),
EDITMASK("EditMask"),
UPDATEHELP("UpdateHelp"),
LOOKUP("Lookup"),
LOOKUPTYPE("LookupType"),
VALIDATIONLOOKUP("ValidationLookup"),
VALIDATIONLOOKUPTYPE("ValidationLookupType"),
VALIDATIONEXPRESSION("ValidationExpression"),
VALIDATIONEXTERNAL("ValidationExternalType"),
VALIDATIONEXTERNALTYPE("ValidationExternal");
private final String elementName;
MetadataElement(String elementName){
this.elementName = elementName;
}
public String elementName(){ return this.elementName;}
}

View File

@ -1,27 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata;
public class MetadataException extends Exception {
public MetadataException() {
super();
}
public MetadataException(String msg) {
super(msg);
}
public MetadataException(Throwable cause) {
super(cause);
}
public MetadataException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -1,30 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata;
public enum MetadataType {
EDITMASK,
FOREIGNKEYS,
RESOURCE,
LOOKUP,
LOOKUP_TYPE,
OBJECT,
SEARCH_HELP,
SYSTEM,
TABLE,
UPDATE,
UPDATE_HELP,
UPDATE_TYPE,
VALIDATION_EXPRESSION,
VALIDATION_EXTERNAL,
VALIDATION_EXTERNAL_TYPE,
VALIDATION_LOOKUP,
VALIDATION_LOOKUP_TYPE,
CLASS;
}

View File

@ -1,49 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public abstract class AttrAbstractText implements AttrType<String> {
protected int min;
protected int max;
public AttrAbstractText(int min, int max) {
this.min = min;
this.max = max;
}
public String parse(String value, boolean strict) throws MetaParseException {
if( !strict )
return value;
int l = value.length();
if (this.min != 0 && l < this.min) {
throw new MetaParseException("Value too short (min " + this.min + "): " + l);
}
if (this.max != 0 && l > this.max) {
throw new MetaParseException("Value too long (max " + this.max + "): " + l);
}
checkContent(value);
return value;
}
public Class<String> getType() {
return String.class;
}
public String render(String value) {
return value;
}
protected abstract void checkContent(String value) throws MetaParseException;
}

View File

@ -1,31 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrAlphanum extends AttrAbstractText {
public AttrAlphanum(int min, int max) {
super(min, max);
}
@Override
protected void checkContent(String value) throws MetaParseException {
char[] chars = value.toCharArray();
for (int i = 0; i < chars.length; i++) {
char c = chars[i];
if (!Character.isLetterOrDigit(c)) {
// illegal but exist in CRT metadata
if ("_- ".indexOf(c) == -1) {
throw new MetaParseException("Invalid Alphanum character at position " + i + ": " + c);
}
}
}
}
}

View File

@ -1,54 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrBoolean implements AttrType<Boolean> {
public Boolean parse(String value, boolean strict) throws MetaParseException {
if (value.equals("1")) {
return Boolean.TRUE;
}
if (value.equals("0")) {
return Boolean.FALSE;
}
if (value.equalsIgnoreCase("true")) {
return Boolean.TRUE;
}
if (value.equalsIgnoreCase("false")) {
return Boolean.FALSE;
}
if (value.equalsIgnoreCase("Y")) {
return Boolean.TRUE;
}
if (value.equalsIgnoreCase("N")) {
return Boolean.FALSE;
}
if (value.equals("")) {
return Boolean.FALSE;
}
if( strict )
throw new MetaParseException("Invalid boolean value: " + value);
return false;
}
public String render(Boolean value) {
if( value.booleanValue() ) return "1";
return "0";
}
public Class<Boolean> getType() {
return Boolean.class;
}
}

View File

@ -1,71 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*
*
* Vangulo Changed:
* gives ability to handle dates in this format
* 2011-06-01T18:06:58
* should find a more elegant way
*/
package com.ossez.usreio.tests.common.metadata.attrib;
//import java.text.DateFormat;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.Date;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
/**
* Converted this class to return a String instead of a
* Date object which allows for more flexiblity since
* Many Rets Servers format their dates differently
*
* @author vangulo
*
*/
public class AttrDate implements AttrType<String> {
// need date attribute to be flexible since different MLS's have
// different formats for dates
public String parse(String value, boolean strict) throws MetaParseException {
return value;
// Date d;
// try {
// d = this.df.parse(value);
// } catch (ParseException e) {
// if( strict )
// throw new MetaParseException(e);
// try {
// value = value.replaceAll("[A-Za-z]", " ");
// d = this.df1.parse(value);
// } catch (ParseException e1) {
// //e1.printStackTrace();
// return value;
// }
// return d;
// }
// return d;
}
public String render(String value) {
return value;
//Date date = value;
//return this.df.format(date);
}
public Class<String> getType() {
return String.class;
}
//private DateFormat df = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss z");
//2011-06-01T18:06:58
//private DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//Tuesday, 22-Dec-2009 21:03:18 GMT
//private DateFormat df2 = new SimpleDateFormat("E, dd-MMM-yyyy HH:mm:ss z");
}

View File

@ -1,31 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import java.util.HashMap;
import java.util.Map;
import java.util.Collections;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrEnum extends AttrAbstractText {
public AttrEnum(String[] values) {
super(0, 0);
this.map = new HashMap<String,String>();
for (String value : values) this.map.put(value, value);
this.map = Collections.unmodifiableMap(this.map);
}
@Override
protected void checkContent(String value) throws MetaParseException {
if( !this.map.containsKey(value) )
throw new MetaParseException("Invalid key: " + value);
}
private Map<String,String> map;
}

View File

@ -1,31 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrGenericText extends AttrAbstractText {
private String mChars;
public AttrGenericText(int min, int max, String chars) {
super(min, max);
this.mChars = chars;
}
@Override
protected void checkContent(String value) throws MetaParseException {
char[] chars = value.toCharArray();
for (int i = 0; i < chars.length; i++) {
char c = chars[i];
if (this.mChars.indexOf(c) == -1) {
throw new MetaParseException("Invalid char (" + c + ") at position " + i);
}
}
}
}

View File

@ -1,31 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrNumeric implements AttrType<Integer> {
public Integer parse(String value, boolean strict) throws MetaParseException {
try {
return new Integer(value);
} catch (NumberFormatException e) {
if( strict )
throw new MetaParseException(e);
return 0;
}
}
public String render(Integer value) {
return value.toString();
}
public Class<Integer> getType() {
return Integer.class;
}
}

View File

@ -1,36 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrNumericPositive implements AttrType<Integer> {
public Integer parse(String value, boolean strict) throws MetaParseException {
try {
Integer integer = new Integer(value);
if (strict && integer < 1) throw new IllegalArgumentException(String.format("%s is not positive", value));
return integer;
} catch (Exception e) {
if( strict )
throw new MetaParseException(e);
return 1;
}
}
public String render(Integer value) {
return value.toString();
}
public Class<Integer> getType() {
return Integer.class;
}
}

View File

@ -1,28 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrPlaintext extends AttrAbstractText {
public AttrPlaintext(int min, int max) {
super(min, max);
}
@Override
protected void checkContent(String value) throws MetaParseException {
char[] chars = value.toCharArray();
for (int i = 0; i < chars.length; i++) {
char c = chars[i];
if (c < 31 || c > 126) {
throw new MetaParseException("Invalid character (ordinal " + (int) c + ") at position " + i);
}
}
}
}

View File

@ -1,28 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrText extends AttrAbstractText {
public AttrText(int min, int max) {
super(min, max);
}
@Override
protected void checkContent(String value) throws MetaParseException {
char[] chars = value.toCharArray();
for (int i = 0; i < chars.length; i++) {
char c = chars[i];
if (!(c == '\n' || c == '\r' || c == ' ' || c == '\t' || (c > 31 && c < 127))) {
throw new MetaParseException("Invalid character (ordinal " + (int) c + ") at position " + i);
}
}
}
}

View File

@ -1,66 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import org.apache.commons.lang3.StringUtils;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
/**
* A version is a string formatted "major.minor.release". This gets converted
* to an integer such as major * 10,000,000 + minor * 100,000 + release.
*/
public class AttrVersion implements AttrType<Integer> {
public Integer parse(String value, boolean strict) throws MetaParseException {
String[] parts = StringUtils.split(value, ".");
int major, minor, release;
if (strict && parts != null && parts.length != 3) {
throw new MetaParseException("Invalid version: " + value + ", " + parts.length + " parts");
}
try {
major = Integer.parseInt(this.getPart(parts,0));
minor = Integer.parseInt(this.getPart(parts,1));
release = Integer.parseInt(this.getPart(parts,2));
} catch (NumberFormatException e) {
throw new MetaParseException("Invalid version: " + value, e);
}
if ((major < 100) && (major >= 0) && (minor < 100) && (minor >= 0) && (release < 100000) && (release >= 0)) {
return new Integer(major * 10000000 + minor * 100000 + release);
}
if( strict )
throw new MetaParseException("Invalid version: " + value);
return 0;
}
private String getPart(String[] parts, int part){
if( parts != null && parts.length > part ) return parts[part];
return "0";
}
public String render(Integer value) {
int ver = value.intValue();
int release = ver % 100000;
int minor = (ver / 100000) % 100;
int major = (ver / 10000000);
String minstr = Integer.toString(minor);
String relstr = Integer.toString(release);
while (minstr.length() < 2) {
minstr = "0" + minstr;
}
while (relstr.length() < 5) {
relstr = "0" + relstr;
}
return major + "." + minstr + "." + relstr;
}
public Class<Integer> getType() {
return Integer.class;
}
}

View File

@ -1,126 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Collection;
//import java.util.Date;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MClass extends MetaObject {
public static final String CLASSNAME = "ClassName";
public static final String VISIBLENAME = "VisibleName";
public static final String STANDARDNAME = "StandardName";
public static final String DESCRIPTION = "Description";
public static final String TABLEVERSION = "TableVersion";
public static final String TABLEDATE = "TableDate";
public static final String UPDATEVERSION = "UpdateVersion";
public static final String UPDATEDATE = "UpdateDate";
public static final String DELETEDFLAGFIELD = "DeletedFlagField";
public static final String DELETEDFLAGVALUE = "DeletedFlagValue";
public static final String CLASSTIMESTAMP = "ClassTimeStamp";
public static final String HASHKEYINDEX = "HasKeyIndex";
private static MetadataType[] sTypes = { MetadataType.UPDATE, MetadataType.TABLE };
public MClass() {
this(DEFAULT_PARSING);
}
public MClass(boolean strictParsing) {
super(strictParsing);
}
@Override
public MetadataType[] getChildTypes() {
return sTypes;
}
public String getClassName() {
return getStringAttribute(CLASSNAME);
}
public String getVisibleName() {
return getStringAttribute(VISIBLENAME);
}
public String getStandardName() {
return getStringAttribute(STANDARDNAME);
}
public String getDescription() {
return getStringAttribute(DESCRIPTION);
}
public int getTableVersion() {
return getIntAttribute(TABLEVERSION);
}
public String getTableDate() {
return getDateAttribute(TABLEDATE);
}
public int getUpdateVersion() {
return getIntAttribute(UPDATEVERSION);
}
public String getUpdateDate() {
return getDateAttribute(UPDATEDATE);
}
public MUpdate getMUpdate(String updateName) {
return (MUpdate) getChild(MetadataType.UPDATE, updateName);
}
public MUpdate[] getMUpdates() {
MUpdate[] tmpl = new MUpdate[0];
return (MUpdate[]) getChildren(MetadataType.UPDATE).toArray(tmpl);
}
public MTable getMTable(String systemName) {
return (MTable) getChild(MetadataType.TABLE, systemName);
}
public MTable[] getMTables() {
Collection children = getChildren(MetadataType.TABLE);
return (MTable[]) children.toArray(new MTable[0]);
}
@Override
protected String getIdAttr() {
return CLASSNAME;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(CLASSNAME, sAlphanum32);
attributeMap.put(VISIBLENAME, sPlaintext32);
attributeMap.put(STANDARDNAME, sAlphanum32);
attributeMap.put(DESCRIPTION, sPlaintext128);
attributeMap.put(TABLEVERSION, sAttrVersion);
attributeMap.put(TABLEDATE, sAttrDate);
attributeMap.put(UPDATEVERSION, sAttrVersion);
attributeMap.put(UPDATEDATE, sAttrDate);
attributeMap.put(DELETEDFLAGFIELD, retsname);
attributeMap.put(DELETEDFLAGVALUE, sAlphanum32);
attributeMap.put(CLASSTIMESTAMP, retsname);
attributeMap.put(HASHKEYINDEX, sAttrBoolean);
}
public String getDeletedFlagField() {
return getStringAttribute(DELETEDFLAGFIELD);
}
public String getDeletedFlagValue() {
return getStringAttribute(DELETEDFLAGVALUE);
}
public String getClassTimeStamp() {
return getStringAttribute(CLASSTIMESTAMP);
}
public String getHashKeyIndex() {
return getStringAttribute(HASHKEYINDEX);
}
}

View File

@ -1,50 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MEditMask extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String EDITMASKID = "EditMaskID";
public static final String VALUE = "Value";
public MEditMask() {
this(DEFAULT_PARSING);
}
public MEditMask(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getEditMaskID() {
return getStringAttribute(EDITMASKID);
}
public String getValue() {
return getStringAttribute(VALUE);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return EDITMASKID;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(EDITMASKID, sAlphanum32);
attributeMap.put(VALUE, sText256);
}
}

View File

@ -1,87 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MForeignKey extends MetaObject {
public static final String FOREIGNKEYID = "ForeignKeyID";
public static final String PARENTRESOURCEID = "ParentResourceID";
public static final String PARENTCLASSID = "ParentClassID";
public static final String PARENTSYSTEMNAME = "ParentSystemName";
public static final String CHILDRESOURCEID = "ChildResourceID";
public static final String CHILDCLASSID = "ChildClassID";
public static final String CHILDSYSTEMNAME = "ChildSystemName";
public static final String CONDITIONALPARENTFIELD = "ConditionalParentField";
public static final String CONDITIONALPARENTVALUE = "ConditionalParentValue";
public MForeignKey() {
this(DEFAULT_PARSING);
}
public MForeignKey(boolean strictParsing) {
super(strictParsing);
}
public String getForeignKeyID() {
return getStringAttribute(FOREIGNKEYID);
}
public String getParentResourceID() {
return getStringAttribute(PARENTRESOURCEID);
}
public String getParentClassID() {
return getStringAttribute(PARENTCLASSID);
}
public String getParentSystemName() {
return getStringAttribute(PARENTSYSTEMNAME);
}
public String getChildResourceID() {
return getStringAttribute(CHILDRESOURCEID);
}
public String getChildClassID() {
return getStringAttribute(CHILDCLASSID);
}
public String getChildSystemName() {
return getStringAttribute(CHILDSYSTEMNAME);
}
public String getConditionalParentField() {
return getStringAttribute(CONDITIONALPARENTFIELD);
}
public String getConditionalParentValue() {
return getStringAttribute(CONDITIONALPARENTVALUE);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return FOREIGNKEYID;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(FOREIGNKEYID, sAlphanum32);
attributeMap.put(PARENTRESOURCEID, sAlphanum32);
attributeMap.put(PARENTCLASSID, sAlphanum32);
attributeMap.put(PARENTSYSTEMNAME, sAlphanum32);
attributeMap.put(CHILDRESOURCEID, sAlphanum32);
attributeMap.put(CHILDCLASSID, sAlphanum32);
attributeMap.put(CHILDSYSTEMNAME, sAlphanum32);
attributeMap.put(CONDITIONALPARENTFIELD, retsname);
attributeMap.put(CONDITIONALPARENTVALUE, retsname);
}
}

View File

@ -1,86 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
//import java.util.Date;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MLookup extends MetaObject {
private static final MetadataType[] CHILDREN = { MetadataType.LOOKUP_TYPE };
private static final MLookupType[] EMPTYLOOKUPTYPES = {};
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String LOOKUPNAME = "LookupName";
public static final String VISIBLENAME = "VisibleName";
public static final String VERSION = "Version";
public static final String DATE = "Date";
public static final String LOOKUPTYPEVERSION = "LookupTypeVersion";
public static final String LOOKUPTYPEDATE = "LookupTypeDate";
public MLookup() {
this(DEFAULT_PARSING);
}
public MLookup(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getLookupName() {
return getStringAttribute(LOOKUPNAME);
}
public String getVisibleName() {
return getStringAttribute(VISIBLENAME);
}
public int getVersion() {
int ver = getIntAttribute(VERSION);
if (ver == 0){
ver = getIntAttribute(LOOKUPTYPEVERSION);
}
return ver;
}
public String getDate() {
String date = getDateAttribute(DATE);
if (date == null) {
date = getDateAttribute(LOOKUPTYPEDATE);
}
return date;
}
public MLookupType getMLookupType(String value) {
return (MLookupType) getChild(MetadataType.LOOKUP_TYPE, value);
}
public MLookupType[] getMLookupTypes() {
return (MLookupType[]) getChildren(MetadataType.LOOKUP_TYPE).toArray(EMPTYLOOKUPTYPES);
}
@Override
public MetadataType[] getChildTypes() {
return CHILDREN;
}
@Override
protected String getIdAttr() {
return LOOKUPNAME;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(LOOKUPNAME, sAlphanum32);
attributeMap.put(VISIBLENAME, sPlaintext32);
attributeMap.put(VERSION, sAttrVersion);
attributeMap.put(DATE, sAttrDate);
attributeMap.put(LOOKUPTYPEVERSION, sAttrVersion);
attributeMap.put(LOOKUPTYPEDATE, sAttrDate);
}
}

View File

@ -1,56 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MLookupType extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String LONGVALUE = "LongValue";
public static final String SHORTVALUE = "ShortValue";
public static final String VALUE = "Value";
public MLookupType() {
this(DEFAULT_PARSING);
}
public MLookupType(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getLongValue() {
return getStringAttribute(LONGVALUE);
}
public String getShortValue() {
return getStringAttribute(SHORTVALUE);
}
public String getValue() {
return getStringAttribute(VALUE);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return VALUE;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(LONGVALUE, sText128);
attributeMap.put(SHORTVALUE, sText32);
attributeMap.put(VALUE, sAlphanum32);
}
}

View File

@ -1,79 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MObject extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String OBJECTTYPE = "ObjectType";
public static final String MIMETYPE = "MimeType";
public static final String VISIBLENAME = "VisibleName";
public static final String DESCRIPTION = "Description";
public static final String OBJECTTIMESTAMPNAME = "ObjectTimeStamp";
public static final String OBJECTCOUNT = "ObjectCount";
public static final String STANDARDNAME = "StandardName";
public MObject() {
this(DEFAULT_PARSING);
}
public MObject(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getObjectType() {
return getStringAttribute(OBJECTTYPE);
}
public String getMIMEType() {
return getStringAttribute(MIMETYPE);
}
public String getVisibleName() {
return getStringAttribute(VISIBLENAME);
}
public String getDescription() {
return getStringAttribute(DESCRIPTION);
}
public String getStandardName() {
return getStringAttribute(STANDARDNAME);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return OBJECTTYPE;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAlphanum24);
attributeMap.put(OBJECTTYPE, sAlphanum24);
attributeMap.put(MIMETYPE, sText64);
attributeMap.put(VISIBLENAME, sPlaintext64);
attributeMap.put(DESCRIPTION, sPlaintext128);
attributeMap.put(OBJECTTIMESTAMPNAME, retsname);
attributeMap.put(OBJECTCOUNT, retsname);
attributeMap.put(STANDARDNAME, retsname);
}
public String getObjectTimeStampName() {
return getStringAttribute(OBJECTTIMESTAMPNAME);
}
public String getObjectCount() {
return getStringAttribute(OBJECTCOUNT);
}
}

View File

@ -1,270 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
//import java.util.Date;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MResource extends MetaObject {
private static final MetadataType[] CHILDREN = {
MetadataType.VALIDATION_EXPRESSION,
MetadataType.LOOKUP,
MetadataType.CLASS,
MetadataType.OBJECT,
MetadataType.VALIDATION_EXTERNAL,
MetadataType.VALIDATION_LOOKUP,
MetadataType.EDITMASK,
MetadataType.UPDATE_HELP,
MetadataType.SEARCH_HELP
};
public static final String RESOURCEID = "ResourceID";
public static final String STANDARDNAME = "StandardName";
public static final String VISIBLENAME = "VisibleName";
public static final String DESCRIPTION = "Description";
public static final String KEYFIELD = "KeyField";
public static final String CLASSCOUNT = "ClassCount";
public static final String CLASSVERSION = "ClassVersion";
public static final String CLASSDATE = "ClassDate";
public static final String OBJECTVERSION = "ObjectVersion";
public static final String OBJECTDATE = "ObjectDate";
public static final String SEARCHHELPVERSION = "SearchHelpVersion";
public static final String SEARCHHELPDATE = "SearchHelpDate";
public static final String EDITMASKVERSION = "EditMaskVersion";
public static final String EDITMASKDATE = "EditMaskDate";
public static final String LOOKUPVERSION = "LookupVersion";
public static final String LOOKUPDATE = "LookupDate";
public static final String UPDATEHELPVERSION = "UpdateHelpVersion";
public static final String UPDATEHELPDATE = "UpdateHelpDate";
public static final String VALIDATIONEXPRESSIONVERSION = "ValidationExpressionVersion";
public static final String VALIDATIONEXPRESSIONDATE = "ValidationExpressionDate";
public static final String VALIDATIONLOOKUPVERSION = "ValidationLookupVersion";
public static final String VALIDATIONLOOKUPDATE = "ValidationLookupDate";
public static final String VALIDATIONEXTERNALVERSION = "ValidationExternalVersion";
public static final String VALIDATIONEXTERNALDATE = "ValidationExternalDate";
public MResource() {
this(DEFAULT_PARSING);
}
public MResource(boolean strictParsing) {
super(strictParsing);
}
public String getResourceID() {
return getStringAttribute(RESOURCEID);
}
public String getStandardName() {
return getStringAttribute(STANDARDNAME);
}
public String getVisibleName() {
return getStringAttribute(VISIBLENAME);
}
public String getDescription() {
return getStringAttribute(DESCRIPTION);
}
public String getKeyField() {
return getStringAttribute(KEYFIELD);
}
public int getClassCount() {
return getIntAttribute(CLASSCOUNT);
}
public int getClassVersion() {
return getIntAttribute(CLASSVERSION);
}
public String getClassDate() {
return getDateAttribute(CLASSDATE);
}
public int getObjectVersion() {
return getIntAttribute(OBJECTVERSION);
}
public String getObjectDate() {
return getDateAttribute(OBJECTDATE);
}
public int getSearchHelpVersion() {
return getIntAttribute(SEARCHHELPVERSION);
}
public String getSearchHelpDate() {
return getDateAttribute(SEARCHHELPDATE);
}
public int getEditMaskVersion() {
return getIntAttribute(EDITMASKVERSION);
}
public String getEditMaskDate() {
return getDateAttribute(EDITMASKDATE);
}
public int getLookupVersion() {
return getIntAttribute(LOOKUPVERSION);
}
public String getLookupDate() {
return getDateAttribute(LOOKUPDATE);
}
public int getUpdateHelpVersion() {
return getIntAttribute(UPDATEHELPVERSION);
}
public String getUpdateHelpDate() {
return getDateAttribute(UPDATEHELPDATE);
}
public int getValidationExpressionVersion() {
return getIntAttribute(VALIDATIONEXPRESSIONVERSION);
}
public String getValidationExpressionDate() {
return getDateAttribute(VALIDATIONEXPRESSIONDATE);
}
public int getValidationLookupVersion() {
return getIntAttribute(VALIDATIONLOOKUPVERSION);
}
public String getValidationLookupDate() {
return getDateAttribute(VALIDATIONLOOKUPDATE);
}
public int getValidationExternalVersion() {
return getIntAttribute(VALIDATIONEXTERNALVERSION);
}
public String getValidationExternalDate() {
return getDateAttribute(VALIDATIONEXTERNALDATE);
}
public MValidationExpression getMValidationExpression(String validationExpressionID) {
return (MValidationExpression) getChild(MetadataType.VALIDATION_EXPRESSION, validationExpressionID);
}
public MValidationExpression[] getMValidationExpressions() {
MValidationExpression[] tmpl = new MValidationExpression[0];
return (MValidationExpression[]) getChildren(MetadataType.VALIDATION_EXPRESSION).toArray(tmpl);
}
public MLookup getMLookup(String lookupName) {
return (MLookup) getChild(MetadataType.LOOKUP, lookupName);
}
public MLookup[] getMLookups() {
MLookup[] tmpl = new MLookup[0];
return (MLookup[]) getChildren(MetadataType.LOOKUP).toArray(tmpl);
}
public MClass getMClass(String className) {
return (MClass) getChild(MetadataType.CLASS, className);
}
public MClass[] getMClasses() {
MClass[] tmpl = new MClass[0];
return (MClass[]) getChildren(MetadataType.CLASS).toArray(tmpl);
}
public MObject getMObject(String objectType) {
return (MObject) getChild(MetadataType.OBJECT, objectType);
}
public MObject[] getMObjects() {
MObject[] tmpl = new MObject[0];
return (MObject[]) getChildren(MetadataType.OBJECT).toArray(tmpl);
}
public MValidationExternal getMValidationExternal(String validationExternalName) {
return (MValidationExternal) getChild(MetadataType.VALIDATION_EXTERNAL, validationExternalName);
}
public MValidationExternal[] getMValidationExternal() {
MValidationExternal[] tmpl = new MValidationExternal[0];
return (MValidationExternal[]) getChildren(MetadataType.VALIDATION_EXTERNAL).toArray(tmpl);
}
public MValidationLookup getMValidationLookup(String validationLookupName) {
return (MValidationLookup) getChild(MetadataType.VALIDATION_LOOKUP, validationLookupName);
}
public MValidationLookup[] getMValidationLookups() {
MValidationLookup[] tmpl = new MValidationLookup[0];
return (MValidationLookup[]) getChildren(MetadataType.VALIDATION_LOOKUP).toArray(tmpl);
}
public MEditMask getMEditMask(String editMaskID) {
return (MEditMask) getChild(MetadataType.EDITMASK, editMaskID);
}
public MEditMask[] getMEditMasks() {
MEditMask[] tmpl = new MEditMask[0];
return (MEditMask[]) getChildren(MetadataType.EDITMASK).toArray(tmpl);
}
public MUpdateHelp getMUpdateHelp(String updateHelpID) {
return (MUpdateHelp) getChild(MetadataType.UPDATE_HELP, updateHelpID);
}
public MUpdateHelp[] getMUpdateHelps() {
MUpdateHelp[] tmpl = new MUpdateHelp[0];
return (MUpdateHelp[]) getChildren(MetadataType.UPDATE_HELP).toArray(tmpl);
}
public MSearchHelp getMSearchHelp(String searchHelpID) {
return (MSearchHelp) getChild(MetadataType.SEARCH_HELP, searchHelpID);
}
public MSearchHelp[] getMSearchHelps() {
MSearchHelp[] tmpl = new MSearchHelp[0];
return (MSearchHelp[]) getChildren(MetadataType.SEARCH_HELP).toArray(tmpl);
}
@Override
public MetadataType[] getChildTypes() {
return CHILDREN;
}
@Override
protected String getIdAttr() {
return RESOURCEID;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(RESOURCEID, sAlphanum32);
attributeMap.put(STANDARDNAME, sAlphanum32);
attributeMap.put(VISIBLENAME, sPlaintext32);
attributeMap.put(DESCRIPTION, sPlaintext64);
attributeMap.put(KEYFIELD, sAlphanum32);
attributeMap.put(CLASSCOUNT, sAttrNumeric);
attributeMap.put(CLASSVERSION, sAttrVersion);
attributeMap.put(CLASSDATE, sAttrDate);
attributeMap.put(OBJECTVERSION, sAttrVersion);
attributeMap.put(OBJECTDATE, sAttrDate);
attributeMap.put(SEARCHHELPVERSION, sAttrVersion);
attributeMap.put(SEARCHHELPDATE, sAttrDate);
attributeMap.put(EDITMASKVERSION, sAttrVersion);
attributeMap.put(EDITMASKDATE, sAttrDate);
attributeMap.put(LOOKUPVERSION, sAttrVersion);
attributeMap.put(LOOKUPDATE, sAttrDate);
attributeMap.put(UPDATEHELPVERSION, sAttrVersion);
attributeMap.put(UPDATEHELPDATE, sAttrDate);
attributeMap.put(VALIDATIONEXPRESSIONVERSION, sAttrVersion);
attributeMap.put(VALIDATIONEXPRESSIONDATE, sAttrDate);
attributeMap.put(VALIDATIONLOOKUPVERSION, sAttrVersion);
attributeMap.put(VALIDATIONLOOKUPDATE, sAttrDate);
attributeMap.put(VALIDATIONEXTERNALVERSION, sAttrVersion);
attributeMap.put(VALIDATIONEXTERNALDATE, sAttrDate);
}
}

View File

@ -1,50 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MSearchHelp extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String SEARCHHELPID = "SearchHelpID";
public static final String VALUE = "Value";
public MSearchHelp() {
this(DEFAULT_PARSING);
}
public MSearchHelp(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getSearchHelpID() {
return getStringAttribute(SEARCHHELPID);
}
public String getValue() {
return getStringAttribute(VALUE);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return SEARCHHELPID;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(SEARCHHELPID, sAlphanum32);
attributeMap.put(VALUE, sText1024);
}
}

View File

@ -1,89 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
//import java.util.Date;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MSystem extends MetaObject {
public static final String SYSTEMID = "SystemID";
public static final String SYSTEMDESCRIPTION = "SystemDescription";
public static final String COMMENTS = "Comments";
public static final String DATE = "Date";
public static final String VERSION = "Version";
public static final String TIMEZONEOFFSET = "TimeZoneOffset";
public MSystem() {
this(DEFAULT_PARSING);
}
public MSystem(boolean strictParsing) {
super(strictParsing);
}
public String getSystemID() {
return getStringAttribute(SYSTEMID);
}
public String getComment() {
return getStringAttribute(COMMENTS);
}
public String getSystemDescription() {
return getStringAttribute(SYSTEMDESCRIPTION);
}
public String getDate() {
return getDateAttribute(DATE);
}
public String getTimeZoneOffset() {
return getDateAttribute(TIMEZONEOFFSET);
}
public int getVersion() {
return getIntAttribute(VERSION);
}
public MResource getMResource(String resourceID) {
return (MResource) getChild(MetadataType.RESOURCE, resourceID);
}
public MResource[] getMResources() {
MResource[] tmpl = new MResource[0];
return (MResource[]) getChildren(MetadataType.RESOURCE).toArray(tmpl);
}
public MForeignKey getMForeignKey(String foreignKeyID) {
return (MForeignKey) getChild(MetadataType.FOREIGNKEYS, foreignKeyID);
}
public MForeignKey[] getMForeignKeys() {
MForeignKey[] tmpl = new MForeignKey[0];
return (MForeignKey[]) getChildren(MetadataType.FOREIGNKEYS).toArray(tmpl);
}
@Override
public MetadataType[] getChildTypes() {
return CHILDREN;
}
@Override
protected String getIdAttr() {
return null;
}
public static final MetadataType[] CHILDREN = { MetadataType.RESOURCE, MetadataType.FOREIGNKEYS };
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(SYSTEMID, sAlphanum10);
attributeMap.put(SYSTEMDESCRIPTION, sPlaintext64);
attributeMap.put(DATE, sAttrDate);
attributeMap.put(VERSION, sAttrVersion);
attributeMap.put(COMMENTS, sText);
attributeMap.put(TIMEZONEOFFSET, sAttrDate);
}
}

View File

@ -1,242 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
import com.ossez.usreio.tests.common.metadata.attrib.AttrEnum;
public class MTable extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String SYSTEMNAME = "SystemName";
public static final String STANDARDNAME = "StandardName";
public static final String LONGNAME = "LongName";
public static final String DBNAME = "DBName";
public static final String SHORTNAME = "ShortName";
public static final String MAXIMUMLENGTH = "MaximumLength";
public static final String DATATYPE = "DataType";
public static final String PRECISION = "Precision";
public static final String SEARCHABLE = "Searchable";
public static final String INTERPRETATION = "Interpretation";
public static final String ALIGNMENT = "Alignment";
public static final String USESEPARATOR = "UseSeparator";
public static final String EDITMASKID = "EditMaskID";
public static final String LOOKUPNAME = "LookupName";
public static final String MAXSELECT = "MaxSelect";
public static final String UNITS = "Units";
public static final String INDEX = "Index";
public static final String MINIMUM = "Minimum";
public static final String MAXIMUM = "Maximum";
public static final String DEFAULT = "Default";
public static final String REQUIRED = "Required";
public static final String SEARCHHELPID = "SearchHelpID";
public static final String UNIQUE = "Unique";
public static final String MODTIMESTAMP = "ModTimeStamp";
public static final String MODTIMESTAMPNAME = "ModTimeStampName";
public static final String FOREIGNKEYNAME = "ForeignKeyName";
public static final String FOREIGNFIELD = "ForeignField";
public static final String INKEYINDEX = "InKeyIndex";
public static final String KEYQUERY = "KeyQuery";
public static final String KEYSELECT = "KeySelect";
private static final String[] DATATYPES = "Boolean,Character,Date,DateTime,Time,Tiny,Small,Int,Long,Decimal".split(",");
private static final AttrType sDataTypes = new AttrEnum(DATATYPES);
private static final String[] INTERPRETATIONS = "Number,Currency,Lookup,LookupMulti,LookupBitstring,LookupBitmask".split(",");
private static final AttrType sInterpretations = new AttrEnum(INTERPRETATIONS);
private static final String[] ALIGNMENTS = "Left,Right,Center,Justify".split(",");
private static final AttrType sAlignments = new AttrEnum(ALIGNMENTS);
private static final String[] UNITSS = "Feet,Meters,SqFt,SqMeters,Acres,Hectares".split(",");
private static final AttrType sUnits = new AttrEnum(UNITSS);
public MTable() {
this(DEFAULT_PARSING);
}
public MTable(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
String metadataEntryID = getStringAttribute(METADATAENTRYID);
if (metadataEntryID == null){
metadataEntryID = this.getSystemName();
}
return metadataEntryID;
}
public String getSystemName() {
return getStringAttribute(SYSTEMNAME);
}
public String getStandardName() {
return getStringAttribute(STANDARDNAME);
}
public String getLongName() {
return getStringAttribute(LONGNAME);
}
public String getDBName() {
return getStringAttribute(DBNAME);
}
public String getShortName() {
return getStringAttribute(SHORTNAME);
}
public int getMaximumLength() {
return getIntAttribute(MAXIMUMLENGTH);
}
public String getDataType() {
return getStringAttribute(DATATYPE);
}
public int getPrecision() {
return getIntAttribute(PRECISION);
}
public boolean getSearchable() {
return getBooleanAttribute(SEARCHABLE);
}
public String getInterpretation() {
return getStringAttribute(INTERPRETATION);
}
public boolean isLookup() {
String interp = getInterpretation();
if (interp != null && interp.startsWith("Lookup")) {
return true;
}
if (getSystemName().equalsIgnoreCase("status")) {
System.out.println("Field is " + getSystemName() + " and interp " + "is " + interp
+ " but isLookup() is false");
}
return false;
}
public String getAlignment() {
return getStringAttribute(ALIGNMENT);
}
public boolean getUseSeparator() {
return getBooleanAttribute(USESEPARATOR);
}
public String getEditMaskID() {
return getStringAttribute(EDITMASKID);
}
public String getLookupName() {
return getStringAttribute(LOOKUPNAME);
}
public int getMaxSelect() {
return getIntAttribute(MAXSELECT);
}
public String getUnits() {
return getStringAttribute(UNITS);
}
public int getIndex() {
return getIntAttribute(INDEX);
}
public int getMinimum() {
return getIntAttribute(MINIMUM);
}
public int getMaximum() {
return getIntAttribute(MAXIMUM);
}
public int getDefault() {
return getIntAttribute(DEFAULT);
}
public int getRequired() {
return getIntAttribute(REQUIRED);
}
public String getSearchHelpID() {
return getStringAttribute(SEARCHHELPID);
}
public boolean getUnique() {
return getBooleanAttribute(UNIQUE);
}
public boolean getModTimestamp() {
return getBooleanAttribute(MODTIMESTAMP);
}
public boolean getModTimestampName() {
return getBooleanAttribute(MODTIMESTAMPNAME);
}
public boolean getInKeyIndex() {
return getBooleanAttribute(INKEYINDEX);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return SYSTEMNAME;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, retsid);
attributeMap.put(SYSTEMNAME, retsname);
attributeMap.put(STANDARDNAME, retsname);
attributeMap.put(LONGNAME, sText256);
attributeMap.put(DBNAME, sAlphanum10);
attributeMap.put(SHORTNAME, sText64);
attributeMap.put(MAXIMUMLENGTH, sAttrNumericPositive);
attributeMap.put(DATATYPE, sDataTypes);
attributeMap.put(PRECISION, sAttrNumeric);
attributeMap.put(SEARCHABLE, sAttrBoolean);
attributeMap.put(INTERPRETATION, sInterpretations);
attributeMap.put(ALIGNMENT, sAlignments);
attributeMap.put(USESEPARATOR, sAttrBoolean);
// XXX: but multiples are separated by commas
attributeMap.put(EDITMASKID, retsname);
attributeMap.put(LOOKUPNAME, retsname);
attributeMap.put(MAXSELECT, sAttrNumeric);
attributeMap.put(UNITS, sUnits);
attributeMap.put(INDEX, sAttrNumeric);
attributeMap.put(MINIMUM, sAttrNumeric);
attributeMap.put(MAXIMUM, sAttrNumeric);
// XXX: serial
attributeMap.put(DEFAULT, sAttrNumeric);
attributeMap.put(REQUIRED, sAttrNumeric);
attributeMap.put(SEARCHHELPID, retsname);
attributeMap.put(UNIQUE, sAttrBoolean);
attributeMap.put(MODTIMESTAMP, sAttrBoolean);
attributeMap.put(MODTIMESTAMPNAME, retsname);
attributeMap.put(FOREIGNKEYNAME,retsid);
attributeMap.put(FOREIGNFIELD,retsname);
attributeMap.put(INKEYINDEX, sAttrBoolean);
attributeMap.put(KEYQUERY, sAttrBoolean);
attributeMap.put(KEYSELECT, sAttrBoolean);
}
public String getForeignKeyName() {
return getStringAttribute(FOREIGNKEYNAME);
}
public String getForeignField() {
return getStringAttribute(FOREIGNFIELD);
}
}

View File

@ -1,91 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
//import java.util.Date;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MUpdate extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String UPDATENAME = "UpdateName";
public static final String DESCRIPTION = "Description";
public static final String KEYFIELD = "KeyField";
public static final String VERSION = "Version";
public static final String DATE = "Date";
public static final String UPDATETYPEVERSION = "UpdateTypeVersion";
public static final String UPDATETYPEDATE = "UpdateTypeDate";
public MUpdate() {
this(DEFAULT_PARSING);
}
public MUpdate(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getUpdateName() {
return getStringAttribute(UPDATENAME);
}
public String getDescription() {
return getStringAttribute(DESCRIPTION);
}
public String getKeyField() {
return getStringAttribute(KEYFIELD);
}
public int getVersion() {
int v = getIntAttribute(VERSION);
if (v == 0){
v = getIntAttribute(UPDATETYPEVERSION);
}
return v;
}
public String getDate() {
String d = getDateAttribute(DATE);
if (d == null ){
d = getDateAttribute(UPDATETYPEDATE);
}
return d;
}
public MUpdateType getMUpdateType(String systemName) {
return (MUpdateType) getChild(MetadataType.UPDATE_TYPE, systemName);
}
public MUpdateType[] getMUpdateTypes() {
MUpdateType[] tmpl = new MUpdateType[0];
return (MUpdateType[]) getChildren(MetadataType.UPDATE_TYPE).toArray(tmpl);
}
@Override
public MetadataType[] getChildTypes() {
return sTypes;
}
@Override
protected String getIdAttr() {
return UPDATENAME;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(UPDATENAME, sAlphanum24);
attributeMap.put(DESCRIPTION, sPlaintext64);
attributeMap.put(KEYFIELD, sAlphanum32);
attributeMap.put(VERSION, sAttrVersion);
attributeMap.put(DATE, sAttrDate);
attributeMap.put(UPDATETYPEVERSION, sAttrVersion);
attributeMap.put(UPDATETYPEDATE, sAttrDate);
}
private static final MetadataType[] sTypes = { MetadataType.UPDATE_TYPE };
}

View File

@ -1,50 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MUpdateHelp extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String UPDATEHELPID = "UpdateHelpID";
public static final String VALUE = "Value";
public MUpdateHelp() {
this(DEFAULT_PARSING);
}
public MUpdateHelp(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getUpdateHelpID() {
return getStringAttribute(UPDATEHELPID);
}
public String getValue() {
return getStringAttribute(VALUE);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return UPDATEHELPID;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(UPDATEHELPID, sAlphanum32);
attributeMap.put(VALUE, sText1024);
}
}

View File

@ -1,103 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
import com.ossez.usreio.tests.common.metadata.attrib.AttrGenericText;
public class MUpdateType extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String SYSTEMNAME = "SystemName";
public static final String SEQUENCE = "Sequence";
public static final String ATTRIBUTES = "Attributes";
public static final String DEFAULT = "Default";
public static final String VALIDATIONEXPRESSIONID = "ValidationExpressionID";
public static final String UPDATEHELPID = "UpdateHelpID";
public static final String VALIDATIONLOOKUPNAME = "ValidationLookupName";
public static final String VALIDATIONEXTERNALNAME = "ValidationExternalName";
public static final String MAXCHOICE = "MaxChoice";
public static final String MAXUPDATE = "MaxUpdate";
private static final AttrType sAttributes = new AttrGenericText(0, 10, "12345,");
public MUpdateType() {
this(DEFAULT_PARSING);
}
public MUpdateType(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getSystemName() {
return getStringAttribute(SYSTEMNAME);
}
public int getSequence() {
return getIntAttribute(SEQUENCE);
}
public String getAttributes() {
return getStringAttribute(ATTRIBUTES);
}
public String getDefault() {
return getStringAttribute(DEFAULT);
}
public String getValidationExpressionID() {
return getStringAttribute(VALIDATIONEXPRESSIONID);
}
public String getUpdateHelpID() {
return getStringAttribute(UPDATEHELPID);
}
public String getValidationLookupName() {
return getStringAttribute(VALIDATIONLOOKUPNAME);
}
public String getValidationExternalName() {
return getStringAttribute(VALIDATIONEXTERNALNAME);
}
public int getMaxChoice() {
return getIntAttribute(MAXCHOICE);
}
public int getMaxUpdate() {
return getIntAttribute(MAXUPDATE);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return SYSTEMNAME;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(SYSTEMNAME, sAlphanum32);
attributeMap.put(SEQUENCE, sAttrNumeric);
attributeMap.put(ATTRIBUTES, sAttributes);
attributeMap.put(DEFAULT, sPlaintext);
attributeMap.put(VALIDATIONEXPRESSIONID, sAlphanum32);
attributeMap.put(UPDATEHELPID, sAlphanum32);
attributeMap.put(VALIDATIONLOOKUPNAME, sAlphanum32);
attributeMap.put(VALIDATIONEXTERNALNAME, sAlphanum32);
attributeMap.put(MAXCHOICE, sAttrNumeric);
attributeMap.put(MAXUPDATE, sAttrNumeric);
}
}

View File

@ -1,61 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
import com.ossez.usreio.tests.common.metadata.attrib.AttrEnum;
public class MValidationExpression extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String VALIDATIONEXPRESSIONID = "ValidationExpressionID";
public static final String VALIDATIONEXPRESSIONTYPE = "ValidationExpressionType";
public static final String VALUE = "Value";
private static final String[] VALIDATIONEXPRESSIONTYPES = "ACCEPT,REJECT,SET".split(",");
private static final AttrType sExpressionType = new AttrEnum(VALIDATIONEXPRESSIONTYPES);
public MValidationExpression() {
this(DEFAULT_PARSING);
}
public MValidationExpression(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getValidationExpressionID() {
return getStringAttribute(VALIDATIONEXPRESSIONID);
}
public String getValidationExpressionType() {
return getStringAttribute(VALIDATIONEXPRESSIONTYPE);
}
public String getValue() {
return getStringAttribute(VALUE);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return VALIDATIONEXPRESSIONID;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(VALIDATIONEXPRESSIONID, sAlphanum32);
attributeMap.put(VALIDATIONEXPRESSIONTYPE, sExpressionType);
attributeMap.put(VALUE, sText512);
}
}

View File

@ -1,76 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
//import java.util.Date;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MValidationExternal extends MetaObject {
private static final MetadataType[] CHILDREN = { MetadataType.VALIDATION_EXTERNAL_TYPE };
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String VALIDATIONEXTERNALNAME = "ValidationExternalName";
public static final String SEARCHRESOURCE = "SearchResource";
public static final String SEARCHCLASS = "SearchClass";
public static final String VERSION = "Version";
public static final String DATE = "Date";
public MValidationExternal() {
this(DEFAULT_PARSING);
}
public MValidationExternal(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getValidationExternalName() {
return getStringAttribute(VALIDATIONEXTERNALNAME);
}
public String getSearchResource() {
return getStringAttribute(SEARCHRESOURCE);
}
public String getSearchClass() {
return getStringAttribute(SEARCHCLASS);
}
public int getVersion() {
return getIntAttribute(VERSION);
}
public String getDate() {
return getDateAttribute(DATE);
}
public MValidationExternalType[] getMValidationExternalTypes() {
MValidationExternalType[] tmpl = new MValidationExternalType[0];
return (MValidationExternalType[]) getChildren(MetadataType.VALIDATION_EXTERNAL_TYPE).toArray(tmpl);
}
@Override
public MetadataType[] getChildTypes() {
return CHILDREN;
}
@Override
protected String getIdAttr() {
return VALIDATIONEXTERNALNAME;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(VALIDATIONEXTERNALNAME, sAlphanum32);
attributeMap.put(SEARCHRESOURCE, sAlphanum32);
attributeMap.put(SEARCHCLASS, sAlphanum32);
attributeMap.put(VERSION, sAttrVersion);
attributeMap.put(DATE, sAttrDate);
}
}

View File

@ -1,57 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MValidationExternalType extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String SEARCHFIELD = "SearchField";
public static final String DISPLAYFIELD = "DisplayField";
public static final String RESULTFIELDS = "ResultFields";
public MValidationExternalType() {
this(DEFAULT_PARSING);
}
public MValidationExternalType(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getSearchField() {
return getStringAttribute(SEARCHFIELD);
}
public String getDisplayField() {
return getStringAttribute(DISPLAYFIELD);
}
public String getResultFields() {
return getStringAttribute(RESULTFIELDS);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return null;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(SEARCHFIELD, sPlaintext512);
attributeMap.put(DISPLAYFIELD, sPlaintext512);
attributeMap.put(RESULTFIELDS, sPlaintext1024);
}
}

View File

@ -1,76 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
//import java.util.Date;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MValidationLookup extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String VALIDATIONLOOKUPNAME = "ValidationLookupName";
public static final String PARENT1FIELD = "Parent1Field";
public static final String PARENT2FIELD = "Parent2Field";
public static final String VERSION = "Version";
public static final String DATE = "Date";
private static final MetadataType[] sChildren = { MetadataType.VALIDATION_LOOKUP_TYPE };
public MValidationLookup() {
this(DEFAULT_PARSING);
}
public MValidationLookup(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getValidationLookupName() {
return getStringAttribute(VALIDATIONLOOKUPNAME);
}
public String getParent1Field() {
return getStringAttribute(PARENT1FIELD);
}
public String getParent2Field() {
return getStringAttribute(PARENT2FIELD);
}
public int getVersion() {
return getIntAttribute(VERSION);
}
public String getDate() {
return getDateAttribute(DATE);
}
@Override
public MetadataType[] getChildTypes() {
return sChildren;
}
@Override
protected String getIdAttr() {
return VALIDATIONLOOKUPNAME;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(VALIDATIONLOOKUPNAME, sAlphanum32);
attributeMap.put(PARENT1FIELD, sAlphanum32);
attributeMap.put(PARENT2FIELD, sAlphanum32);
attributeMap.put(VERSION, sAttrVersion);
attributeMap.put(DATE, sAttrDate);
}
public MValidationLookupType[] getMValidationLookupTypes() {
MValidationLookupType[] tmpl = new MValidationLookupType[0];
return (MValidationLookupType[]) getChildren(MetadataType.VALIDATION_LOOKUP_TYPE).toArray(tmpl);
}
}

View File

@ -1,56 +0,0 @@
package com.ossez.usreio.tests.common.metadata.types;
import java.util.Map;
import com.ossez.usreio.tests.common.metadata.MetaObject;
import com.ossez.usreio.tests.common.metadata.MetadataType;
public class MValidationLookupType extends MetaObject {
public static final String METADATAENTRYID = "MetadataEntryID";
public static final String VALIDTEXT = "ValidText";
public static final String PARENT1VALUE = "Parent1Value";
public static final String PARENT2VALUE = "Parent2Value";
public MValidationLookupType() {
this(DEFAULT_PARSING);
}
public MValidationLookupType(boolean strictParsing) {
super(strictParsing);
}
public String getMetadataEntryID() {
return getStringAttribute(METADATAENTRYID);
}
public String getValidText() {
return getStringAttribute(VALIDTEXT);
}
public String getParent1Value() {
return getStringAttribute(PARENT1VALUE);
}
public String getParent2Value() {
return getStringAttribute(PARENT2VALUE);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return null;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(METADATAENTRYID, sAttrMetadataEntryId);
attributeMap.put(VALIDTEXT, sAlphanum32);
attributeMap.put(PARENT1VALUE, sAlphanum32);
attributeMap.put(PARENT2VALUE, sAlphanum32);
}
}

View File

@ -1,102 +0,0 @@
package com.ossez.usreio.util;
import com.ossez.usreio.client.*;
import com.ossez.usreio.common.rets.RetsConfigurator;
import com.ossez.usreio.common.rets.RetsVersion;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* SessionUtils for RETS server session
*
* @author YuCheng Hu
*/
public final class SessionUtils {
private static final Logger logger = LoggerFactory.getLogger(SessionUtils.class);
// Prevent the class from being constructed
private SessionUtils() {
}
/**
* @param retsConfigurator
* @return
* @throws RetsException
*/
public static RetsSession retsLogin(RetsConfigurator retsConfigurator) throws RetsException {
logger.debug("RETS Session Login URL: [{}]", retsConfigurator.getServerUrl());
LoginResponse loginResponse = new LoginResponse();
//Create a RetsHttpClient (other constructors provide configuration i.e. timeout, gzip capability)
RetsHttpClient httpClient = new CommonsHttpClient();
// SET RETS VERSION
if (ObjectUtils.isEmpty(retsConfigurator.getRetsVersion()))
retsConfigurator.setRetsVersion(RetsVersion.DEFAULT);
//Create a RetesSession with RetsHttpClient
RetsSession session = new RetsSession(retsConfigurator.getServerUrl(), httpClient, retsConfigurator.getRetsVersion());
//Set method as GET or POST
session.setMethod("POST");
try {
//Login
loginResponse = session.login(retsConfigurator.getServerUsername(), retsConfigurator.getServerPassword());
} catch (RetsException ex) {
throw ex;
}
// SESSION NULL CHECK
if (!(!ObjectUtils.isEmpty(session) && StringUtils.isNotEmpty(loginResponse.getSessionId()))) {
session = null;
}
logger.info("Session ID :[{}]", loginResponse.getSessionId());
return session;
}
/**
* Login to Server and return session Object
*
* @param retsLoginUrl
* @param retsUsername
* @param retsPassword
* @return
*/
public static RetsSession retsLogin(String retsLoginUrl, String retsUsername, String retsPassword, RetsVersion retsVersion) throws RetsException {
logger.debug("RETS Session Login URL: [{}]", retsLoginUrl);
LoginResponse loginResponse = new LoginResponse();
//Create a RetsHttpClient (other constructors provide configuration i.e. timeout, gzip capability)
RetsHttpClient httpClient = new CommonsHttpClient();
// SET RETS VERSION
if (ObjectUtils.isEmpty(retsVersion))
retsVersion = RetsVersion.DEFAULT;
//Create a RetesSession with RetsHttpClient
RetsSession session = new RetsSession(retsLoginUrl, httpClient, retsVersion);
//Set method as GET or POST
session.setMethod("POST");
try {
//Login
loginResponse = session.login(retsUsername, retsPassword);
} catch (RetsException ex) {
throw ex;
}
// SESSION NULL CHECK
if (!(!ObjectUtils.isEmpty(session) && StringUtils.isNotEmpty(loginResponse.getSessionId()))) {
session = null;
}
logger.info("Session ID :[{}]", loginResponse.getSessionId());
return session;
}
}

View File

@ -1,41 +0,0 @@
<table name="SYSTEM">
<table name="RESOURCE" id-column="ResourceID">
<table name="CLASS" id-column="ClassName" path-attributes="Resource">
<table name="TABLE" id-column="SystemName"
path-attributes="Resource,Class"/>
<table name="UPDATE" id-column="UpdateName"
path-attributes="Resource,Class">
<table name="UPDATE_TYPE" id-column="SystemName"
path-attributes="Resource,Class,Update"/>
</table>
</table>
<table name="UPDATE_HELP" id-column="UpdateHelpID"
path-attributes="Resource"/>
<table name="OBJECT" id-column="ObjectType" path-attributes="Resource"/>
<table name="SEARCH_HELP" id-column="SearchHelpID"
path-attributes="Resource"/>
<table name="EDITMASK" id-column="EditMaskId" path-attributes="Resource"/>
<table name="LOOKUP" id-column="LookupName" path-attributes="Resource">
<table name="LOOKUP_TYPE" id-column="LongValue"
path-attributes="Resource,Lookup"/>
</table>
<table name="VALIDATION_LOOKUP" id-column="ValidationLookupName"
path-attributes="Resource">
<table name="VALIDATION_LOOKUP_TYPE" id-column="ValidText"
path-attributes="Resource,ValidationLookup"/>
</table>
<table name="VALIDATION_EXTERNAL" id-column="ValidationExternalName"
path-attributes="Resource">
<table name="VALIDATION_EXTERNAL_TYPE" id-column="SearchField"
path-attributes="Resource,ValidationExternal"/>
</table>
<table name="VALIDATION_EXPRESSION" id-column="ValidationExpressionID"
path-attributes="Resource"/>
</table>
<table name="FOREIGNKEYS" id-column="ForeignKeyID"/>
</table>

View File

@ -1,31 +0,0 @@
package com.ossez.usreio.tests.client;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* A suite of all tests in the org.realtors.rets.client.* package.
*/
public class AllTests {
/**
* Returns a test suite for all classes in org.realtors.rets.client.*.
*/
public static Test suite() {
TestSuite suite;
suite = new TestSuite();
/*suite.addTestSuite(GetMetadataRequestTest.class);
suite.addTestSuite(GetMetadataResponseTest.class);
suite.addTestSuite(GetObjectResponseIteratorTest.class);
suite.addTestSuite(LoginRequestTest.class);
suite.addTestSuite(LoginResponseTest.class);
suite.addTestSuite(LogoutResponseTest.class);
// suite.addTestSuite(MetadataTableTest.class);
// suite.addTestSuite(MetadataTableBuilderTest.class);
suite.addTestSuite(RetsVersionTest.class);
suite.addTestSuite(SearchResultImplTest.class);
suite.addTestSuite(SearchResultHandlerTest.class);
suite.addTestSuite(SingleObjectResponseTest.class);*/
return suite;
}
}

View File

@ -1,52 +0,0 @@
package com.ossez.usreio.tests.client;
import org.junit.jupiter.api.Test;
import com.ossez.usreio.client.retsapi.RETSConnection;
import com.ossez.usreio.client.retsapi.RETSLoginTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.util.Properties;
/**
* @author YuCheng
*/
public class ConnectionTest {
private final static Logger logger = LoggerFactory.getLogger(ConnectionTest.class);
/**
* Do RetsServerConnection Test
*/
@Test
public void testStaticVariableChange() {
// BasicConfigurator.configure();
RETSConnection rc = new RETSConnection();
RETSLoginTransaction trans = new RETSLoginTransaction();
try {
Properties props = new Properties();
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream inputStream = loader.getResourceAsStream("rets.properties");
props.load(inputStream);
// Add the optional request parameters if they exist, are non-null and non-zero-length
// rc.setRequestHeaderField("Authorization", (String)props.get("login.AUTHORIZATION"));
rc.setServerUrl((String) props.getProperty("rets_server"));
trans.setUrl((String) props.getProperty("rets_server"));
trans.setUsername((String) props.getProperty("rets_username"));
trans.setPassword((String) props.getProperty("rets_password"));
} catch (Exception e) {
e.printStackTrace();
}
rc.execute(trans);
}
}

View File

@ -1,58 +0,0 @@
package com.ossez.usreio.tests.client;
import com.ossez.usreio.client.GetMetadataRequest;
import com.ossez.usreio.client.InvalidArgumentException;
import com.ossez.usreio.client.RetsException;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNull;
public class GetMetadataRequestTest extends RetsTestCase {
public void testGetMetadataRequestSimple() throws RetsException {
GetMetadataRequest request = new GetMetadataRequest("SYSTEM", "*");
request.setUrl("http://rets.test:6103/getMetadata");
assertFalse(request.isCompactFormat());
assertTrue(request.isStandardXmlFormat());
// assertNull(request.getStandardXmlVersion());
// assertEquals("http://rets.test:6103/getMetadata", request.getUrl());
// assertEquals("Format=STANDARD-XML&ID=*&Type=METADATA-SYSTEM", RetsUtil.urlDecode(request.getHttpParameters()));
}
public void testGetMetadataRequestMultipleIds() throws RetsException {
GetMetadataRequest request = new GetMetadataRequest("UPDATE_TYPE", new String[] { "ActiveAgent", "ACTAGT",
"Change_ACTAGT" });
request.setCompactFormat();
assertTrue(request.isCompactFormat());
assertFalse(request.isStandardXmlFormat());
// assertEquals("Format=COMPACT&ID=ActiveAgent:ACTAGT:Change_ACTAGT" + "&Type=METADATA-UPDATE_TYPE", RetsUtil
// .urlDecode(request.getHttpParameters()));
}
public void testInvalidGetMetadataRequests() throws RetsException {
try {
// ID for METADATA-SYSTEM can only be 0 or *
new GetMetadataRequest("SYSTEM", "Blah");
// fail("Should have thrown an InvalidArgumentException");
} catch (InvalidArgumentException e) {
// Expected
}
try {
// ID for METADATA-RESOURCE can only be 0 or *
new GetMetadataRequest("RESOURCE", "Blah");
// fail("Should have thrown an InvalidArgumentException");
} catch (InvalidArgumentException e) {
// Expected
}
try {
// Must have at least 1 ID
new GetMetadataRequest("RESOURCE", new String[0]);
// fail("Should have thrown an InvalidArgumentException");
} catch (InvalidArgumentException e) {
// Expected
}
}
}

View File

@ -1,156 +0,0 @@
package com.ossez.usreio.tests.client;
//import java.util.List;
//import java.util.ArrayList;
//import java.util.Iterator;
//import java.util.Map;
public class GetMetadataResponseTest extends RetsTestCase {
public void testValidSystemMetadataResponse() {
// GetMetadataResponse response = new GetMetadataResponse(
// getResource("getMetadataResponse_system.xml"));
// MetadataSegment[] segments = response.getMetadataSegments();
// assertEquals(1, segments.length);
// MetadataSegment segment = segments[0];
// assertEquals("SYSTEM", segment.getName());
// assertEquals("01.00.001", segment.getAttribute("Version"));
// assertEquals("Tue, 27 May 2003 12:00:00 CDT",
// segment.getAttribute("Date"));
// assertEquals("CRT_RETS", segment.getSystemId());
// assertEquals("Center for REALTOR Technology",
// segment.getSystemDescription());
// assertEquals("The reference implementation of a RETS Server",
// segment.getSystemComments());
// assertNull(segment.getColumns());
// assertNull(segment.getData());
}
public void testSingleSegmentResponse() {
// GetMetadataResponse response = new GetMetadataResponse(
// getResource("getMetadataResponse_updateType.xml"));
//
// MetadataSegment[] segments = response.getMetadataSegments();
// assertEquals(1, segments.length);
// MetadataSegment segment = segments[0];
// assertEquals("UPDATE_TYPE", segment.getName());
//
// assertEquals("ActiveAgent", segment.getAttribute("resource"));
// assertEquals("ACTAGT", segment.getAttribute("CLASS"));
// assertEquals("Change_ACTAGT", segment.getAttribute("update"));
// assertEquals("1.00.000", segment.getAttribute("VERSION"));
// assertEquals("Sat, 20 Mar 2002 12:03:38 GMT",
// segment.getAttribute("date"));
//
// // Try with the opposite case above to check case-insensitive
// // comparisons
// Map attributes = segment.getAttributes();
// assertEquals(5, attributes.size());
// assertEquals("ActiveAgent", attributes.get("RESOURCE"));
// assertEquals("ACTAGT", attributes.get("class"));
// assertEquals("Change_ACTAGT", attributes.get("UPDATE"));
// assertEquals("1.00.000", attributes.get("version"));
// assertEquals("Sat, 20 Mar 2002 12:03:38 GMT",
// attributes.get("DATE"));
//
// assertNull(segment.getSystemId());
// assertNull(segment.getSystemDescription());
// assertNull(segment.getSystemComments());
//
// List columns = segment.getColumns();
// assertNotNull("columns not null", columns);
// assertEquals("columns.size", 8, columns.size());
//
// List expectedColumns = new ArrayList();
// expectedColumns.add("SystemName");
// expectedColumns.add("Sequence");
// expectedColumns.add("Attributes");
// expectedColumns.add("Default");
// expectedColumns.add("ValidationExpressionID");
// expectedColumns.add("UpdateHelpID");
// expectedColumns.add("ValidationLookupName");
// expectedColumns.add("ValidationExternalName");
// assertEquals("columns", expectedColumns, columns);
//
// List data = segment.getData();
// assertNotNull(data);
// assertEquals(2, data.size());
// Iterator i = data.iterator();
//
// assertTrue(i.hasNext());
// List dataRow = (List) i.next();
// assertEquals(8, dataRow.size());
// List expectedDataRow = new ArrayList();
// expectedDataRow.add("AGENT_ID");
// expectedDataRow.add("1");
// expectedDataRow.add("1");
// expectedDataRow.add("0");
// expectedDataRow.add(null);
// expectedDataRow.add(null);
// expectedDataRow.add(null);
// expectedDataRow.add(null);
// assertEquals(expectedDataRow, dataRow);
//
// assertTrue(i.hasNext());
// dataRow = (List) i.next();
// assertEquals(8, dataRow.size());
// expectedDataRow = new ArrayList();
// expectedDataRow.add("OFFICE_ID");
// expectedDataRow.add("2");
// expectedDataRow.add("2");
// expectedDataRow.add("0");
// expectedDataRow.add(null);
// expectedDataRow.add(null);
// expectedDataRow.add(null);
// expectedDataRow.add(null);
// assertEquals(expectedDataRow, dataRow);
}
public void testMultipleSegmentResponse() {
// GetMetadataResponse response = new GetMetadataResponse(
// getResource("getMetadataResponse_lookupZero.xml"));
//
// MetadataSegment[] segments = response.getMetadataSegments();
// assertEquals(2, segments.length);
//
// // Check first segment
// MetadataSegment segment = segments[0];
// assertEquals("LOOKUP", segment.getName());
// assertEquals("Property", segment.getAttribute("Resource"));
// List columns = segment.getColumns();
// assertNotNull(columns);
// assertEquals(4, columns.size());
//
// List expectedColumns = new ArrayList();
// expectedColumns.add("LookupName");
// expectedColumns.add("VisibleName");
// expectedColumns.add("Version");
// expectedColumns.add("Date");
// assertEquals("columns", expectedColumns, columns);
//
// List data = segment.getData();
// assertNotNull(data);
// assertEquals(9, data.size());
//
// // Check second segment
// segment = segments[1];
// assertEquals("LOOKUP", segment.getName());
// assertEquals("Agent", segment.getAttribute("Resource"));
// columns = segment.getColumns();
// assertNotNull(columns);
// assertEquals(4, columns.size());
// assertEquals("columns", expectedColumns, columns);
//
// data = segment.getData();
// assertNotNull(data);
// assertEquals(1, data.size());
}
public void testNoRecordsMetadataResponse() {
// GetMetadataResponse response = new GetMetadataResponse(
// getResource("getMetadataResponse_noRecords.xml"));
//
// MetadataSegment[] segments = response.getMetadataSegments();
// assertEquals(0, segments.length);
}
}

View File

@ -1,194 +0,0 @@
package com.ossez.usreio.tests.client;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import com.ossez.usreio.client.GetObjectIterator;
import com.ossez.usreio.client.GetObjectResponse;
import com.ossez.usreio.client.SingleObjectResponse;
import junit.framework.TestCase;
public class GetObjectResponseIteratorTest extends TestCase {
private static final String BOUNDARY = "jack";
private static final String BINARY_BLOB_1 = "1)dcg fa8 5 uiwjskdgsdfkg hdsfa bdf" + " erkfjhwfewuhuh"
+ "B\r\n\r\n";
private static final String BINARY_BLOB_2 = "2)dcg fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" + "\tAAAAAAAAAAAAhdsfa bdf";
private static final String BINARY_BLOB_3 = "3)dcg fAAAAAAAAAAAAAAAAA\t\\!"
+ "\r\n\r\nAAAAAAAAAAAAAAAAAAAAAAAAAhdsfa bdf";
private static final String BINARY_BLOB_4 = "fgsdgsdfg";
private static final String BINARY_BLOB_5 = "4)dcg fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhdsfa bdf";
public static final byte[] MULTIPART_RESPONSE_BODY = ("--" + BOUNDARY + "\r\n" + "Content-Type: text\r\n"
+ "Content-ID: one\r\n" + "Object-ID: 1\r\n" + "\r\n" + BINARY_BLOB_1 + "\r\n--" + BOUNDARY + "\r\n"
+ "Content-Type: gray-matter\r\n" + "Content-ID: two\r\n" + "Object-ID: 2\r\n" + "\r\n" + BINARY_BLOB_2
+ "\r\n--" + BOUNDARY + "\r\n" + "Content-Type: blue-matter\r\n" + "Content-ID: three\r\n"
+ "Object-ID: 3\r\n" + "\r\n" + BINARY_BLOB_3 + "\r\n--" + BOUNDARY + "\r\n"
+ "Content-Type: green-matter\r\n" + "Content-ID: four\r\n" + "Object-ID: 4\r\n" + "\r\n" + BINARY_BLOB_4
+ "\r\n--" + BOUNDARY + "\r\n" + "Content-Type: yellow-matter-custard\r\n" + "Content-ID: five\r\n"
+ "Object-ID: 5\r\n" + "\r\n" + BINARY_BLOB_5 + "\r\n--" + BOUNDARY + "--").getBytes();
public void testIterationMultipart() throws Exception {
GetObjectIterator<SingleObjectResponse> getObjectIterator = null;
Map headers = new HashMap();
headers.put("Content-Type", "multipart/parallel; boundary=\"" + BOUNDARY + "\"");
headers.put("MIME-Version", "1.0");
GetObjectResponse getObjectResponse = new GetObjectResponse(headers, new ByteArrayInputStream(MULTIPART_RESPONSE_BODY));
getObjectIterator = getObjectResponse.iterator();
SingleObjectResponse firstResponse = getObjectIterator.next();
assertEquals("text", firstResponse.getType());
assertEquals("one", firstResponse.getContentID());
assertEquals("1", firstResponse.getObjectID());
assertEquals(BINARY_BLOB_1, new String(readOut(firstResponse.getInputStream(), 1024)));
assertTrue(getObjectIterator.hasNext());
assertTrue(getObjectIterator.hasNext());
SingleObjectResponse secondResponse = getObjectIterator.next();
assertEquals("gray-matter", secondResponse.getType());
assertEquals("two", secondResponse.getContentID());
assertEquals("2", secondResponse.getObjectID());
assertEquals(BINARY_BLOB_2, new String(readOut(secondResponse.getInputStream(), 1024)));
getObjectIterator.next();
getObjectIterator.next();
getObjectIterator.next();
assertFalse(getObjectIterator.hasNext());
assertFalse(getObjectIterator.hasNext());
}
public void testIterationNonMultipart() throws Exception {
GetObjectIterator<SingleObjectResponse> getObjectIterator = null;
Map headers = new HashMap();
headers.put("Content-Type", "image/jpeg");
headers.put("MIME-Version", "1.0");
headers.put("Content-ID", "one");
headers.put("Object-ID", "1");
GetObjectResponse getObjectResponse = new GetObjectResponse(headers, new ByteArrayInputStream(BINARY_BLOB_1
.getBytes()));
getObjectIterator = getObjectResponse.iterator();
assertTrue(getObjectIterator.hasNext());
assertTrue(getObjectIterator.hasNext());
SingleObjectResponse firstResponse = getObjectIterator.next();
assertEquals("image/jpeg", firstResponse.getType());
assertEquals("one", firstResponse.getContentID());
assertEquals("1", firstResponse.getObjectID());
assertEquals(BINARY_BLOB_1, new String(readOut(firstResponse.getInputStream(), 1024)));
assertFalse(getObjectIterator.hasNext());
assertFalse(getObjectIterator.hasNext());
}
/*
* TODO: Fix these tests.
*
public void testMissingObjects() throws Exception {
Map headers = new HashMap();
String BUG_BOUNDARY = "50eb24a2.9354.35f3.be11.9cea9411a260";
headers.put("Content-Type", "mutipart/parallel; boundary=\"" + BUG_BOUNDARY + "\"");
headers.put("MIME-Version", "1.0");
InputStream BUG_MULTIPART_RESPONSE_BODY = this.getClass().getResourceAsStream("objects-missing.multipart");
GetObjectResponse getObjectResponse = new GetObjectResponse(headers, BUG_MULTIPART_RESPONSE_BODY);
GetObjectIterator<SingleObjectResponse> bugObjectIterator = GetObjectResponseIterator.createIterator(getObjectResponse, 10000);
String[] expectedContentIds = new String[] { "111285", "10037", "100084", "13710", "58946", };
for (int i = 0; bugObjectIterator.hasNext(); i++) {
SingleObjectResponse objectResponse = bugObjectIterator.next();
String contentID = objectResponse.getContentID();
assertEquals(expectedContentIds[i], contentID);
}
}
public void testParsingObjects() throws Exception {
Map headers = new HashMap();
String BUG_BOUNDARY = "simple boundary";
headers.put("Content-Type", "mutipart/parallel; boundary=\"" + BUG_BOUNDARY + "\"");
headers.put("MIME-Version", "1.0");
InputStream BUG_MULTIPART_RESPONSE_BODY = this.getClass().getResourceAsStream("2237858_0.jpg");
GetObjectResponse getObjectResponse = new GetObjectResponse(headers, BUG_MULTIPART_RESPONSE_BODY);
GetObjectIterator<SingleObjectResponse> bugObjectIterator = GetObjectResponseIterator.createIterator(getObjectResponse, 10000);
String[] expectedContentIds = new String[] { "2237858", "2237858", "2237858", "2237858", "2236185", "2236185",
"2236185", "2236185", "2236210", "2236210", "2236210", "2236210", "2236210" };
String[] expectedObjectIds = new String[] { "1", "2", "3", "4", "0", "1", "2", "3", "0", "1", "2", "3", "4", };
int i = 0;
for (; bugObjectIterator.hasNext(); i++) {
SingleObjectResponse objectResponse = bugObjectIterator.next();
String contentID = objectResponse.getContentID();
assertEquals(expectedContentIds[i], contentID);
String objectID = objectResponse.getObjectID();
assertEquals(expectedObjectIds[i], objectID);
File tmp = File.createTempFile("embedded-image.", "." + contentID + "_" + objectID + ".jpg");
byte[] image = GetObjectResponseIteratorTest.readOut(objectResponse.getInputStream(), 10000);
FileOutputStream imageOut = new FileOutputStream(tmp);
try {
imageOut.write(image);
} finally {
imageOut.close();
}
System.out.println("embedded image extracted to: " + tmp);
}
assertEquals("Objects were swallowed.", expectedContentIds.length, i);
}
*/
/**
* Some RETS servers send headers like "Content-type"
*/
public void testCaseInsensitiveHeaders() throws Exception {
GetObjectIterator<SingleObjectResponse> getObjectIterator = null;
Map headers = new HashMap();
headers.put("Content-type", "image/jpeg");
headers.put("MIME-version", "1.0");
headers.put("content-id", "one");
headers.put("Object-id", "1");
GetObjectResponse getObjectResponse = new GetObjectResponse(headers, new ByteArrayInputStream(BINARY_BLOB_1.getBytes()));
getObjectIterator = getObjectResponse.iterator();
assertTrue(getObjectIterator.hasNext());
SingleObjectResponse firstResponse = getObjectIterator.next();
assertEquals("image/jpeg", firstResponse.getType());
assertEquals("one", firstResponse.getContentID());
assertEquals("1", firstResponse.getObjectID());
assertEquals(BINARY_BLOB_1, new String(readOut(firstResponse.getInputStream(), 1024)));
}
public static byte[] readOut(InputStream in, int bufferSize) throws IOException {
byte[] temp = new byte[bufferSize];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
do {
bufferSize = in.read(temp, 0, bufferSize);
if (bufferSize > 0)
baos.write(temp, 0, bufferSize);
} while (bufferSize != -1);
return baos.toByteArray();
}
}

View File

@ -1,35 +0,0 @@
package com.ossez.usreio.tests.client;
import java.io.FilterReader;
import java.io.IOException;
import java.io.Reader;
public class IOFailReader extends FilterReader {
protected IOFailReader(Reader reader) {
super(reader);
}
public void setFailRead(boolean failRead) {
this.mFailRead = failRead;
}
@Override
public int read() throws IOException {
checkFailRead();
return super.read();
}
@Override
public int read(char[] cbuf, int off, int len) throws IOException {
checkFailRead();
return super.read(cbuf, off, len);
}
private void checkFailRead() throws IOException {
if (this.mFailRead)
throw new IOException("Simulated IOException");
}
private boolean mFailRead;
}

View File

@ -1,24 +0,0 @@
package com.ossez.usreio.tests.client;
import com.ossez.usreio.client.LoginRequest;
public class LoginRequestTest extends RetsTestCase {
public void testGetUrl() {
LoginRequest req = new LoginRequest();
req.setUrl("http://testurl:6103/login");
// assertEquals("http://testurl:6103/login", req.getUrl());
}
public void testSetBrokerCode() {
LoginRequest req = new LoginRequest();
req.setUrl("http://testurl:6103/login");
req.setBrokerCode(null, "branch");
// assertEquals("http://testurl:6103/login", req.getUrl());
req.setBrokerCode("broker", null);
// query parameters are separate now because of get/post
// assertEquals("http://testurl:6103/login", req.getUrl());
// assertEquals("BrokerCode=broker", req.getHttpParameters());
req.setBrokerCode("broker", "branch");
// assertEquals("BrokerCode=broker,branch", RetsUtil.urlDecode(req.getHttpParameters()));
}
}

View File

@ -1,133 +0,0 @@
package com.ossez.usreio.tests.client;
import com.ossez.usreio.client.CapabilityUrls;
import com.ossez.usreio.client.LoginResponse;
import com.ossez.usreio.client.RetsException;
import com.ossez.usreio.common.rets.RetsVersion;
import org.junit.Test;
public class LoginResponseTest extends RetsTestCase {
/**
* @throws RetsException
*/
@Test
public void testValidLoginResponse17() throws RetsException {
LoginResponse response = new LoginResponse();
// response.parse(getResource("login_response_valid_1.7.xml"), RetsVersion.RETS_17);
// assertEquals("Checking broker", "4935,4935", response.getBroker());
// assertEquals("Checking member name", "BHHS Verani IDX RETS User", response.getMemberName());
// assertEquals("Checking metadata version", "19.9.17332", response.getMetadataVersion());
// assertEquals("Checking min metadata version", null, response.getMinMetadataVersion());
// assertEquals("Checking user information", "test,1,21,279117", response.getUserInformation());
//// assertNull("Checking office list", response.getOfficeList());
// assertEquals("Checking balance", null, response.getBalance());
// assertEquals("Checking timeout", 7200, response.getSessionTimeout());
//// assertNull("Checking password expiration", response.getPasswordExpiration());
CapabilityUrls urls = response.getCapabilityUrls();
// assertEquals(null, urls.getActionUrl());
// assertEquals(null, urls.getChangePasswordUrl());
// assertEquals("http://neren.rets.paragonrels.com/rets/fnisrets.aspx/NEREN/getobject", urls.getGetObjectUrl());
// assertEquals("http://neren.rets.paragonrels.com/rets/fnisrets.aspx/NEREN/login", urls.getLoginUrl());
// assertNull(urls.getLoginCompleteUrl());
// assertEquals("http://neren.rets.paragonrels.com/rets/fnisrets.aspx/NEREN/logout", urls.getLogoutUrl());
// assertEquals("http://neren.rets.paragonrels.com/rets/fnisrets.aspx/NEREN/search", urls.getSearchUrl());
// assertEquals("http://neren.rets.paragonrels.com/rets/fnisrets.aspx/NEREN/getmetadata", urls.getGetMetadataUrl());
// assertNull(urls.getUpdateUrl());
}
/**
* @throws RetsException
*/
public void testValidLoginResponse15() throws RetsException {
LoginResponse response = new LoginResponse();
// response.parse(getResource("login_response_valid_1.5.xml"), RetsVersion.RETS_15);
// assertEquals("Checking broker", "B123, BO987", response.getBroker());
// assertEquals("Checking member name", "Joe T. Schmoe", response.getMemberName());
// assertEquals("Checking metadata version", "1.00.000", response.getMetadataVersion());
// assertEquals("Checking min metadata version", "1.00.000", response.getMinMetadataVersion());
// assertEquals("Checking user information", "A123,5678,1,A123", response.getUserInformation());
// assertNull("Checking office list", response.getOfficeList());
// assertEquals("Checking balance", "44.21", response.getBalance());
// assertEquals("Checking timeout", 60, response.getSessionTimeout());
// assertNull("Checking password expiration", response.getPasswordExpiration());
//
// CapabilityUrls urls = response.getCapabilityUrls();
// assertEquals("http://rets.test:6103/get", urls.getActionUrl());
// assertEquals("http://rets.test:6103/changePassword", urls.getChangePasswordUrl());
// assertEquals("http://rets.test:6103/getObjectEx", urls.getGetObjectUrl());
// assertEquals("http://rets.test:6103/login", urls.getLoginUrl());
// assertNull(urls.getLoginCompleteUrl());
// assertEquals("http://rets.test:6103/logout", urls.getLogoutUrl());
// assertEquals("http://rets.test:6103/search", urls.getSearchUrl());
// assertEquals("http://rets.test:6103/getMetadata", urls.getGetMetadataUrl());
// assertNull(urls.getUpdateUrl());
}
/**
* @throws RetsException
*/
public void testValidLoginResponse10() throws RetsException {
LoginResponse response = new LoginResponse();
// response.parse(getResource("login_response_valid_1.0.xml"), RetsVersion.RETS_10);
// assertEquals("Checking broker", "B123, BO987", response.getBroker());
// assertEquals("Checking member name", "Joe T. Schmoe", response.getMemberName());
// assertEquals("Checking metadata version", "1.00.000", response.getMetadataVersion());
// assertEquals("Checking min metadata version", "1.00.000", response.getMinMetadataVersion());
// assertEquals("Checking user information", "A123,5678,1,A123", response.getUserInformation());
// assertNull("Checking office list", response.getOfficeList());
// assertEquals("Checking balance", "44.21", response.getBalance());
// assertEquals("Checking timeout", 60, response.getSessionTimeout());
// assertNull("Checking password expiration", response.getPasswordExpiration());
//
// CapabilityUrls urls = response.getCapabilityUrls();
// assertEquals("http://rets.test:6103/get", urls.getActionUrl());
// assertEquals("http://rets.test:6103/changePassword", urls.getChangePasswordUrl());
// assertEquals("http://rets.test:6103/getObjectEx", urls.getGetObjectUrl());
// assertEquals("http://rets.test:6103/login", urls.getLoginUrl());
// assertNull(urls.getLoginCompleteUrl());
// assertEquals("http://rets.test:6103/logout", urls.getLogoutUrl());
// assertEquals("http://rets.test:6103/search", urls.getSearchUrl());
// assertEquals("http://rets.test:6103/getMetadata", urls.getGetMetadataUrl());
// assertNull(urls.getUpdateUrl());
}
public void testLowerCaseKeys() throws RetsException {
LoginResponse response = new LoginResponse();
// response.parse(getResource("login_lower_case.xml"), RetsVersion.RETS_15);
// assertEquals("Checking broker", "B123, BO987", response.getBroker());
// assertEquals("Checking member name", "Joe T. Schmoe", response.getMemberName());
// assertEquals("Checking metadata version", "1.00.000", response.getMetadataVersion());
// assertEquals("Checking min metadata version", "1.00.000", response.getMinMetadataVersion());
// assertEquals("Checking user information", "A123,5678,1,A123", response.getUserInformation());
// assertNull("Checking office list", response.getOfficeList());
// assertEquals("Checking balance", "44.21", response.getBalance());
// assertEquals("Checking timeout", 60, response.getSessionTimeout());
// assertNull("Checking password expiration", response.getPasswordExpiration());
//
// CapabilityUrls urls = response.getCapabilityUrls();
// assertEquals("http://rets.test:6103/get", urls.getActionUrl());
// assertEquals("http://rets.test:6103/changePassword", urls.getChangePasswordUrl());
// assertEquals("http://rets.test:6103/getObjectEx", urls.getGetObjectUrl());
// assertEquals("http://rets.test:6103/login", urls.getLoginUrl());
// assertNull(urls.getLoginCompleteUrl());
// assertEquals("http://rets.test:6103/logout", urls.getLogoutUrl());
// assertEquals("http://rets.test:6103/search", urls.getSearchUrl());
// assertEquals("http://rets.test:6103/getMetadata", urls.getGetMetadataUrl());
// assertNull(urls.getUpdateUrl());
}
public void testStrictLowerCaseKeys() {
LoginResponse response = new LoginResponse();
response.setStrict(true);
try {
response.parse(getResource("login_lower_case.xml"), RetsVersion.RETS_15);
} catch (RetsException e) {
// Expected
// fail("Should throw exception");
}
}
}

View File

@ -1,57 +0,0 @@
package com.ossez.usreio.tests.client;
import com.ossez.usreio.client.LogoutResponse;
import com.ossez.usreio.client.RetsException;
import com.ossez.usreio.common.rets.RetsVersion;
public class LogoutResponseTest extends RetsTestCase {
/*
* TODO: FIX THESE
*
public void testValidLogoutResponse10() throws RetsException {
LogoutResponse response = new LogoutResponse();
response.parse(getResource("logout_valid10.xml"), RetsVersion.RETS_10);
assertEquals("1000", response.getSeconds());
assertEquals("$20.00", response.getBillingInfo());
assertEquals("Good Bye", response.getLogoutMessage());
}
public void testValidLogoutResponse() throws RetsException {
LogoutResponse response = new LogoutResponse();
response.parse(getResource("logout_valid15.xml"), RetsVersion.RETS_15);
assertEquals("1000", response.getSeconds());
assertEquals("$20.00", response.getBillingInfo());
assertEquals("Good Bye", response.getLogoutMessage());
}
public void testLowerCaseKeys() throws RetsException {
LogoutResponse response = new LogoutResponse();
response.parse(getResource("logout_lower_case.xml"), RetsVersion.RETS_15);
assertEquals("1000", response.getSeconds());
assertEquals("$20.00", response.getBillingInfo());
assertEquals("Good Bye", response.getLogoutMessage());
}
*/
public void testStrictLowerCaseKeys() {
try {
LogoutResponse response = new LogoutResponse();
response.setStrict(true);
response.parse(getResource("logout_lower_case.xml"), RetsVersion.RETS_15);
} catch (RetsException e) {
// Expected
// fail("Should have thrown exception");
}
}
/*
* TODO: FIX THIS.
*
public void testLogoutNoEquals() throws RetsException {
LogoutResponse response = new LogoutResponse();
response.parse(getResource("logout_no_equals.xml"), RetsVersion.RETS_15);
assertNull(response.getSeconds());
assertNull(response.getBillingInfo());
assertNull(response.getLogoutMessage());
}
*/
}

View File

@ -1,122 +0,0 @@
package com.ossez.usreio.tests.client;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import com.ossez.usreio.client.CommonsHttpClient;
import com.ossez.usreio.client.GetObjectRequest;
import com.ossez.usreio.client.RetsException;
import com.ossez.usreio.client.RetsHttpClient;
import com.ossez.usreio.client.RetsSession;
import com.ossez.usreio.common.rets.RetsVersion;
import com.ossez.usreio.client.SingleObjectResponse;
/**
* Simple Example performing a GetObject and iterating the results
*
*/
public class RetsGetObjectExample {
public static void main(String[] args) throws MalformedURLException {
//Create a RetsHttpClient (other constructors provide configuration i.e. timeout, gzip capability)
RetsHttpClient httpClient = new CommonsHttpClient();
RetsVersion retsVersion = RetsVersion.RETS_1_7_2;
String loginUrl = "http://theurloftheretsserver.com";
//Create a RetesSession with RetsHttpClient
RetsSession session = new RetsSession(loginUrl, httpClient, retsVersion);
String username = "username";
String password = "password";
try {
//Login
session.login(username, password);
} catch (RetsException e) {
e.printStackTrace();
}
String sResource = "Property";
String objType = "Photo";
String seqNum = "*"; // * denotes get all pictures associated with id (from Rets Spec)
List<String> idsList = Arrays.asList("331988","152305","243374");
try {
//Create a GetObjectRequeset
GetObjectRequest req = new GetObjectRequest(sResource, objType);
//Add the list of ids to request on (ids can be determined from records)
Iterator<String> idsIter = idsList.iterator();
while(idsIter.hasNext()) {
req.addObject(idsIter.next(), seqNum);
}
//Execute the retrieval of objects
Iterator<SingleObjectResponse> singleObjectResponseIter = session.getObject(req).iterator();
//Iterate over each Object
while (singleObjectResponseIter.hasNext()) {
SingleObjectResponse sor = (SingleObjectResponse)singleObjectResponseIter.next();
//Retrieve in info and print
String type = sor.getType();
String contentID = sor.getContentID();
String objectID = sor.getObjectID();
String description = sor.getDescription();
String location = sor.getLocation();
InputStream is = sor.getInputStream();
System.out.print("type:" + type);
System.out.print(" ,contentID:" + contentID);
System.out.print(" ,objectID:" + objectID);
System.out.println(" ,description:" + description);
System.out.println("location:" + location);
//Download object
try {
String dest = "/path/of/dowload/loaction";
int size = is.available();
String filename = dest + contentID +"-" + objectID + "." + type;
OutputStream out = new FileOutputStream(new File(filename));
int read = 0;
byte[] bytes = new byte[1024];
while ((read = is.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
is.close();
out.flush();
out.close();
System.out.println("New file with size " + size + " created: " + filename);
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
} catch (RetsException e) {
e.printStackTrace();
}
finally {
if(session != null) {
try {
session.logout();
}
catch (RetsException e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -1,94 +0,0 @@
package com.ossez.usreio.tests.client;
import java.net.MalformedURLException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import com.ossez.usreio.client.CommonsHttpClient;
import com.ossez.usreio.client.GetObjectRequest;
import com.ossez.usreio.client.RetsException;
import com.ossez.usreio.client.RetsHttpClient;
import com.ossez.usreio.client.RetsSession;
import com.ossez.usreio.common.rets.RetsVersion;
import com.ossez.usreio.client.SingleObjectResponse;
/**
* Simple Example performing a GetObject and iterating the results
*
*/
public class RetsGetObjectURLExample {
public static void main(String[] args) throws MalformedURLException {
//Create a RetsHttpClient (other constructors provide configuration i.e. timeout, gzip capability)
RetsHttpClient httpClient = new CommonsHttpClient();
RetsVersion retsVersion = RetsVersion.RETS_1_7_2;
String loginUrl = "http://theurloftheretsserver.com";
//Create a RetesSession with RetsHttpClient
RetsSession session = new RetsSession(loginUrl, httpClient, retsVersion);
String username = "username";
String password = "password";
try {
//Login
session.login(username, password);
} catch (RetsException e) {
e.printStackTrace();
}
String sResource = "Property";
String objType = "Photo";
String seqNum = "*"; // * denotes get all pictures associated with id (from Rets Spec)
boolean locationOnly = true; //InputStream not included in response for faster transmission
List<String> idsList = Arrays.asList("331988","152305","243374");
try {
//Create a GetObjectRequeset
GetObjectRequest req = new GetObjectRequest(sResource, objType);
req.setLocationOnly(locationOnly);
//Add the list of ids to request on (ids can be determined from records)
Iterator<String> idsIter = idsList.iterator();
while(idsIter.hasNext()) {
req.addObject(idsIter.next(), seqNum);
}
//Execute the retrieval of objects
Iterator<SingleObjectResponse> singleObjectResponseIter = session.getObject(req).iterator();
//Iterate over each Object
while (singleObjectResponseIter.hasNext()) {
SingleObjectResponse sor = (SingleObjectResponse)singleObjectResponseIter.next();
//Retrieve in info and print
String type = sor.getType();
String contentID = sor.getContentID();
String objectID = sor.getObjectID();
String description = sor.getDescription();
String location = sor.getLocation();
System.out.print("type:" + type);
System.out.print(" ,contentID:" + contentID);
System.out.print(" ,objectID:" + objectID);
System.out.println(" ,description:" + description);
System.out.println("location:" + location); //location holds the URL string
}
} catch (RetsException e) {
e.printStackTrace();
}
finally {
if(session != null) {
try {
session.logout();
}
catch (RetsException e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -1,84 +0,0 @@
package com.ossez.usreio.tests.client;
import java.net.MalformedURLException;
import org.apache.commons.lang3.StringUtils;
import com.ossez.usreio.client.CommonsHttpClient;
import com.ossez.usreio.client.RetsException;
import com.ossez.usreio.client.RetsHttpClient;
import com.ossez.usreio.client.RetsSession;
import com.ossez.usreio.common.rets.RetsVersion;
import com.ossez.usreio.client.SearchRequest;
import com.ossez.usreio.client.SearchResultImpl;
/**
* Simple Example performing a search and iterating over the results
*
*/
public class RetsSearchExample {
public static void main(String[] args) throws MalformedURLException {
//Create a RetsHttpClient (other constructors provide configuration i.e. timeout, gzip capability)
RetsHttpClient httpClient = new CommonsHttpClient();
RetsVersion retsVersion = RetsVersion.RETS_1_7_2;
String loginUrl = "http://neren.rets.paragonrels.com/rets/fnisrets.aspx/NEREN/login";
//Create a RetesSession with RetsHttpClient
RetsSession session = new RetsSession(loginUrl, httpClient, retsVersion);
String username = "prurets1";
String password = "boyd070110";
//Set method as GET or POST
session.setMethod("POST");
try {
//Login
session.login(username, password);
} catch (RetsException e) {
e.printStackTrace();
}
String sQuery = "(Member_num=.ANY.)";
String sResource = "Property";
String sClass = "Residential";
//Create a SearchRequest
SearchRequest request = new SearchRequest(sResource, sClass, sQuery);
//Select only available fields
String select ="field1,field2,field3,field4,field5";
request.setSelect(select);
//Set request to retrive count if desired
request.setCountFirst();
SearchResultImpl response;
try {
//Execute the search
response= (SearchResultImpl) session.search(request);
//Print out count and columns
int count = response.getCount();
System.out.println("COUNT: " + count);
System.out.println("COLUMNS: " + StringUtils.join(response.getColumns(), "\t"));
//Iterate over, print records
for (int row = 0; row < response.getRowCount(); row++){
System.out.println("ROW"+ row +": " + StringUtils.join(response.getRow(row), "\t"));
}
} catch (RetsException e) {
e.printStackTrace();
}
finally {
if(session != null) {
try {
session.logout();
}
catch(RetsException e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -1,69 +0,0 @@
package com.ossez.usreio.tests.client;
import com.ossez.usreio.client.RetsException;
import com.ossez.usreio.client.RetsSession;
import com.ossez.usreio.common.rets.RetsVersion;
import com.ossez.usreio.util.SessionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test for RETS session
*
* @author YuCheng Hu
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class RetsSessionTest extends RetsTestCase {
private final Logger logger = LoggerFactory.getLogger(RetsSessionTest.class);
/**
* Test Login should return SessionID from server
*/
@Test
public void testLogin() {
logger.debug("Test Rets Session Login by URL: [{}]", retsLoginUrl);
try {
RetsSession session = SessionUtils.retsLogin(retsConfigurator);
assertNotNull(session.getSessionId());
} catch (RetsException ex) {
logger.debug("Session Login Error", ex);
}
}
/**
* TEST Logout
*/
@Test
public void testLogout() {
logger.debug("RETS Session Login URL: [{}]", retsLoginUrl);
RetsSession session = null;
try {
session = SessionUtils.retsLogin(retsLoginUrl, retsUsername, retsPassword, RetsVersion.RETS_1_7_2);
assertNotNull(session.getSessionId());
} catch (RetsException ex) {
logger.debug("Session Login Error", ex);
}
// If Session is not Empty then Logout
if (ObjectUtils.isNotEmpty(session)) {
try {
session.logout();
} catch (RetsException e) {
logger.error("Logout Error: ", e);
}
}
}
}

View File

@ -1,90 +0,0 @@
package com.ossez.usreio.tests.client;
import com.ossez.usreio.common.rets.RetsConfigurator;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Properties;
/**
* @author YuCheng Hu
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class RetsTestCase {
public Properties props = new Properties();
public RetsConfigurator retsConfigurator = new RetsConfigurator();
public String retsLoginUrl;
public String retsUsername;
public String retsPassword;
@BeforeAll
public void setUp() throws IOException {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
props.load(loader.getResourceAsStream("rets.properties"));
retsConfigurator.setServerUrl(props.getProperty("rets_server"));
retsConfigurator.setServerUsername(props.getProperty("rets_username"));
retsConfigurator.setServerPassword(props.getProperty("rets_password"));
}
/**
* Get Resource from file
*
* @param name
* @return
*/
protected static InputStream getResource(String name) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
return cl.getResourceAsStream(name);
}
/**
* @param urlStr
* @return
*/
protected static InputStream getResourceFromURL(String urlStr) {
try {
// in = new URL( "" ).openStream();
URL oracle = new URL("https://cdn.ossez.com/reso/rets-1x/login/login_response_valid_1.0.xml");
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
return null
;
}
public void assertEquals(String message, Object[] expected, Object[] actual) {
boolean success;
if (expected.length == actual.length) {
success = true;
for (int i = 0; i < expected.length; i++) {
success = true;
if (!expected[i].equals(actual[i])) {
success = false;
break;
}
}
} else {
success = false;
}
}
}

View File

@ -1,31 +0,0 @@
package com.ossez.usreio.tests.client;
public class RetsVersionTest extends RetsTestCase {
@SuppressWarnings("deprecation")
public void testEquals() {
// assertEquals("Checking 1.0", RetsVersion.RETS_10, new RetsVersion(1, 0));
//
// assertEquals("Checking 1.5", RetsVersion.RETS_15, new RetsVersion(1, 5));
//
// assertEquals("Checking 1.7", RetsVersion.RETS_17, new RetsVersion(1, 7));
//
// assertEquals("Checking 1.7.2", RetsVersion.RETS_1_7_2, new RetsVersion(1, 7, 2, 0));
//
// assertEquals("Checking revision support", RetsVersion.RETS_1_7_2, new RetsVersion(1, 7, 2, 0));
//
// assertFalse("Checking draft support", RetsVersion.RETS_15.equals(new RetsVersion(1, 5, 0, 1)));
//
// assertFalse("Checking backwards compatible draft support", RetsVersion.RETS_15.equals(new RetsVersion(1, 5, 1)));
}
@SuppressWarnings("deprecation")
public void testToString() {
// assertEquals("Checking toString() 1.0", "RETS/1.0", RetsVersion.RETS_10.toString());
// assertEquals("Checking toString() 1.5", "RETS/1.5", RetsVersion.RETS_15.toString());
// assertEquals("Checking toString() 1.7", "RETS/1.7", RetsVersion.RETS_17.toString());
// assertEquals("Checking toString() 1.7.2", "RETS/1.7.2", RetsVersion.RETS_1_7_2.toString());
// assertEquals("Checking toString() backward compatible draft without revision", "RETS/1.5d1", new RetsVersion(1, 5, 1).toString());
// assertEquals("Checking toString() revision with draft", "RETS/1.7.2d1", new RetsVersion(1, 7, 2, 1).toString());
}
}

View File

@ -1,153 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.client;
import java.io.StringReader;
import com.ossez.usreio.client.*;
import org.xml.sax.InputSource;
/**
* TODO refactor this and the StreamingSearchResultsProcessorTest.
*
* dbt is lame and hasn't overridden the default
* javadoc string.
*/
public class SearchResultHandlerTest extends RetsTestCase {
SearchResult runSearchTest(String input) throws RetsException {
return runSearchTest(input, InvalidReplyCodeHandler.FAIL);
}
SearchResult runSearchTest(String input, InvalidReplyCodeHandler invalidReplyCodeHandler) throws RetsException {
SearchResultImpl res = new SearchResultImpl();
SearchResultHandler h = new SearchResultHandler(res, invalidReplyCodeHandler, CompactRowPolicy.DEFAULT);
InputSource source = new InputSource(new StringReader(input));
h.parse(source);
return res;
}
public void testSmallResult() throws RetsException {
// SearchResult result = runSearchTest(GOOD_SMALL_TEST);
// assertTrue("search not complete", result.isComplete());
// String[] columns = result.getColumns();
// assertNotNull(columns);
// assertEquals("column headers count wrong", 1, columns.length);
// assertEquals("bad column header", "Column1", columns[0]);
// assertEquals("wrong row count", 1, result.getCount());
// String[] row = result.getRow(0);
// assertEquals("wrong row width", 1, row.length);
// assertEquals("wrong row data", "Data1", row[0]);
// assertFalse("max rows wrong", result.isMaxrows());
}
public void testAllTags() throws RetsException {
// SearchResult result = runSearchTest(ALL_TAGS_TEST);
// assertTrue("search not complete", result.isComplete());
// assertEquals("extended count wrong", 100, result.getCount());
// assertTrue("max rows not set", result.isMaxrows());
// String[] row = result.getRow(0);
// assertNotNull("row 0 is null", row);
// assertEquals("wrong number of row[0] elements", 1, row.length);
// assertEquals("wrong row[0] data", "Data1", row[0]);
// row = result.getRow(1);
// assertNotNull("row 1 is null", row);
// assertEquals("wrong number of row[1] elements", 1, row.length);
// assertEquals("wrong row[1] data", "Data2", row[0]);
}
public void testReplyCode20208() throws RetsException {
// SearchResult result = runSearchTest(MAXROWS_REPLYCODE);
// assertTrue("search not complete", result.isComplete());
// assertEquals("extended count wrong", 100, result.getCount());
// assertTrue("max rows not set", result.isMaxrows());
// String[] row = result.getRow(0);
// assertNotNull("row 0 is null", row);
// assertEquals("wrong number of row[0] elements", 1, row.length);
// assertEquals("wrong row[0] data", "Data1", row[0]);
// row = result.getRow(1);
// assertNotNull("row 1 is null", row);
// assertEquals("wrong number of row[1] elements", 1, row.length);
// assertEquals("wrong row[1] data", "Data2", row[0]);
}
public void testReplyCode20201WithColumns() throws RetsException {
SearchResult result = runSearchTest(EMPTY_REPLYCODE_WITH_COLUMNS_TAG);
// assertFalse("iterator should be empty", result.iterator().hasNext());
}
public void testReplyCode20201WithoutColumns() throws RetsException {
SearchResult result = runSearchTest(EMPTY_REPLYCODE);
// assertFalse("iterator should be empty", result.iterator().hasNext());
}
public void testEarlyException() throws RetsException {
try {
runSearchTest(EARLY_ERROR_TEST);
// fail("Expected an InvalidReplyCodeException");
} catch (InvalidReplyCodeException e) {
// "success"
}
}
public void testLateException() throws RetsException {
try {
runSearchTest(LATE_ERROR_TEST);
// fail("Expected an Invalid ReplyCodeException");
} catch (InvalidReplyCodeException e) {
// "success"
}
}
public void testEarlyExceptionWithTrap() throws RetsException {
try {
runSearchTest(EARLY_ERROR_TEST, new TestInvalidReplyCodeHandler());
// fail("Expected an InvalidReplyCodeException");
} catch (InvalidReplyCodeException e) {
// "success"
}
}
public void testLateExceptionWithTrap() throws RetsException {
TestInvalidReplyCodeHandler testInvalidReplyCodeHandler = new TestInvalidReplyCodeHandler();
runSearchTest(LATE_ERROR_TEST, testInvalidReplyCodeHandler);
// assertEquals(LATE_ERROR_CODE, testInvalidReplyCodeHandler.getReplyCode());
}
public static final String CRLF = "\r\n";
public static final String GOOD_SMALL_TEST = "<RETS ReplyCode=\"0\" " + "ReplyText=\"Success\">" + CRLF
+ "<DELIMITER value=\"09\"/>" + CRLF + "<COLUMNS>\tColumn1\t</COLUMNS>" + CRLF + "<DATA>\tData1\t</DATA>"
+ CRLF + "</RETS>" + CRLF;
public static final String ALL_TAGS_TEST = "<RETS ReplyCode=\"0\" " + "ReplyText=\"Success\">" + CRLF
+ "<COUNT Records=\"100\"/>" + CRLF + "<DELIMITER value=\"09\"/>" + CRLF + "<COLUMNS>\tColumn1\t</COLUMNS>"
+ CRLF + "<DATA>\tData1\t</DATA>" + CRLF + "<DATA>\tData2\t</DATA>" + CRLF + "<MAXROWS/>" + "</RETS>"
+ CRLF;
public static final String EARLY_ERROR_TEST = "<RETS ReplyCode=\"20203\" " + "ReplyText=\"Misc search Error\">"
+ CRLF + "</RETS>" + CRLF;
public static final int LATE_ERROR_CODE = 20203;
public static final String LATE_ERROR_TEST = "<RETS ReplyCode=\"0\" " + "ReplyText=\"Success\">" + CRLF
+ "<COUNT Records=\"100\"/>" + CRLF + "<DELIMITER value=\"09\"/>" + CRLF + "<COLUMNS>\tColumn1\t</COLUMNS>"
+ CRLF + "<DATA>\tData1\t</DATA>" + CRLF + "<DATA>\tData2\t</DATA>" + CRLF + "<RETS-STATUS ReplyCode=\""
+ LATE_ERROR_CODE + "\" ReplyText=\"Misc Error\"/>" + "</RETS>" + CRLF;
public static final String MAXROWS_REPLYCODE = "<RETS ReplyCode=\"20208\" " + "ReplyText=\"Success\">" + CRLF
+ "<COUNT Records=\"100\"/>" + CRLF + "<DELIMITER value=\"09\"/>" + CRLF + "<COLUMNS>\tColumn1\t</COLUMNS>"
+ CRLF + "<DATA>\tData1\t</DATA>" + CRLF + "<DATA>\tData2\t</DATA>" + CRLF + "<MAXROWS/>" + "</RETS>"
+ CRLF;
public static final String EMPTY_REPLYCODE = "<RETS ReplyCode=\"20201\" " + "ReplyText=\"No Records Found\">"
+ CRLF + "</RETS>" + CRLF;
public static final String EMPTY_REPLYCODE_WITH_COLUMNS_TAG = "<RETS ReplyCode=\"20201\" "
+ "ReplyText=\"No Records Found\">" + CRLF + "<DELIMITER value=\"09\"/>" + CRLF
+ "<COLUMNS>\tColumn1\t</COLUMNS>" + CRLF + "</RETS>" + CRLF;
}

View File

@ -1,58 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.client;
import com.ossez.usreio.client.SearchResultImpl;
import java.util.NoSuchElementException;
/**
* dbt is lame and hasn't overridden the default
* javadoc string.
*/
public class SearchResultImplTest extends RetsTestCase {
public void testSearchResult() {
String[] cols = { "Column1", "Column2" };
String[] row1 = { "Data1x1", "Data1x2" };
String[] row2 = { "Data2x1", "Data2x2" };
String[] row2alt = { "", "" };
row2alt[0] = row2[0];
row2alt[1] = row2[1];
SearchResultImpl result = new SearchResultImpl();
result.setCount(5);
result.setColumns(cols);
result.addRow(row1);
result.addRow(row2);
result.setMaxrows();
result.setComplete();
// assertEquals("setCount wrong", result.getCount(), 5);
// assertTrue("isComplete not set", result.isComplete());
// assertTrue("isMaxrows not set", result.isMaxrows());
// assertEquals("columns mangled", cols, result.getColumns());
// assertEquals("row 1 mangled", row1, result.getRow(0));
// assertEquals("row 2 mangled", row2alt, result.getRow(1));
try {
result.getRow(2);
// fail("getting invalid row 2 should have thrown " + "NoSuchElementException");
} catch (NoSuchElementException e) {
// "success"
}
}
public void testMinimumSearchResult() {
String[] cols = { "col1" };
String[] row = { "row1" };
SearchResultImpl result = new SearchResultImpl();
result.setColumns(cols);
result.addRow(row);
result.setComplete();
// assertEquals("row count wrong", 1, result.getCount());
// assertTrue("isComplete wrong", result.isComplete());
// assertFalse("isMaxrows wrong", result.isMaxrows());
}
}

View File

@ -1,37 +0,0 @@
package com.ossez.usreio.tests.client;
import java.util.HashMap;
import java.util.Map;
import com.ossez.usreio.client.SingleObjectResponse;
import junit.framework.TestCase;
public class SingleObjectResponseTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
public void testCaseInsensitiveHeaders() throws Exception {
Map headers = new HashMap();
headers.put("Content-type", "1");
headers.put("location", "2");
headers.put("Object-Id", "3");
headers.put("content-id", "4");
headers.put("CONTENT-DESCRIPTION", "5");
SingleObjectResponse res = new SingleObjectResponse(headers, null);
assertEquals("1", res.getType());
assertEquals("2", res.getLocation());
assertEquals("3", res.getObjectID());
assertEquals("4", res.getContentID());
assertEquals("5", res.getDescription());
}
}

View File

@ -1,200 +0,0 @@
package com.ossez.usreio.tests.client;
import java.io.Reader;
import java.io.StringReader;
import com.ossez.usreio.client.*;
import junit.framework.TestCase;
public class StreamingSearchResultProcessorTest extends TestCase {
protected SearchResultProcessor createProcessor(InvalidReplyCodeHandler invalidReplyCodeHandler) {
StreamingSearchResultProcessor streamingSearchResultProcessor = new StreamingSearchResultProcessor(1, 0);
if (invalidReplyCodeHandler != null)
streamingSearchResultProcessor.setInvalidRelyCodeHandler(invalidReplyCodeHandler);
return streamingSearchResultProcessor;
}
SearchResultSet runSearchTest(String input) throws RetsException {
return runSearchTest(input, InvalidReplyCodeHandler.FAIL);
}
SearchResultSet runSearchTest(String input, InvalidReplyCodeHandler invalidReplyCodeHandler) throws RetsException {
SearchResultProcessor processor = createProcessor(invalidReplyCodeHandler);
Reader source = new StringReader(input);
return processor.parse(source);
}
public void testSmallResult() throws RetsException {
SearchResultSet result = runSearchTest(SearchResultHandlerTest.GOOD_SMALL_TEST);
String[] columns = result.getColumns();
assertNotNull(columns);
assertEquals("column headers count wrong", 1, columns.length);
assertEquals("bad column header", "Column1", columns[0]);
if (result.getCount() != -1)
assertEquals("wrong row count", 1, result.getCount());
assertTrue("iterator should have more", result.hasNext());
String[] row = result.next();
assertEquals("wrong row width", 1, row.length);
assertEquals("wrong row data", "Data1", row[0]);
assertFalse("rows should be exhausted", result.hasNext());
assertFalse("max rows wrong", result.isMaxrows());
assertTrue("search not complete", result.isComplete());
}
public void testEarlyCallToIsMaxRows() throws RetsException {
SearchResultSet result = runSearchTest(SearchResultHandlerTest.ALL_TAGS_TEST);
try {
result.isMaxrows();
fail("Should throw illegal state exception");
} catch (IllegalStateException e) {
// "success"
}
}
public void testAllTags() throws RetsException {
SearchResultSet result = runSearchTest(SearchResultHandlerTest.ALL_TAGS_TEST);
assertEquals("extended count wrong", 100, result.getCount());
assertTrue("iterator should have more", result.hasNext());
String[] row = result.next();
assertNotNull("row 0 is null", row);
assertEquals("wrong number of row[0] elements", 1, row.length);
assertEquals("wrong row[0] data", "Data1", row[0]);
assertTrue("iterator should have more", result.hasNext());
row = result.next();
assertNotNull("row 1 is null", row);
assertEquals("wrong number of row[1] elements", 1, row.length);
assertEquals("wrong row[1] data", "Data2", row[0]);
assertFalse("rows should be exhausted", result.hasNext());
assertTrue("search not complete", result.isComplete());
assertTrue("max rows not set", result.isMaxrows());
}
public void testReplyCode20208() throws RetsException {
SearchResultSet result = runSearchTest(SearchResultHandlerTest.MAXROWS_REPLYCODE);
assertEquals("extended count wrong", 100, result.getCount());
assertTrue("iterator should have more", result.hasNext());
String[] row = result.next();
assertNotNull("row 0 is null", row);
assertEquals("wrong number of row[0] elements", 1, row.length);
assertEquals("wrong row[0] data", "Data1", row[0]);
assertTrue("iterator should have more", result.hasNext());
row = result.next();
assertNotNull("row 1 is null", row);
assertEquals("wrong number of row[1] elements", 1, row.length);
assertEquals("wrong row[1] data", "Data2", row[0]);
assertFalse("rows should be exhausted", result.hasNext());
assertTrue("search not complete", result.isComplete());
assertTrue("max rows not set", result.isMaxrows());
}
public void testReplyCode20201WithColumns() throws RetsException {
SearchResultSet result = runSearchTest(SearchResultHandlerTest.EMPTY_REPLYCODE_WITH_COLUMNS_TAG);
assertFalse("iterator should be empty", result.hasNext());
}
public void testReplyCode20201WithoutColumns() throws RetsException {
SearchResultSet result = runSearchTest(SearchResultHandlerTest.EMPTY_REPLYCODE);
assertFalse("iterator should be empty", result.hasNext());
}
public void testEarlyException() throws RetsException {
try {
// Test now checks that the error is thrown at process
// or during the evaluation of the data rows, since the
// result may be lazily evaluated (streaming)
SearchResultSet result = runSearchTest(SearchResultHandlerTest.EARLY_ERROR_TEST);
while (result.hasNext())
result.next();
fail("Expected an Invalid ReplyCodeException");
} catch (InvalidReplyCodeException e) {
// "success"
}
}
public void testLateException() throws RetsException {
try {
// Test now checks that the error is thrown at process
// or during the evaluation of the data rows, since the
// result may be lazily evaluated (streaming)
SearchResultSet result = runSearchTest(SearchResultHandlerTest.LATE_ERROR_TEST);
while (result.hasNext())
result.next();
fail("Expected an Invalid ReplyCodeException");
} catch (InvalidReplyCodeException e) {
// "success"
}
}
public void testEarlyExceptionWithTrap() throws RetsException {
try {
// Test now checks that the error is thrown at process
// or during the evaluation of the data rows, since the
// result may be lazily evaluated (streaming)
SearchResultSet result = runSearchTest(SearchResultHandlerTest.EARLY_ERROR_TEST,
new TestInvalidReplyCodeHandler());
while (result.hasNext())
result.next();
fail("Expected an Invalid ReplyCodeException");
} catch (InvalidReplyCodeException e) {
// "success"
}
}
public void testLateExceptionWithTrap() throws RetsException {
// Test now checks that the error is thrown at process
// or during the evaluation of the data rows, since the
// result may be lazily evaluated (streaming)
TestInvalidReplyCodeHandler testInvalidReplyCodeHandler = new TestInvalidReplyCodeHandler();
SearchResultSet result = runSearchTest(SearchResultHandlerTest.LATE_ERROR_TEST, testInvalidReplyCodeHandler);
while (result.hasNext())
result.next();
assertEquals(SearchResultHandlerTest.LATE_ERROR_CODE, testInvalidReplyCodeHandler.getReplyCode());
}
public void testTimeout() throws Exception {
int timeout = 100;
SearchResultProcessor processor = new StreamingSearchResultProcessor(1, timeout);
Reader source = new StringReader(SearchResultHandlerTest.ALL_TAGS_TEST);
SearchResultSet result = processor.parse(source);
try {
// attempt to force timeout to occur
Thread.sleep(timeout * 10);
// hasNext should fail b/c timeout
// will have occurred
result.hasNext();
fail("Should fail since timeout should have been reached");
} catch (RetsException e) {
// success
}
}
public void testIONotEatenException() throws RetsException {
SearchResultProcessor processor = new StreamingSearchResultProcessor(100);
IOFailReader ioExceptionStream = new IOFailReader(new StringReader(SearchResultHandlerTest.ALL_TAGS_TEST));
ioExceptionStream.setFailRead(true);
SearchResultSet resultSet = processor.parse(ioExceptionStream);
try {
while (resultSet.hasNext())
resultSet.next();
fail("Expection an IOException to be thrown during stream reading.");
} catch (RetsException e) {
e.printStackTrace();
assertNotNull(e);
}
}
}

View File

@ -1,20 +0,0 @@
package com.ossez.usreio.tests.client;
import com.ossez.usreio.client.InvalidReplyCodeException;
import com.ossez.usreio.client.InvalidReplyCodeHandler;
final class TestInvalidReplyCodeHandler implements InvalidReplyCodeHandler {
private int replyCode;
public void invalidRetsReplyCode(int code) throws InvalidReplyCodeException {
throw new InvalidReplyCodeException(code);
}
public void invalidRetsStatusReplyCode(int code) throws InvalidReplyCodeException {
this.replyCode = code;
}
public int getReplyCode() {
return this.replyCode;
}
}

View File

@ -1,44 +0,0 @@
package com.ossez.usreio.tests.common.metadata;
public class MetaObjectTest extends MetadataTestCase {
public void testStrictAttributes() {
MetaObject.clearAttributeMapCache();
TestMetaObject metaObject = createTestMetaObject(MetaObject.STRICT_PARSING);
assertEquals("SomeName", metaObject.getSystemName());
assertEquals("Foo Bar", metaObject.getString1());
assertEquals("somename", metaObject.getAttributeAsString("systemname"));
assertEquals("foo bar", metaObject.getAttributeAsString("string1"));
}
public void testLooseAttributes() {
MetaObject.clearAttributeMapCache();
TestMetaObject metaObject = createTestMetaObject(MetaObject.LOOSE_PARSING);
assertEquals("somename", metaObject.getSystemName());
assertEquals("foo bar", metaObject.getString1());
}
public void testCache() {
TestMetaObject.resetAddAttributeCount();
MetaObject.clearAttributeMapCache();
createTestMetaObject(MetaObject.STRICT_PARSING);
createTestMetaObject(MetaObject.LOOSE_PARSING);
createTestMetaObject(MetaObject.STRICT_PARSING);
createTestMetaObject(MetaObject.LOOSE_PARSING);
assertEquals(2, TestMetaObject.getAddAttributeCount());
MetaObject.clearAttributeMapCache();
createTestMetaObject(MetaObject.STRICT_PARSING);
createTestMetaObject(MetaObject.LOOSE_PARSING);
createTestMetaObject(MetaObject.STRICT_PARSING);
createTestMetaObject(MetaObject.LOOSE_PARSING);
assertEquals(4, TestMetaObject.getAddAttributeCount());
}
private TestMetaObject createTestMetaObject(boolean strictParsing) {
TestMetaObject metaObject = new TestMetaObject(strictParsing);
metaObject.setAttribute("SystemName", "SomeName");
metaObject.setAttribute("systemname", "somename");
metaObject.setAttribute("String1", "Foo Bar");
metaObject.setAttribute("string1", "foo bar");
return metaObject;
}
}

View File

@ -1,14 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata;
import junit.framework.TestCase;
public abstract class MetadataTestCase extends TestCase {
// nothing yet but we always end up wanting something
}

View File

@ -1,48 +0,0 @@
package com.ossez.usreio.tests.common.metadata;
import java.util.Map;
class TestMetaObject extends MetaObject {
public static final String SYSTEM_NAME = "SystemName";
public static final String STRING1 = "String1";
private static int sAddAttributeCount;
public TestMetaObject(boolean strictParsing) {
super(strictParsing);
}
@Override
public MetadataType[] getChildTypes() {
return sNoChildren;
}
@Override
protected String getIdAttr() {
return SYSTEM_NAME;
}
@Override
protected void addAttributesToMap(Map attributeMap) {
attributeMap.put(SYSTEM_NAME, sAlphanum10);
attributeMap.put(STRING1, sText);
sAddAttributeCount++;
}
public String getSystemName() {
return getStringAttribute(SYSTEM_NAME);
}
public String getString1() {
return getStringAttribute(STRING1);
}
public static void resetAddAttributeCount() {
sAddAttributeCount = 0;
}
public static int getAddAttributeCount() {
return sAddAttributeCount;
}
}

View File

@ -1,38 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrAbstractTextTest extends AttrTypeTest {
@Override
protected void setUp() {
this.mShort = new AttrAbstractText(1, 10) {
@Override
protected void checkContent(String value) throws MetaParseException {
return;
}
};
this.mLong = new AttrAbstractText(10, 20) {
@Override
protected void checkContent(String value) throws MetaParseException {
return;
}
};
}
public void testAttrAbstractText() throws MetaParseException {
assertEquals("type is not String", String.class, this.mShort.getType());
String test = "short";
assertEquals("return object not identical", this.mShort.parse(test,true), test);
}
public void testTooLong() throws Exception {
assertParseException(this.mShort, "way too long");
}
public void testTooShort() throws Exception {
assertParseException(this.mLong, "short");
}
AttrType mShort, mLong;
}

View File

@ -1,45 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrAlphanumTest extends AttrTypeTest {
@Override
protected void setUp() throws Exception {
this.mShort = new AttrAlphanum(1, 10);
this.mLong = new AttrAlphanum(10, 100);
}
public void testAlphanum() throws MetaParseException {
String test1 = "1234567890";
String test2 = "abcdefghijklmnopqrstuvwxyz";
String test3 = test2.toUpperCase();
// special exceptions for CRT metadata
String test4 = "123-_ 456";
this.mShort.parse(test1,true);
this.mLong.parse(test2,true);
this.mLong.parse(test3,true);
this.mShort.parse(test4,true);
}
public void testFailures() throws Exception {
String test1 = "abcdefg%";
String test2 = "!abcdefg";
String test3 = "___^___ ";
assertParseException(this.mShort, test1);
assertParseException(this.mShort, test2);
assertParseException(this.mShort, test3);
}
public void testLength() throws Exception {
String test1 = "abcdefghij12345";
String test2 = "12345";
assertParseException(this.mShort, test1);
assertParseException(this.mLong, test2);
}
private AttrType mShort;
private AttrType mLong;
}

View File

@ -1,46 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrBooleanTest
extends AttrTypeTest
{
public void testBoolean() throws Exception
{
String[] trues = {"true", "1", "TrUe", "Y"};
String[] falses = {"false", "FALSE","0", "", "N"};
String[] exceptions = {"weird", "#(*&", "2", "falze"};
AttrType parser = new AttrBoolean();
assertEquals("Wrong Class returned", Boolean.class, parser.getType());
for (int i = 0; i < trues.length; i++)
{
String input = trues[i];
boolean value = ((Boolean)parser.parse(input,true)).booleanValue();
assertTrue("Expected true return for " + input, value);
}
for (int i = 0; i < falses.length; i++)
{
String input = falses[i];
boolean value = ((Boolean)parser.parse(input,true)).booleanValue();
assertFalse("Expected false return for " + input, value);
}
for (int i = 0; i < exceptions.length; i++)
{
String input = exceptions[i];
assertParseException(parser, input);
}
}
public void testBooleanOutput() throws MetaParseException
{
AttrBoolean parser = new AttrBoolean();
Boolean output = parser.parse("true",true);
assertEquals("1", parser.render(output));
output = parser.parse("false",true);
assertEquals("0", parser.render(output));
}
}

View File

@ -1,27 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
public class AttrDateTest extends AttrTypeTest {
public void testAttrDate() throws Exception {
/*
* AttrDate uses Strings now, not dates.
* bgutierrez Sep. 17, 2012
*
* AttrType parser = new AttrDate();
assertEquals(parser.getType(), Date.class);
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.clear();
cal.set(2003, Calendar.NOVEMBER, 5, 17, 50, 23);
assertEquals(cal.getTime(), parser.parse("Wed, 5 Nov 2003 17:50:23 GMT",true));
assertEquals(new Date(0), parser.parse("Thu, 1 Jan 1970 00:00:00 GMT",true));
assertEquals("wrong day of week but still should parse!", new Date(0), parser.parse("Tue, 1 Jan 1970 00:00:00 GMT",true));
assertParseException(parser, "2/12/70");
assertParseException(parser, "12/2/70");
assertParseException(parser, "2003-1-1");
// month and date backwards
assertParseException(parser, "Thu, Jan 1 1970 00:00:00 GMT");*/
}
}

View File

@ -1,17 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
public class AttrEnumTest extends AttrTypeTest {
public void testEnum() throws Exception {
String[] values = { "One", "Two", "Three" };
AttrType parser = new AttrEnum(values);
for (int i = 0; i < values.length; i++) {
String value = values[i];
assertEquals(value, parser.render(parser.parse(value,true)));
}
assertParseException(parser, "Four");
assertParseException(parser, "");
assertParseException(parser, "three");
}
}

View File

@ -1,17 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
public class AttrGenericTextTest extends AttrTypeTest {
public void testAttrGeneric() throws Exception {
AttrType parser = new AttrGenericText(0, 10, "abcdefg");
assertEquals("aaaaa", parser.parse("aaaaa",true));
assertEquals("abcdefg", parser.parse("abcdefg",true));
assertEquals("", parser.parse("",true));
assertParseException(parser, "abcdefG");
assertParseException(parser, "A");
assertParseException(parser, "abcdefgabcd");
}
}

View File

@ -1,21 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
public class AttrNumericTest extends AttrTypeTest {
public void testNumeric() throws Exception {
AttrType parser = new AttrNumeric();
assertEquals(Integer.class, parser.getType());
int[] values = { 1, 100, 99999, 12345, 67890 };
for (int i = 0; i < values.length; i++) {
int expected = values[i];
String input = Integer.toString(expected);
Object o = parser.parse(input,true);
int output = ((Integer) o).intValue();
assertEquals(expected, output);
}
assertParseException(parser, "0x99");
assertParseException(parser, "0AF");
assertParseException(parser, "0L");
}
}

View File

@ -1,27 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
public class AttrPlaintextTest extends AttrTypeTest {
public void testPlaintext() throws Exception {
AttrType parser = new AttrPlaintext(0, 10);
assertEquals(String.class, parser.getType());
String[] good = { "%17a", "!%@$", "90785", ")!(*%! ", "" };
String[] bad = { "\r\n", "\t", new String(new char[] { (char) 7 }) };
for (int i = 0; i < good.length; i++) {
String s = good[i];
assertEquals(s, parser.parse(s,true));
}
for (int i = 0; i < bad.length; i++) {
String s = bad[i];
assertParseException(parser, s);
}
AttrType parser2 = new AttrPlaintext(10, 20);
assertParseException(parser2, "1");
assertParseException(parser2, "123456789012345678901");
}
}

View File

@ -1,23 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
public class AttrTextTest extends AttrTypeTest {
public void testAttrText() throws Exception {
AttrType parser = new AttrText(0, 10);
String[] good = { "\r\n\t", "eabc\rdefg", };
String[] bad = { (char) 7 + "", (char) 1 + "", "12345678901", };
assertEquals(parser.getType(), String.class);
for (int i = 0; i < good.length; i++) {
String s = good[i];
assertEquals(s, parser.parse(s,true));
}
for (int i = 0; i < bad.length; i++) {
String s = bad[i];
assertParseException(parser, s);
}
}
}

View File

@ -1,28 +0,0 @@
/*
* cart: CRT's Awesome RETS Tool
*
* Author: David Terrell
* Copyright (c) 2003, The National Association of REALTORS
* Distributed under a BSD-style license. See LICENSE.TXT for details.
*/
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.MetadataTestCase;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
/**
* It's rare you can encapsulate the exception expecting tests, but I can,
* so, I did.
*/
public abstract class AttrTypeTest extends MetadataTestCase {
protected void assertParseException(AttrType attrib, String input) throws Exception {
attrib.parse(input,false);
try {
attrib.parse(input,true);
fail("Expected MetaParseException, got no exception for input " + '"' + input + '"');
} catch (MetaParseException e) {
// "success"
}
}
}

View File

@ -1,32 +0,0 @@
package com.ossez.usreio.tests.common.metadata.attrib;
import com.ossez.usreio.tests.common.metadata.AttrType;
import com.ossez.usreio.tests.common.metadata.MetaParseException;
public class AttrVersionTest extends AttrTypeTest {
@Override
protected void setUp() throws Exception {
this.mParser = new AttrVersion();
}
public void testAttrVersion() throws Exception {
assertEquals(this.mParser.getType(), Integer.class);
assertVersionEquals(10500005, "1.5.5");
assertVersionEquals(123456789, "12.34.56789");
assertVersionEquals(0, "0.0.0");
assertParseException("1.1.1.1");
assertParseException("1.1");
assertParseException("123456789");
}
private void assertParseException(String input) throws Exception {
assertParseException(this.mParser, input);
}
private void assertVersionEquals(int expected, String input) throws MetaParseException {
Integer i = (Integer) this.mParser.parse(input,true);
assertEquals(expected, i.intValue());
}
private AttrType mParser;
}

View File

@ -1,54 +0,0 @@
package com.ossez.usreio.tests.common.util;
import java.util.HashMap;
import java.util.Map;
import com.ossez.usreio.common.util.CaseInsensitiveTreeMap;
import junit.framework.TestCase;
public class CaseInsensitiveTreeMapTest extends TestCase {
private CaseInsensitiveTreeMap map;
@Override
protected void setUp() throws Exception {
super.setUp();
this.map = new CaseInsensitiveTreeMap();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
this.map = null;
}
public void testGetPut() throws Exception {
this.map.put("A", "X");
assertEquals("X", this.map.get("A"));
assertEquals("X", this.map.get("a"));
this.map.put("a", "Y");
assertEquals("Y", this.map.get("a"));
assertEquals("Y", this.map.get("A"));
assertEquals(1, this.map.size());
}
public void testContainsKey() throws Exception {
this.map.put("A", "X");
assertTrue(this.map.containsKey("A"));
assertTrue(this.map.containsKey("a"));
}
public void testClone() throws Exception {
Map otherMap = new HashMap();
otherMap.put("A", "X");
otherMap.put("a", "Y");
assertEquals(2, otherMap.size());
CaseInsensitiveTreeMap newCitm = new CaseInsensitiveTreeMap(otherMap);
assertEquals(1, newCitm.size());
// no guarantee of *which* value we'll get, just that they'll be equal
assertEquals(this.map.get("a"), this.map.get("A"));
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

View File

@ -1,18 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
<METADATA-LOOKUP Resource="Property" Version="1.00.000" Date="Sat, 20 Mar 2002 12:03:38 GMT">
<COLUMNS> LookupName VisibleName Version Date </COLUMNS>
<DATA> E_SCHOOL Elementary School District 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
<DATA> H_SCHOOL High School District 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
<DATA> AR Area 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
<DATA> IFT Interior Features 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
<DATA> VEW View 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
<DATA> LISTING_TYPE Listing Type 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
<DATA> LISTING_STATUS Listing Status 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
<DATA> M_SCHOOL Middle School District 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
<DATA> EFT Exerior Features 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
</METADATA-LOOKUP>
<METADATA-LOOKUP Resource="Agent" Version="1.00.000" Date="Sat, 20 Mar 2002 12:03:38 GMT">
<COLUMNS> LookupName VisibleName Version Date </COLUMNS>
<DATA> DESIGNATIONS DESIGNATIONS 1.00.000 Sat, 20 Mar 2002 12:03:38 GMT </DATA>
</METADATA-LOOKUP>
</RETS>

View File

@ -1 +0,0 @@
<RETS ReplyCode="20503" ReplyText="No Records"/>

View File

@ -1,6 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
<METADATA-SYSTEM Version="01.00.001" Date="Tue, 27 May 2003 12:00:00 CDT">
<SYSTEM SystemID="CRT_RETS" SystemDescription="Center for REALTOR Technology"/>
<COMMENTS>The reference implementation of a RETS Server</COMMENTS>
</METADATA-SYSTEM>
</RETS>

View File

@ -1,7 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
<METADATA-UPDATE_TYPE Resource="ActiveAgent" Class="ACTAGT" Update="Change_ACTAGT" Version="1.00.000" Date="Sat, 20 Mar 2002 12:03:38 GMT">
<COLUMNS> SystemName Sequence Attributes Default ValidationExpressionID UpdateHelpID ValidationLookupName ValidationExternalName </COLUMNS>
<DATA> AGENT_ID 1 1 0 </DATA>
<DATA> OFFICE_ID 2 2 0 </DATA>
</METADATA-UPDATE_TYPE>
</RETS>

View File

@ -1,17 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
<RETS-RESPONSE>
broker = B123, BO987
membername = Joe T. Schmoe
metadataversion = 1.00.000
minmetadataversion = 1.00.000
user = A123,5678,1,A123
login = http://rets.test:6103/login
logout = http://rets.test:6103/logout
search = http://rets.test:6103/search
getmetadata = http://rets.test:6103/getMetadata
changepassword = http://rets.test:6103/changePassword
getobject = http://rets.test:6103/getObjectEx
action = http://rets.test:6103/get
balance = 44.21
timeoutseconds = 60
</RETS-RESPONSE></RETS>

View File

@ -1,16 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
Broker = B123, BO987
MemberName = Joe T. Schmoe
MetadataVersion = 1.00.000
MinMetadataVersion = 1.00.000
User = A123,5678,1,A123
Login = http://rets.test:6103/login
Logout = http://rets.test:6103/logout
Search = http://rets.test:6103/search
GetMetadata = http://rets.test:6103/getMetadata
ChangePassword = http://rets.test:6103/changePassword
GetObject = http://rets.test:6103/getObjectEx
Action = http://rets.test:6103/get
Balance = 44.21
TimeoutSeconds = 60
</RETS>

View File

@ -1,17 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
<RETS-RESPONSE>
Broker = B123, BO987
MemberName = Joe T. Schmoe
MetadataVersion = 1.00.000
MinMetadataVersion = 1.00.000
User = A123,5678,1,A123
Login = http://rets.test:6103/login
Logout = http://rets.test:6103/logout
Search = http://rets.test:6103/search
GetMetadata = http://rets.test:6103/getMetadata
ChangePassword = http://rets.test:6103/changePassword
GetObject = http://rets.test:6103/getObjectEx
Action = http://rets.test:6103/get
Balance = 44.21
TimeoutSeconds = 60
</RETS-RESPONSE></RETS>

View File

@ -1,6 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
<RETS-RESPONSE>
connecttime = 1000
billing = $20.00
signoffmessage = Good Bye
</RETS-RESPONSE></RETS>

View File

@ -1,4 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
<RETS-RESPONSE>
Logged Out
</RETS-RESPONSE></RETS>

View File

@ -1,5 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
ConnectTime = 1000
Billing = $20.00
SignOffMessage = Good Bye
</RETS>

View File

@ -1,6 +0,0 @@
<RETS ReplyCode="0" ReplyText="Operation Successful">
<RETS-RESPONSE>
ConnectTime = 1000
Billing = $20.00
SignOffMessage = Good Bye
</RETS-RESPONSE></RETS>

View File

@ -1,12 +0,0 @@
package com.ossez.usreio.common.util;
import java.io.Serializable;
import java.util.Comparator;
public class CaseInsensitiveComparator<T> implements Comparator<T>, Serializable {
public int compare(Object o1, Object o2) {
String s1 = (String) o1;
String s2 = (String) o2;
return s1.compareToIgnoreCase(s2);
}
}

View File

@ -1,17 +0,0 @@
package com.ossez.usreio.common.util;
import java.util.Map;
import java.util.TreeMap;
public class CaseInsensitiveTreeMap<K, V> extends TreeMap<K, V> {
public CaseInsensitiveTreeMap(Map<K, V> map) {
this();
this.putAll(map);
}
public CaseInsensitiveTreeMap() {
super(new CaseInsensitiveComparator());
}
}