use of javax.jdo.JDOUserException in project datanucleus-api-jdo by datanucleus.
the class TypeMetadataImpl method newPropertyMetadata.
/* (non-Javadoc)
* @see javax.jdo.metadata.ComponentMetadata#newPropertyMetadata(java.lang.reflect.Method)
*/
public PropertyMetadata newPropertyMetadata(Method method) {
String methodName = method.getName();
String name = null;
if (methodName.startsWith("set")) {
name = methodName.substring(3);
} else if (methodName.startsWith("get")) {
name = methodName.substring(3);
} else if (methodName.startsWith("is")) {
name = methodName.substring(2);
} else {
throw new JDOUserException("Method " + methodName + " is not a Java-bean method");
}
String propertyName = name.substring(0, 1).toLowerCase() + name.substring(1);
PropertyMetaData internalPmd = getInternal().newPropertyMetadata(propertyName);
PropertyMetadataImpl pmd = new PropertyMetadataImpl(internalPmd);
pmd.parent = this;
return pmd;
}
use of javax.jdo.JDOUserException in project datanucleus-api-jdo by datanucleus.
the class JDOPersistenceManager method refreshAll.
/**
* Method to do a refresh of a collection of objects.
* @param pcs The Objects
* @throws JDOUserException thrown if instances could not be refreshed.
*/
public void refreshAll(Collection pcs) {
assertIsOpen();
ArrayList failures = new ArrayList();
Iterator iter = pcs.iterator();
while (iter.hasNext()) {
try {
jdoRefresh(iter.next());
} catch (JDOException e) {
failures.add(e);
}
}
if (!failures.isEmpty()) {
throw new JDOUserException(Localiser.msg("010037"), (Exception[]) failures.toArray(new Exception[failures.size()]));
}
}
use of javax.jdo.JDOUserException in project datanucleus-api-jdo by datanucleus.
the class JDOPersistenceManager method makeNontransactionalAll.
/**
* Method to make nontransactional a collection of objects.
* @param pcs The objects.
* @throws JDOUserException thrown if objects could not be made nontransactional
*/
public void makeNontransactionalAll(Collection pcs) {
assertIsOpen();
assertActiveTransaction();
ArrayList failures = new ArrayList();
Iterator i = pcs.iterator();
while (i.hasNext()) {
try {
jdoMakeNontransactional(i.next());
} catch (RuntimeException e) {
failures.add(e);
}
}
if (!failures.isEmpty()) {
throw new JDOUserException(Localiser.msg("010043"), (Exception[]) failures.toArray(new Exception[failures.size()]));
}
}
use of javax.jdo.JDOUserException in project datanucleus-api-jdo by datanucleus.
the class JDOPersistenceManager method makeTransientAll.
/**
* Method to make transient a collection of objects.
* @param pcs The objects
* @param useFetchPlan Whether to use the fetch plan when making transient
* @throws JDOUserException thrown if objects could not be made transient.
*/
public void makeTransientAll(Collection pcs, boolean useFetchPlan) {
assertIsOpen();
ArrayList failures = new ArrayList();
Iterator i = pcs.iterator();
FetchPlanState state = null;
if (useFetchPlan) {
// Create a state object to carry the processing state info
state = new FetchPlanState();
}
while (i.hasNext()) {
try {
jdoMakeTransient(i.next(), state);
} catch (RuntimeException e) {
failures.add(e);
}
}
if (!failures.isEmpty()) {
throw new JDOUserException(Localiser.msg("010041"), (Exception[]) failures.toArray(new Exception[failures.size()]));
}
}
use of javax.jdo.JDOUserException in project datanucleus-api-jdo by datanucleus.
the class JDOPersistenceManager method makePersistentAll.
/**
* JDO method to make persistent a collection of objects.
* Throws a JDOUserException if objects could not be made persistent.
* @param pcs The objects to persist
* @return The persistent objects
*/
public <T> Collection<T> makePersistentAll(Collection<T> pcs) {
assertIsOpen();
assertWritable();
try {
Object[] persistedPcs = ec.persistObjects(pcs.toArray());
Collection persisted = new ArrayList();
for (int i = 0; i < persistedPcs.length; i++) {
persisted.add(persistedPcs[i]);
}
return persisted;
} catch (NucleusUserException nue) {
Throwable[] failures = nue.getNestedExceptions();
throw new JDOUserException(Localiser.msg("010039"), failures);
}
}
Aggregations