use of org.activiti.engine.impl.persistence.entity.PropertyEntity in project Activiti by Activiti.
the class DbSqlSession method dbSchemaUpdate.
public String dbSchemaUpdate() {
String feedback = null;
boolean isUpgradeNeeded = false;
int matchingVersionIndex = -1;
if (isEngineTablePresent()) {
PropertyEntity dbVersionProperty = selectById(PropertyEntity.class, "schema.version");
String dbVersion = dbVersionProperty.getValue();
// Determine index in the sequence of Activiti releases
int index = 0;
while (matchingVersionIndex < 0 && index < ACTIVITI_VERSIONS.size()) {
if (ACTIVITI_VERSIONS.get(index).matches(dbVersion)) {
matchingVersionIndex = index;
} else {
index++;
}
}
// Exception when no match was found: unknown/unsupported version
if (matchingVersionIndex < 0) {
throw new ActivitiException("Could not update Activiti database schema: unknown version from database: '" + dbVersion + "'");
}
isUpgradeNeeded = (matchingVersionIndex != (ACTIVITI_VERSIONS.size() - 1));
if (isUpgradeNeeded) {
dbVersionProperty.setValue(ProcessEngine.VERSION);
PropertyEntity dbHistoryProperty;
if ("5.0".equals(dbVersion)) {
dbHistoryProperty = new PropertyEntity("schema.history", "create(5.0)");
insert(dbHistoryProperty);
} else {
dbHistoryProperty = selectById(PropertyEntity.class, "schema.history");
}
// Set upgrade history
String dbHistoryValue = dbHistoryProperty.getValue() + " upgrade(" + dbVersion + "->" + ProcessEngine.VERSION + ")";
dbHistoryProperty.setValue(dbHistoryValue);
// Engine upgrade
dbSchemaUpgrade("engine", matchingVersionIndex);
feedback = "upgraded Activiti from " + dbVersion + " to " + ProcessEngine.VERSION;
}
} else {
dbSchemaCreateEngine();
}
if (isHistoryTablePresent()) {
if (isUpgradeNeeded) {
dbSchemaUpgrade("history", matchingVersionIndex);
}
} else if (dbSqlSessionFactory.isDbHistoryUsed()) {
dbSchemaCreateHistory();
}
if (isIdentityTablePresent()) {
if (isUpgradeNeeded) {
dbSchemaUpgrade("identity", matchingVersionIndex);
}
} else if (dbSqlSessionFactory.isDbIdentityUsed()) {
dbSchemaCreateIdentity();
}
return feedback;
}
use of org.activiti.engine.impl.persistence.entity.PropertyEntity in project Activiti by Activiti.
the class GetNextIdBlockCmd method execute.
public IdBlock execute(CommandContext commandContext) {
PropertyEntity property = (PropertyEntity) commandContext.getPropertyEntityManager().findPropertyById("next.dbid");
long oldValue = Long.parseLong(property.getValue());
long newValue = oldValue + idBlockSize;
property.setValue(Long.toString(newValue));
return new IdBlock(oldValue, newValue - 1);
}
use of org.activiti.engine.impl.persistence.entity.PropertyEntity in project Activiti by Activiti.
the class GetPropertiesCmd method execute.
@SuppressWarnings("unchecked")
public Map<String, String> execute(CommandContext commandContext) {
List<PropertyEntity> propertyEntities = commandContext.getDbSqlSession().selectList("selectProperties");
Map<String, String> properties = new HashMap<String, String>();
for (PropertyEntity propertyEntity : propertyEntities) {
properties.put(propertyEntity.getName(), propertyEntity.getValue());
}
return properties;
}
Aggregations