Skip to content

Commit

Permalink
RObjectDeltaOperation#fromRepo methods marked with @NotNull
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Mar 12, 2020
1 parent f01d921 commit f323091
Showing 1 changed file with 16 additions and 21 deletions.
Expand Up @@ -7,6 +7,14 @@

package com.evolveum.midpoint.repo.sql.data.audit;

import static com.evolveum.midpoint.repo.sql.data.audit.RObjectDeltaOperation.COLUMN_RECORD_ID;

import java.sql.ResultSet;
import javax.persistence.*;

import org.hibernate.annotations.ForeignKey;
import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.polystring.PolyString;
Expand All @@ -28,25 +36,14 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;

import org.hibernate.annotations.ForeignKey;

import javax.persistence.*;

import static com.evolveum.midpoint.repo.sql.data.audit.RObjectDeltaOperation.COLUMN_RECORD_ID;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
* @author lazyman
*/
@Ignore
@Entity
@IdClass(RObjectDeltaOperationId.class)
@Table(name = RObjectDeltaOperation.TABLE_NAME, indexes = {
@Index(name = "iAuditDeltaRecordId", columnList = COLUMN_RECORD_ID)})
@Index(name = "iAuditDeltaRecordId", columnList = COLUMN_RECORD_ID) })
public class RObjectDeltaOperation implements OperationResultFull, EntityState {

private static final long serialVersionUID = -1065600513263271161L;
Expand Down Expand Up @@ -86,7 +83,6 @@ public class RObjectDeltaOperation implements OperationResultFull, EntityState {
private String resourceOid;
private RPolyString resourceName;


@ForeignKey(name = "none")
@MapsId("record")
@ManyToOne(fetch = FetchType.LAZY)
Expand Down Expand Up @@ -265,7 +261,7 @@ public int hashCode() {
}

public static RObjectDeltaOperation toRepo(RAuditEventRecord record, ObjectDeltaOperation operation,
PrismContext prismContext) throws DtoTranslationException {
PrismContext prismContext) throws DtoTranslationException {
RObjectDeltaOperation auditDelta = new RObjectDeltaOperation();
auditDelta.setRecord(record);

Expand Down Expand Up @@ -294,7 +290,6 @@ public static RObjectDeltaOperation toRepo(RAuditEventRecord record, ObjectDelta
throw new DtoTranslationException(ex.getMessage(), ex);
}


return auditDelta;
}

Expand Down Expand Up @@ -339,15 +334,15 @@ public static SingleSqlQuery toRepo(Long recordId, ObjectDeltaOperation operatio
queryBuilder.addNullParameter(STATUS_COLUMN_NAME);
queryBuilder.addNullParameter(FULL_RESULT_COLUMN_NAME);
}
if(operation.getObjectName() != null) {
if (operation.getObjectName() != null) {
queryBuilder.addParameter(OBJECT_NAME_ORIG_COLUMN_NAME, operation.getObjectName().getOrig());
queryBuilder.addParameter(OBJECT_NAME_NORM_COLUMN_NAME, operation.getObjectName().getNorm());
} else {
queryBuilder.addNullParameter(OBJECT_NAME_ORIG_COLUMN_NAME);
queryBuilder.addNullParameter(OBJECT_NAME_NORM_COLUMN_NAME);
}
queryBuilder.addParameter(RESOURCE_OID_COLUMN_NAME, operation.getResourceOid());
if(operation.getResourceName() != null) {
if (operation.getResourceName() != null) {
queryBuilder.addParameter(RESOURCE_NAME_ORIG_COLUMN_NAME, operation.getResourceName().getOrig());
queryBuilder.addParameter(RESOURCE_NAME_NORM_COLUMN_NAME, operation.getResourceName().getNorm());
} else {
Expand All @@ -359,10 +354,10 @@ public static SingleSqlQuery toRepo(Long recordId, ObjectDeltaOperation operatio
throw new DtoTranslationException(ex.getMessage(), ex);
}


return queryBuilder.build();
}

@NotNull
public static ObjectDeltaOperation fromRepo(RObjectDeltaOperation operation, PrismContext prismContext, boolean useUtf16)
throws DtoTranslationException {

Expand Down Expand Up @@ -392,6 +387,7 @@ public static ObjectDeltaOperation fromRepo(RObjectDeltaOperation operation, Pri
return odo;
}

@NotNull
public static ObjectDeltaOperation fromRepo(ResultSet resultSet, PrismContext prismContext, boolean useUtf16)
throws DtoTranslationException {

Expand All @@ -411,11 +407,11 @@ public static ObjectDeltaOperation fromRepo(ResultSet resultSet, PrismContext pr
OperationResultType resultType = prismContext.parserFor(xmlResult).parseRealValue(OperationResultType.class);
odo.setExecutionResult(OperationResult.createOperationResult(resultType));
}
if(resultSet.getString(OBJECT_NAME_ORIG_COLUMN_NAME) != null || resultSet.getString(OBJECT_NAME_NORM_COLUMN_NAME) != null) {
if (resultSet.getString(OBJECT_NAME_ORIG_COLUMN_NAME) != null || resultSet.getString(OBJECT_NAME_NORM_COLUMN_NAME) != null) {
odo.setObjectName(new PolyString(resultSet.getString(OBJECT_NAME_ORIG_COLUMN_NAME), resultSet.getString(OBJECT_NAME_NORM_COLUMN_NAME)));
}
odo.setResourceOid(resultSet.getString(RESOURCE_OID_COLUMN_NAME));
if(resultSet.getString(RESOURCE_NAME_ORIG_COLUMN_NAME) != null || resultSet.getString(RESOURCE_NAME_NORM_COLUMN_NAME) != null) {
if (resultSet.getString(RESOURCE_NAME_ORIG_COLUMN_NAME) != null || resultSet.getString(RESOURCE_NAME_NORM_COLUMN_NAME) != null) {
odo.setResourceName(new PolyString(resultSet.getString(RESOURCE_NAME_ORIG_COLUMN_NAME), resultSet.getString(RESOURCE_NAME_NORM_COLUMN_NAME)));
}
} catch (Exception ex) {
Expand All @@ -424,5 +420,4 @@ public static ObjectDeltaOperation fromRepo(ResultSet resultSet, PrismContext pr

return odo;
}

}

0 comments on commit f323091

Please sign in to comment.