use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.
the class RAnyConverter method convertToRValue.
//todo assignment parameter really messed up this method, proper interfaces must be introduced later [lazyman]
public Set<RAnyValue> convertToRValue(Item item, boolean assignment) throws DtoTranslationException {
Validate.notNull(item, "Object for converting must not be null.");
Validate.notNull(item.getDefinition(), "Item '" + item.getElementName() + "' without definition can't be saved.");
ItemDefinition definition = item.getDefinition();
Set<RAnyValue> rValues = new HashSet<>();
if (!isIndexed(definition, prismContext)) {
return rValues;
}
try {
RAnyValue rValue;
List<PrismValue> values = item.getValues();
for (PrismValue value : values) {
if (value instanceof PrismPropertyValue) {
PrismPropertyValue propertyValue = (PrismPropertyValue) value;
//todo omg, do something with this!!! [lazyman]
switch(getValueType(definition.getTypeName())) {
case BOOLEAN:
{
Boolean repoValue = extractValue(propertyValue, Boolean.class);
if (assignment) {
rValue = new RAExtBoolean(repoValue);
} else {
rValue = new ROExtBoolean(repoValue);
}
break;
}
case LONG:
{
Long repoValue = extractValue(propertyValue, Long.class);
if (assignment) {
rValue = new RAExtLong(repoValue);
} else {
rValue = new ROExtLong(repoValue);
}
break;
}
case DATE:
{
Timestamp repoValue = extractValue(propertyValue, Timestamp.class);
if (assignment) {
rValue = new RAExtDate(repoValue);
} else {
rValue = new ROExtDate(repoValue);
}
break;
}
case POLY_STRING:
{
PolyString repoValue = extractValue(propertyValue, PolyString.class);
if (assignment) {
rValue = new RAExtPolyString(repoValue);
} else {
rValue = new ROExtPolyString(repoValue);
}
break;
}
case STRING:
default:
{
String repoValue = extractValue(propertyValue, String.class);
if (assignment) {
rValue = new RAExtString(repoValue);
} else {
rValue = new ROExtString(repoValue);
}
}
}
} else if (value instanceof PrismReferenceValue) {
if (assignment) {
PrismReferenceValue referenceValue = (PrismReferenceValue) value;
rValue = RAExtReference.createReference(referenceValue);
} else {
PrismReferenceValue referenceValue = (PrismReferenceValue) value;
rValue = ROExtReference.createReference(referenceValue);
}
} else if (value == null) {
// shouldn't occur anyway
continue;
} else {
// shouldn't get here because if isIndexed test above
throw new AssertionError("Wrong value type: " + value);
}
rValue.setName(RUtil.qnameToString(definition.getName()));
rValue.setType(RUtil.qnameToString(definition.getTypeName()));
rValue.setValueType(getValueType(value.getParent()));
rValue.setDynamic(definition.isDynamic());
rValues.add(rValue);
}
} catch (Exception ex) {
throw new DtoTranslationException("Exception when translating " + item + ": " + ex.getMessage(), ex);
}
return rValues;
}
use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.
the class ROperationalState method fromJaxb.
public static void fromJaxb(OperationalStateType jaxb, ROperationalState repo) throws DtoTranslationException {
Objects.requireNonNull(repo, "Repo object must not be null.");
Objects.requireNonNull(jaxb, "JAXB object must not be null.");
try {
if (jaxb.getLastAvailabilityStatus() != null) {
repo.setLastAvailabilityStatus(RUtil.getRepoEnumValue(jaxb.getLastAvailabilityStatus(), RAvailabilityStatus.class));
}
} catch (Exception ex) {
throw new DtoTranslationException(ex.getMessage(), ex);
}
}
use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.
the class ActivationMapper method map.
@Override
public RActivation map(ActivationType input, MapperContext context) {
try {
RActivation ractivation = new RActivation();
RActivation.fromJaxb(input, ractivation);
return ractivation;
} catch (DtoTranslationException ex) {
throw new SystemException("Couldn't translate activation to entity", ex);
}
}
use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.
the class CaseWorkItemMapper method map.
@Override
public RCaseWorkItem map(CaseWorkItemType input, MapperContext context) {
RCase owner = (RCase) context.getOwner();
RCaseWorkItem item;
try {
item = RCaseWorkItem.toRepo(owner, input, context.getRepositoryContext());
} catch (DtoTranslationException ex) {
throw new SystemException("Couldn't translate CaseWorkItemType to entity", ex);
}
return item;
}
use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.
the class RResource method copyFromJAXB.
// dynamically called
public static void copyFromJAXB(ResourceType jaxb, RResource repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException {
copyAssignmentHolderInformationFromJAXB(jaxb, repo, repositoryContext, generatorResult);
repo.setNameCopy(RPolyString.copyFromJAXB(jaxb.getName()));
repo.setConnectorRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getConnectorRef(), repositoryContext.relationRegistry));
try {
if (jaxb.getBusiness() != null) {
ResourceBusinessConfigurationType business = jaxb.getBusiness();
repo.getApproverRef().addAll(RUtil.toRObjectReferenceSet(business.getApproverRef(), repo, RReferenceType.RESOURCE_BUSINESS_CONFIGURATION_APPROVER, repositoryContext.relationRegistry));
repo.setAdministrativeState(RUtil.getRepoEnumValue(business.getAdministrativeState(), RResourceAdministrativeState.class));
}
if (jaxb.getOperationalState() != null) {
ROperationalState repoOpState = new ROperationalState();
ROperationalState.fromJaxb(jaxb.getOperationalState(), repoOpState);
repo.setOperationalState(repoOpState);
}
} catch (Exception ex) {
throw new DtoTranslationException(ex.getMessage(), ex);
}
}
Aggregations