org.efaps.importer.DefaultObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of efaps-kernel Show documentation
Show all versions of efaps-kernel Show documentation
eFaps is a framework used to map objects with or without attached files to
a relational database and optional file systems (only for attaches files). Configurable access control can be provided down to object and attribute level depending on implementation and use case. Depending on requirements, events (like triggers) allow to implement business logic and to separate business logic from user interface.
The framework includes integrations (e.g. webdav, full text search) and a web application as 'simple' configurable user interface. Some best practises, example web application modules (e.g. team work module) support administrators and implementers using this framework.
/*
* Copyright 2003 - 2012 The eFaps Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Revision: $Rev: 7483 $
* Last Changed: $Date: 2012-05-11 11:57:38 -0500 (Fri, 11 May 2012) $
* Last Changed By: $Author: [email protected] $
*/
package org.efaps.importer;
import java.util.HashMap;
import java.util.Map;
/**
* This Class represents the Possibility to define default Values, for the Case
* a Foreign-Object returns a invalid Value.
*
* Example for the XML-Structure:
<definition>
<default
* type="Admin_User_Person" name="Creator">1</default>
* </definition>
*
* The Value can also be d by a ForeignObject.
*
* @author The eFaps Team
* @version $Id: DefaultObject.java 7483 2012-05-11 16:57:38Z [email protected] $
*/
public class DefaultObject
{
/**
* Contains the defaults defined for this import.
*/
private static final Map DEFAULTS = new HashMap();
/**
* Contains the link to the {@link ForeignObject foreign object} of this
* default object.
*/
private ForeignObject link;
/**
* Contains the value of the default.
*/
private String value = null;
/**
* Defines the {@link #value} and adds a new default to the
* {@link #DEFAULTS}.
*
* @param _type string containing the Type of the Object
* @param _name string containing the Name of the Attribute
* @param _value value to be Set if the Default will be inserted
*/
public void addDefault(final String _type,
final String _name,
final String _value)
{
this.value = _value;
DefaultObject.DEFAULTS.put(_type + "/" + _name, this);
}
/**
* Returns the default value of the object.
*
* @param _type type of the Object
* @param _name name of the Attribute
* @return string containing the default value, null
if not
* defined
*/
public static String getDefault(final String _type,
final String _name)
{
final DefaultObject def = DefaultObject.DEFAULTS.get(_type + "/" + _name);
String ret = null;
if (def != null) {
ret = def.value;
if (ret.equals("")) {
ret = def.link.dbGetValue();
def.value = ret;
}
}
return ret;
}
/**
* Adds a foreign object to this default object.
*
* @param _link foreign object to add
*/
public void addLink(final ForeignObject _link)
{
this.link = _link;
}
}