本文整理汇总了Java中ca.sqlpower.dao.SPPersistenceException类的典型用法代码示例。如果您正苦于以下问题:Java SPPersistenceException类的具体用法?Java SPPersistenceException怎么用?Java SPPersistenceException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SPPersistenceException类属于ca.sqlpower.dao包,在下文中一共展示了SPPersistenceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeObject
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
public void removeObject(String parentUUID, String uuid)
throws SPPersistenceException {
if (transactionCount == 0) {
throw new SPPersistenceException("Operation attempted while not in a transaction.");
}
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put(METHOD, SPPersistMethod.removeObject.getCode());
jsonObject.put(PARENT_UUID, parentUUID);
jsonObject.put("uuid", uuid);
} catch (JSONException e) {
logger.error(e);
rollback();
throw new SPPersistenceException(uuid, e);
}
logger.debug(jsonObject);
messageBuffer.add(jsonObject);
}
示例2: getImageRendererProperty
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Retrieves a property value from an {@link ImageRenderer} object based on
* the property name and converts it to something that can be passed to a
* persister.
*
* @param iRenderer
* The {@link ImageRenderer} object to retrieve the named
* property from.
* @param propertyName
* The property name that needs to be retrieved and converted.
* This is the name of the property in the class itself based on
* the property fired by the setter for the event which is
* enforced by tests using JavaBeans methods even though the
* values are hard coded in here and won't change if the class
* changes.
* @return The value stored in the variable of the object we are given at
* the property name after it has been converted to a type that can
* be stored. The conversion is based on the
* {@link WabitSessionPersisterSuperConverter}.
* @throws SPPersistenceException
* Thrown if the property name is not known in this method.
*/
private Object getImageRendererProperty(ImageRenderer iRenderer,
String propertyName) throws SPPersistenceException {
if (propertyName.equals("image")) {
return converter.convertToBasicType(iRenderer.getImage());
} else if (propertyName.equals("preservingAspectRatio")) {
return converter.convertToBasicType(iRenderer
.isPreservingAspectRatio());
} else if (propertyName.equals("preserveAspectRatioWhenResizing")) {
return converter.convertToBasicType(iRenderer
.isPreserveAspectRatioWhenResizing());
} else if (propertyName.equals("HAlign")) {
return converter.convertToBasicType(iRenderer.getHAlign());
} else if (propertyName.equals("VAlign")) {
return converter.convertToBasicType(iRenderer.getVAlign());
} else {
throw new SPPersistenceException(
iRenderer.getUUID(),
getSPPersistenceExceptionMessage(iRenderer, propertyName));
}
}
示例3: persistProperty
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
@Override
public void persistProperty(String uuid, String propertyName,
DataType propertyType, Object oldValue, Object newValue)
throws SPPersistenceException {
try {
if (filterOn.call() == Boolean.TRUE) {
if(!seenUUIDS.contains(uuid)) {
targetPersister.persistProperty(uuid, propertyName, propertyType, oldValue, newValue);
}
} else {
targetPersister.persistProperty(uuid, propertyName, propertyType, oldValue, newValue);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例4: persistRevisionFromServer
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Requests the server for persist calls from version 0 to the given revision
* of the given project, and persists them to the given decoder.
*
* @param projectLocation
* @param revisionNo Must be greater than zero, and no greater than the current revision number
* @param decoder
* @throws IOException
* @throws URISyntaxException
* @throws SPPersistenceException
* @throws IllegalArgumentException Thrown if the server rejects the given revisionNo
*/
public static void persistRevisionFromServer(ProjectLocation projectLocation,
int revisionNo,
SPJSONMessageDecoder decoder,
CookieStore cookieStore)
throws IOException, URISyntaxException, SPPersistenceException, IllegalArgumentException {
SPServerInfo serviceInfo = projectLocation.getServiceInfo();
HttpClient httpClient = ClientSideSessionUtils.createHttpClient(serviceInfo, cookieStore);
try {
JSONMessage response = ClientSideSessionUtils.executeServerRequest(httpClient, serviceInfo,
"/" + ClientSideSessionUtils.REST_TAG + "/project/" + projectLocation.getUUID() + "/" + revisionNo,
new JSONResponseHandler());
if (response.isSuccessful()) {
decoder.decode(response.getBody());
} else {
throw new IllegalArgumentException("The server rejected the revision number " +
"(it must be greater than 0, and no greater than the current revision number)");
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例5: removeObject
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Removes {@link WabitObject}s from persistent storage.
*
* @param parentUUID
* The parent UUID of the {@link WabitObject} to remove
* @param uuid
* The UUID of the {@link WabitObject} to remove
* @throws SPPersistenceException
*/
public void removeObject(String parentUUID, String uuid)
throws SPPersistenceException {
synchronized (session) {
this.enforeThreadSafety();
if (logger.isDebugEnabled()) {
logger.debug(String.format("wsp.removeObject(\"%s\", \"%s\");",
parentUUID, uuid));
}
if (this.transactionCount==0) {
logger.error("Remove Object attempted while not in a transaction. Rollback initiated.");
this.rollback();
throw new SPPersistenceException(uuid,"Remove Object attempted while not in a transaction. Rollback initiated.");
}
if (!exists(uuid)) {
this.rollback();
throw new SPPersistenceException(uuid,
"Cannot remove the WabitObject with UUID " + uuid
+ " from parent UUID " + parentUUID
+ " as it does not exist.");
}
objectsToRemove.put(uuid, parentUUID);
}
}
示例6: testBegin
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
public void testBegin() throws Exception {
MessageSender<JSONObject> messagePasser = new MessageSender<JSONObject>() {
public void send(JSONObject content) throws SPPersistenceException {
try {
assertEquals(content.getString(SPJSONPersister.METHOD), SPPersistMethod.begin.getCode());
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
public void flush() throws SPPersistenceException {
// no-op
}
public void clear() {
// no op
}
};
persister = new SPJSONPersister(messagePasser);
persister.begin();
}
示例7: commitPageProperty
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Commits a persisted {@link Page} object property
*
* @param page
* The {@link Page} object to commit the persisted property upon
* @param propertyName
* The property name
* @param newValue
* The persisted property value to be committed
* @throws SPPersistenceException
* Thrown if the property name is not known in this method.
*/
private void commitPageProperty(Page page, String propertyName,
Object newValue) throws SPPersistenceException {
if (propertyName.equals("height")) {
page.setHeight((Integer) converter.convertToComplexType(newValue,
Integer.class));
} else if (propertyName.equals("width")) {
page.setWidth((Integer) converter.convertToComplexType(newValue,
Integer.class));
} else if (propertyName.equals("orientation")) {
page.setOrientation((PageOrientation) converter
.convertToComplexType(newValue, PageOrientation.class));
} else if (propertyName.equals("defaultFont")) {
page.setDefaultFont((Font) converter.convertToComplexType(newValue,
Font.class));
} else {
throw new SPPersistenceException(page.getUUID(),
getSPPersistenceExceptionMessage(page, propertyName));
}
}
示例8: commitWabitOlapAxisProperty
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Commits a persisted {@link WabitOlapAxis} object property
*
* @param olapAxis
* The {@link WabitOlapAxis} object to commit the persisted
* property upon
* @param propertyName
* The property name
* @param newValue
* The persisted property value to be committed
* @throws SPPersistenceException
* Thrown if the property name is not known in this method.
*/
private void commitWabitOlapAxisProperty(WabitOlapAxis olapAxis,
String propertyName, Object newValue)
throws SPPersistenceException {
if (propertyName.equals("nonEmpty")) {
olapAxis.setNonEmpty((Boolean) converter.convertToComplexType(
newValue, Boolean.class));
} else if (propertyName.equals("sortEvaluationLiteral")) {
olapAxis.setSortEvaluationLiteral((String) converter
.convertToComplexType(newValue, String.class));
} else if (propertyName.equals("sortOrder")) {
olapAxis.setSortOrder((String) converter.convertToComplexType(
newValue, String.class));
} else {
throw new SPPersistenceException(olapAxis.getUUID(),
getSPPersistenceExceptionMessage(olapAxis, propertyName));
}
}
示例9: getCellSetRendererProperty
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Retrieves a property value from a {@link CellSetRenderer} object based on
* the property name and converts it to something that can be passed to a
* persister.
*
* @param csRenderer
* The {@link CellSetRenderer} object to retrieve the named
* property from.
* @param propertyName
* The property name that needs to be retrieved and converted.
* This is the name of the property in the class itself based on
* the property fired by the setter for the event which is
* enforced by tests using JavaBeans methods even though the
* values are hard coded in here and won't change if the class
* changes.
* @return The value stored in the variable of the object we are given at
* the property name after it has been converted to a type that can
* be stored. The conversion is based on the
* {@link WabitSessionPersisterSuperConverter}.
* @throws SPPersistenceException
* Thrown if the property name is not known in this method.
*/
private Object getCellSetRendererProperty(CellSetRenderer csRenderer,
String propertyName) throws SPPersistenceException {
if (propertyName.equals("bodyAlignment")) {
return converter.convertToBasicType(csRenderer.getBodyAlignment());
} else if (propertyName.equals("bodyFormat")) {
return converter.convertToBasicType(csRenderer.getBodyFormat());
} else if (propertyName.equals("headerFont")) {
return converter.convertToBasicType(csRenderer.getHeaderFont());
} else if (propertyName.equals("bodyFont")) {
return converter.convertToBasicType(csRenderer.getBodyFont());
} else if (propertyName.equals("backgroundColour")) {
return converter.convertToBasicType(csRenderer.getBackgroundColour());
} else {
throw new SPPersistenceException(csRenderer.getUUID(),
getSPPersistenceExceptionMessage(csRenderer,
propertyName));
}
}
示例10: commit
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Increments the commit counter and adds this commit call to the list of
* persister calls.
*/
@Override
public void commit() throws SPPersistenceException {
commitCount++;
persisterCalls.add(SPPersistMethod.commit);
if (beginCount == commitCount) {
List<PersistedSPObject> orderedPersistedObjects = new ArrayList<PersistedSPObject>(persistedObjects.values());
Collections.sort(orderedPersistedObjects, persistedObjectComparator);
savedPersistedObjects = new ArrayList<PersistedSPObject>();
for (PersistedSPObject pwo : orderedPersistedObjects) {
savedPersistedObjects.add(new PersistedSPObject(
pwo.getParentUUID(), pwo.getType(), pwo.getUUID(), pwo.getIndex()));
}
savedObjectsToRemove = new TreeMap<String, String>(removedObjectComparator);
savedObjectsToRemove.putAll(objectsToRemove);
super.commit();
latch.countDown();
} else {
super.commit();
}
}
示例11: getComparisonDiffChunks
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Gets a list of DiffChunks representing the differences between the two revisions from the server.
*/
public List<DiffChunk<DiffInfo>> getComparisonDiffChunks(int oldRevisionNo, int newRevisionNo)
throws IOException, URISyntaxException, JSONException, SPPersistenceException {
SPServerInfo serviceInfo = projectLocation.getServiceInfo();
HttpClient httpClient = ClientSideSessionUtils.createHttpClient(serviceInfo, cookieStore);
try {
JSONMessage response = ClientSideSessionUtils.executeServerRequest(httpClient, projectLocation.getServiceInfo(),
"/" + ClientSideSessionUtils.REST_TAG + "/project/" + projectLocation.getUUID() + "/compare",
"versions=" + oldRevisionNo + ":" + newRevisionNo,
new JSONResponseHandler());
return SimpleDiffChunkJSONConverter.decode(response.getBody());
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例12: getPropertyAndRemove
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Retrieves a persisted property value given by the UUID of the
* {@link WabitObject} and its property name. The property is removed from
* the {@link Multimap} if found.
*
* @param uuid
* The UUID of the {@link WabitObject}
* @param propertyName
* The persisted property name
* @return The persisted property value
* @throws SPPersistenceException
* Thrown if the object does not have the specified property
* name.
*/
private Object getPropertyAndRemove(String uuid, String propertyName)
throws SPPersistenceException {
for (PersistedSPOProperty wop : persistedProperties.get(uuid)) {
if (wop.getPropertyName().equals(propertyName)) {
Object value = wop.getNewValue();
persistedProperties.remove(uuid, wop);
return value;
}
}
// Property might not be persisted because it might be null.
// We therefore need to return null.
return null;
}
示例13: rollbackProperties
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
private void rollbackProperties() throws SPPersistenceException {
Collections.reverse(this.persistedPropertiesRollbackList);
for (PersistedPropertiesEntry entry : this.persistedPropertiesRollbackList) {
try {
final String parentUuid = entry.getUUID();
final String propertyName = entry.getPropertyName();
final Object rollbackValue = entry.getRollbackValue();
final SPObject parent = SQLPowerUtils.findByUuid(root, parentUuid, SPObject.class);
if (parent != null) {
this.applyProperty(parent, propertyName, rollbackValue);
}
} catch (Throwable t) {
// Keep going. We need to rollback as much as we can.
logger.error("Cannot rollback change to " + entry.getPropertyName() + " to value " + entry.getRollbackValue(), t);
}
}
}
示例14: persistProperty
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Persists a {@link WabitObject} property conditionally given by its object
* UUID, property name, property type, expected old value, and new value
*
* @param uuid
* The UUID of the {@link WabitObject} to persist the property
* upon
* @param propertyName
* The property name
* @param propertyType
* The property type
* @param oldValue
* The expected old property value
* @param newValue
* The new property value to persist
* @throws SPPersistenceException
* Thrown if the property name is not known in this method.
*/
public void persistProperty(String uuid, String propertyName,
DataType propertyType, Object oldValue, Object newValue)
throws SPPersistenceException {
if (transactionCount <= 0) {
this.rollback();
throw new SPPersistenceException("Cannot persist objects while outside a transaction.");
}
synchronized (session) {
this.enforeThreadSafety();
if (logger.isDebugEnabled()) {
logger.debug(String.format(
"wsp.persistProperty(\"%s\", \"%s\", DataType.%s, %s, %s);",
uuid, propertyName, propertyType.name(), oldValue, newValue));
}
try {
persistPropertyHelper(uuid, propertyName, propertyType, oldValue,
newValue, this.godMode);
} catch (SPPersistenceException e) {
this.rollback();
throw e;
}
}
}
示例15: commitChartColumnProperty
import ca.sqlpower.dao.SPPersistenceException; //导入依赖的package包/类
/**
* Commits a persisted {@link ChartColumn} object property
*
* @param chartColumn
* The {@link ChartColumn} object to commit the persisted
* property upon
* @param propertyName
* The property name
* @param newValue
* The persisted property value to be committed
* @throws SPPersistenceException
* Thrown if the property name is not known in this method.
*/
private void commitChartColumnProperty(ChartColumn chartColumn,
String propertyName, Object newValue)
throws SPPersistenceException {
if (propertyName.equals("roleInChart")) {
chartColumn.setRoleInChart((ColumnRole) converter
.convertToComplexType(newValue, ColumnRole.class));
} else if (propertyName.equals("XAxisIdentifier")) {
chartColumn.setXAxisIdentifier((ChartColumn) converter
.convertToComplexType(newValue, ChartColumn.class));
} else {
throw new SPPersistenceException(chartColumn.getUUID(),
getSPPersistenceExceptionMessage(chartColumn,
propertyName));
}
}