use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class SqlAuditServiceImpl method insertResourceOids.
private void insertResourceOids(JdbcSession jdbcSession, long recordId, Collection<String> resourceOids) {
if (resourceOids.isEmpty()) {
return;
}
QAuditResource qAuditResource = QAuditResourceMapping.get().defaultAlias();
SQLInsertClause insertBatch = jdbcSession.newInsert(qAuditResource);
for (String resourceOid : resourceOids) {
insertBatch.set(qAuditResource.recordId, recordId).set(qAuditResource.resourceOid, resourceOid).addBatch();
}
insertBatch.setBatchToBulk(true);
insertBatch.execute();
}
use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class SqlAuditServiceImpl method insertChangedItemPaths.
private void insertChangedItemPaths(JdbcSession jdbcSession, long recordId, Collection<MAuditDelta> deltas) {
Set<String> changedItemPaths = new HashSet<>();
for (MAuditDelta delta : deltas) {
try {
ObjectDeltaType deltaBean = schemaService.parserFor(delta.serializedDelta).parseRealValue(ObjectDeltaType.class);
for (ItemDeltaType itemDelta : deltaBean.getItemDelta()) {
ItemPath path = itemDelta.getPath().getItemPath();
CanonicalItemPath canonical = schemaService.createCanonicalItemPath(path, deltaBean.getObjectType());
for (int i = 0; i < canonical.size(); i++) {
changedItemPaths.add(canonical.allUpToIncluding(i).asString());
}
}
} catch (SchemaException | SystemException e) {
// See MID-6446 - we want to throw in tests, old ones should be fixed by now
if (InternalsConfig.isConsistencyChecks()) {
throw new SystemException("Problem during audit delta parse", e);
}
LOGGER.warn("Serialized audit delta for recordId={} cannot be parsed." + " No changed items were created. This may cause problem later, but is not" + " critical for storing the audit record.", recordId, e);
}
}
if (!changedItemPaths.isEmpty()) {
QAuditItem qAuditItem = QAuditItemMapping.get().defaultAlias();
SQLInsertClause insertBatch = jdbcSession.newInsert(qAuditItem);
for (String changedItemPath : changedItemPaths) {
insertBatch.set(qAuditItem.recordId, recordId).set(qAuditItem.changedItemPath, changedItemPath).addBatch();
}
insertBatch.setBatchToBulk(true);
insertBatch.execute();
}
}
use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class SqaleAuditService method insertReferences.
private void insertReferences(JdbcSession jdbcSession, MAuditEventRecord auditRow, Map<String, Set<AuditReferenceValue>> references) {
if (references.isEmpty()) {
return;
}
QAuditRefValue qr = QAuditRefValueMapping.get().defaultAlias();
SQLInsertClause insertBatch = jdbcSession.newInsert(qr);
for (String refName : references.keySet()) {
for (AuditReferenceValue refValue : references.get(refName)) {
// id will be generated, but we're not interested in those here
PolyString targetName = refValue.getTargetName();
insertBatch.set(qr.recordId, auditRow.id).set(qr.timestamp, auditRow.timestamp).set(qr.name, refName).set(qr.targetOid, SqaleUtils.oidToUUid(refValue.getOid())).set(qr.targetType, refValue.getType() != null ? MObjectType.fromTypeQName(refValue.getType()) : null).set(qr.targetNameOrig, PolyString.getOrig(targetName)).set(qr.targetNameNorm, PolyString.getNorm(targetName)).addBatch();
}
}
if (insertBatch.getBatchCount() == 0) {
// strange, no values anywhere?
return;
}
insertBatch.setBatchToBulk(true);
insertBatch.execute();
}
use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class AuditInsertion method insertReferences.
private void insertReferences(MAuditEventRecord auditRow, List<AuditEventRecordReferenceType> references) {
if (references.isEmpty()) {
return;
}
QAuditRefValue qr = QAuditRefValueMapping.get().defaultAlias();
SQLInsertClause insertBatch = jdbcSession.newInsert(qr);
for (AuditEventRecordReferenceType refSet : references) {
for (AuditEventRecordReferenceValueType refValue : refSet.getValue()) {
// id will be generated, but we're not interested in those here
PolyStringType targetName = refValue.getTargetName();
insertBatch.set(qr.recordId, auditRow.id).set(qr.timestamp, auditRow.timestamp).set(qr.name, refSet.getName()).set(qr.targetOid, SqaleUtils.oidToUUid(refValue.getOid())).set(qr.targetType, refValue.getType() != null ? MObjectType.fromTypeQName(refValue.getType()) : null).set(qr.targetNameOrig, PolyString.getOrig(targetName)).set(qr.targetNameNorm, PolyString.getNorm(targetName)).addBatch();
}
}
if (insertBatch.getBatchCount() == 0) {
// strange, no values anywhere?
return;
}
insertBatch.setBatchToBulk(true);
insertBatch.execute();
}
use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class TweetRepository method save.
@Transactional
public Long save(Tweet tweet, Long... mentions) {
Long tweetId = save(tweet);
SQLInsertClause insert = insert(tweetUser);
for (Long mentionsId : mentions) {
TweetUser tu = new TweetUser();
tu.setTweetId(tweetId);
tu.setMentionsId(mentionsId);
insert.populate(tu).addBatch();
}
insert.execute();
return tweetId;
}
Aggregations