Skip to content

Commit

Permalink
Set default case name for manual case creation
Browse files Browse the repository at this point in the history
  • Loading branch information
bpowers1215 committed Oct 26, 2017
1 parent 35a408a commit ee7aea5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
Expand Up @@ -288,9 +288,9 @@ private List<ItemWrapper> createProperties(ContainerWrapper cWrapper, OperationR
} else { // if not an assignment
//hack for CaseWorkItemType as a quick fix; in further versions there is already implemented
//functionality for multivalue containers
if ((container.getValues().size() == 1 || container.getValues().isEmpty())
&& (containerDefinition == null || containerDefinition.isSingleValue() ||
CaseWorkItemType.class.isAssignableFrom(container.getCompileTimeClass()))) {
if (((container.getValues().size() == 1 || container.getValues().isEmpty())
&& (containerDefinition == null || containerDefinition.isSingleValue())) ||
(container.getValues().size() == 1 && CaseWorkItemType.class.isAssignableFrom(container.getCompileTimeClass()))){

// there's no point in showing properties for non-single-valued
// parent containers,
Expand Down
Expand Up @@ -8,6 +8,7 @@
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.OidUtil;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.LoggingUtils;
Expand All @@ -24,6 +25,7 @@
import com.evolveum.midpoint.web.resource.img.ImgResources;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -90,8 +92,6 @@ private ObjectWrapper<CaseType> loadCase() {
if (emptyCase) {
LOGGER.trace("Loading case: New case (creating)");
CaseType newCase = new CaseType();
//CaseWorkItemType newCaseWorkItem = new CaseWorkItemType();
newCase.beginWorkItem();
getMidpointApplication().getPrismContext().adopt(newCase);
caseInstance = newCase.asPrismObject();
} else {
Expand Down Expand Up @@ -175,11 +175,9 @@ protected void onError(AjaxRequestTarget target, Form<?> form) {
}

private String getObjectOidParameter() {
LOGGER.debug("PAGE CASE getObjectOidParameter");
PageParameters parameters = getPageParameters();
LOGGER.trace("Page parameters: {}", parameters);
StringValue oidValue = getPageParameters().get(OnePageParameterEncoder.PARAMETER);
LOGGER.trace("OID parameter: {}", oidValue);

if (oidValue == null) {
return null;
}
Expand All @@ -191,7 +189,6 @@ private String getObjectOidParameter() {
}

private boolean isEditingFocus() {
LOGGER.debug("PAGE CASE isEditingFocus");
return getObjectOidParameter() != null;
}

Expand All @@ -209,10 +206,13 @@ private void savePerformed(AjaxRequestTarget target) {
}
if (delta.isAdd()) {
CaseType object = delta.getObjectToAdd().asObjectable();
createCaseWorkItems(object, task, result);
if (object.getName() == null || object.getName().getOrig().isEmpty()) {
object.setName(new PolyStringType(OidUtil.generateOid()));
}
if (object.getState() == null || object.getState().isEmpty()) {
object.setState("open");
}
createCaseWorkItems(object, task, result);
}
if (delta.getPrismContext() == null) {
getPrismContext().adopt(delta);
Expand Down
Expand Up @@ -3703,6 +3703,11 @@ CaseType.closeTimestamp=Close Timestamp
CaseType.event=Event
CaseType.workItem=Work Item
CaseType.jpegPhoto=Proof
AbstractWorkItemType.assigneeRef=Assignee
AbstractWorkItemType.originalAssigneeRef=Original Assignee
AbstractWorkItemType.deadline=Deadline
AbstractWorkItemType.performerRef=Performer
AbstractWorkItemType.closeTimestamp=Closed
PageUserHistory.title='{0}' historical data {1}
PageXmlDataReview.title=Historical data
PageXmlDataReview.aceEditorPanelTitle='{0}' historical xml data {1}
Expand Down
Expand Up @@ -196,6 +196,7 @@
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
<a:displayName>AbstractWorkItemType.deadline</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand All @@ -207,6 +208,7 @@
<!-- TODO allow also roles/orgs here. -->
<xsd:appinfo>
<a:objectReferenceTargetType>tns:UserType</a:objectReferenceTargetType>
<a:displayName>AbstractWorkItemType.originalAssigneeRef</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand All @@ -220,6 +222,7 @@
<!-- TODO allow also roles/orgs here. -->
<xsd:appinfo>
<a:objectReferenceTargetType>tns:UserType</a:objectReferenceTargetType>
<a:displayName>AbstractWorkItemType.assigneeRef</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand All @@ -240,6 +243,7 @@
</xsd:documentation>
<xsd:appinfo>
<a:objectReferenceTargetType>tns:UserType</a:objectReferenceTargetType>
<a:displayName>AbstractWorkItemType.performerRef</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand All @@ -262,6 +266,9 @@
<xsd:documentation>
When was this work item closed. (If null, it is considered open.)
</xsd:documentation>
<xsd:appinfo>
<a:displayName>AbstractWorkItemType.closeTimestamp</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
Expand Down

0 comments on commit ee7aea5

Please sign in to comment.