Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2017 TerraMeta Software, Inc.
*
* 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.
*/
package org.cloudgraph.store.lang;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cloudgraph.store.service.GraphServiceException;
import org.plasma.query.collector.SelectionCollector;
import org.plasma.query.model.Where;
import org.plasma.sdo.PlasmaDataObject;
import org.plasma.sdo.PlasmaProperty;
import org.plasma.sdo.PlasmaType;
import org.plasma.sdo.access.DataAccessException;
import org.plasma.sdo.access.provider.common.PropertyPair;
import org.plasma.sdo.profile.KeyType;
import commonj.sdo.Property;
import commonj.sdo.Type;
/**
* Default assembler functionality without any shared objects related to graph
* assembly, such that it is usable by parallel tasks.
*
* @author Scott Cinnamond
* @since 0.6.2
*/
public abstract class AssemblerSupport {
private static Log log = LogFactory.getLog(AssemblerSupport.class);
protected SelectionCollector collector;
protected StatementFactory statementFactory;
protected StatementExecutor statementExecutor;
@SuppressWarnings("unused")
private AssemblerSupport() {
}
public AssemblerSupport(SelectionCollector collector, StatementFactory statementFactory,
StatementExecutor statementExecutor) {
this.collector = collector;
this.statementFactory = statementFactory;
this.statementExecutor = statementExecutor;
}
public StatementFactory getStatementFactory() {
return statementFactory;
}
public StatementExecutor getStatementExecutor() {
return statementExecutor;
}
protected List getChildKeyPairs(PropertyPair pair) {
List childKeyProps = new ArrayList();
PlasmaProperty supplier = pair.getProp().getKeySupplier();
if (supplier != null) {
PropertyPair childPair = new PropertyPair(supplier, pair.getValue());
childPair.setValueProp(supplier);
childKeyProps.add(childPair);
} else {
List childPkProps = ((PlasmaType) pair.getProp().getType())
.findProperties(KeyType.primary);
if (childPkProps.size() == 1) {
childKeyProps.add(new PropertyPair((PlasmaProperty) childPkProps.get(0), pair.getValue()));
} else
throwPriKeyError(childPkProps, pair.getProp().getType(), pair.getProp());
}
return childKeyProps;
}
protected List getChildKeyPairs(PlasmaDataObject dataObject, PlasmaProperty prop) {
PlasmaProperty opposite = (PlasmaProperty) prop.getOpposite();
if (opposite == null)
throw new DataAccessException("no opposite property found"
+ " - cannot map from many property, " + prop.toString());
List childKeyProps = new ArrayList();
List pkProps = ((PlasmaType) dataObject.getType()).findProperties(KeyType.primary);
if (pkProps.size() == 1) {
PlasmaProperty pkProp = (PlasmaProperty) pkProps.get(0);
Object value = dataObject.get(pkProp);
if (value != null) {
PropertyPair pair = new PropertyPair(opposite, value);
pair.setValueProp(pkProp);
childKeyProps.add(pair);
} else
throw new GraphServiceException("no value found for key property, " + pkProp.toString());
} else
throwPriKeyError(pkProps, dataObject.getType(), prop);
return childKeyProps;
}
protected List> getPredicateResult(PlasmaType targetType,
PlasmaProperty sourceProperty, Set props, List childKeyPairs) {
List> result = null;
Where where = this.collector.getPredicate(sourceProperty);
if (where == null) {
List