LinkType.java revision 2a800c5e99e40ed3ce5545a905036e422a787bf8
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions Copyrighted [year] [name of copyright owner]".
*
* Copyright © 2011 ForgeRock AS. All rights reserved.
*/
// Java Standard Edition
// SLF4J
// JSON Fluent library
// OpenIDM
/**
* Represents the sharable Link Types,
* and helpers for mappings to find and use matching link types
* as mappings can share link sets, bi-directional.
*
* @author aegloff
*/
class LinkType {
// The link type name
// The linked object sets, bi-directional
// Whether linking should be case sensitive on the first or second IDs
boolean firstCaseSensitive;
boolean secondCaseSensitive;
// Represents how this LinkType matches a given ObjectMapping
/**
* LinkType factory method
* @param forMapping the mapping to find the link type for
* @param allMappings all configured mappings
* @return the link type matching the requested
*/
// Link order is influenced by link type name being same as the (defining) mapping name.
// Enhancement to consider: May want to allow explicit LinkType definition option
}
}
}
if (linkDefiner == null) {
String warning = "When using links from another mapping the links must be named according to the mapping."
throw new InvalidException(warning);
}
return new LinkType(linkDefiner.getName(), linkDefiner.getSourceObjectSet(), linkDefiner.getTargetObjectSet(),
}
return name;
}
public boolean useReverse() {
}
public boolean getFirstCaseSensitive() {
return firstCaseSensitive;
}
public boolean getSecondCaseSensitive() {
return secondCaseSensitive;
}
this.firstObjectSet = firstObjectSet;
this.secondObjectSet = secondObjectSet;
this.firstCaseSensitive = firstCaseSensitive;
}
/**
* Normalizes the source ID if required, e.g. make lower case for
* case insensitive id comparison purposes
* @param aSourceId the original id
* @return normalized id
*/
if (!isSourceCaseSensitive()) {
} else {
return aSourceId;
}
}
/**
* Normalizes the target ID if required, e.g. make lower case for
* case insensitive id comparison purposes
* @param aSourceId the original id
* @return normalized id
*/
if (!isTargetCaseSensitive()) {
} else {
return aTargetId;
}
}
/**
* Unconditionally normalizes the given ID, currently to lower case
* @param anId the original id
* @return normalized id
*/
}
/**
* @return whether the source id is case sensitive
*/
public boolean isSourceCaseSensitive() {
if (useReverse()) {
return getSecondCaseSensitive();
} else {
return getFirstCaseSensitive();
}
}
/**
* @return whether the target id is case sensitive
*/
public boolean isTargetCaseSensitive() {
if (useReverse()) {
return getFirstCaseSensitive();
} else {
return getSecondCaseSensitive();
}
}
/**
* Determines whether the link types are compatible and in which order (direction)
*/
public enum Match {
logger.info("Mapping {} defines links named {}.", linkDefiner.getName(), linkDefiner.getLinkTypeName());
} else {
logger.info("Mapping {} shares the links of {} named {}.", new Object[] {forMapping.getName(), linkDefiner.getName(), linkDefiner.getLinkTypeName()});
}
return MATCH_EXACT;
logger.info("Mapping {} shares the links of {} in the opposite direction, named {}.", new Object[] {forMapping.getName(), linkDefiner.getName(), linkDefiner.getLinkTypeName()});
return MATCH_REVERSE;
} else {
throw new InvalidException("Mappings " + forMapping.getName() + " and " + linkDefiner.getName() + " {} are configured to share the same links of "
+ linkDefiner.getLinkTypeName() + ", but use incompatible source or targets: (" + forMapping.getSourceObjectSet() + "->" + forMapping.getTargetObjectSet()
}
}
}
}