Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Feb 26, 2015
2 parents f8a7335 + ed3e8ba commit 47675e3
Show file tree
Hide file tree
Showing 20 changed files with 553 additions and 89 deletions.
Expand Up @@ -54,6 +54,7 @@
<div class="row">
<div class="col-xs-9">
<div wicket:id="relation" />
<span wicket:id="relationLabel" />
</div>
</div>
</div>
Expand Down
Expand Up @@ -42,6 +42,7 @@
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.web.page.admin.configuration.component.ChooseTypePanel;
import com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto;
import com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus;
import com.evolveum.midpoint.web.util.WebMiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
Expand Down Expand Up @@ -97,6 +98,7 @@ public class AssignmentEditorPanel extends SimplePanel<AssignmentEditorDto> {
private static final String ID_DESCRIPTION = "description";
private static final String ID_RELATION_CONTAINER = "relationContainer";
private static final String ID_RELATION = "relation";
private static final String ID_RELATION_LABEL = "relationLabel";
private static final String ID_ADMINISTRATIVE_STATUS = "administrativeStatus";
private static final String ID_VALID_FROM = "validFrom";
private static final String ID_VALID_TO = "validTo";
Expand Down Expand Up @@ -343,8 +345,38 @@ public boolean isVisible() {
"AssignmentEditorPanel.member", "AssignmentEditorPanel.manager", null);
relation.setOutputMarkupId(true);
relation.setOutputMarkupPlaceholderTag(true);
relation.add(new VisibleEnableBehaviour(){

@Override
public boolean isVisible() {
return isCreatingNewAssignment();
}
});
relationContainer.add(relation);

Label relationLabel = new Label(ID_RELATION_LABEL, new AbstractReadOnlyModel<String>() {

@Override
public String getObject() {
if(getModel() == null || getModel().getObject() == null){
return getString("AssignmentEditorPanel.relation.notSpecified");
}

AssignmentEditorDto object = getModel().getObject();
return object.isOrgUnitManager() ? getString("AssignmentEditorPanel.manager") : getString("AssignmentEditorPanel.member");
}
});
relationLabel.setOutputMarkupId(true);
relationLabel.setOutputMarkupPlaceholderTag(true);
relationLabel.add(new VisibleEnableBehaviour(){

@Override
public boolean isVisible() {
return !isCreatingNewAssignment();
}
});
relationContainer.add(relationLabel);

WebMarkupContainer tenantRefContainer = new WebMarkupContainer(ID_CONTAINER_TENANT_REF);
ChooseTypePanel tenantRef = new ChooseTypePanel(ID_TENANT_CHOOSER,
new PropertyModel<ObjectViewDto>(getModel(), AssignmentEditorDto.F_TENANT_REF)){
Expand Down Expand Up @@ -738,4 +770,16 @@ private void showErrorPerformed(AjaxRequestTarget target){
error(getString("AssignmentEditorPanel.targetError"));
target.add(getPageBase().getFeedbackPanel());
}

/**
* Override to provide the information if object that contains this assignment
* is being edited or created.
* */
protected boolean isCreatingNewAssignment(){
if(getModelObject() == null){
return false;
}

return UserDtoStatus.ADD.equals(getModelObject().getStatus());
}
}
Expand Up @@ -28,6 +28,7 @@ AssignmentEditorPanel.tenantRef=Tenant
AssignmentEditorPanel.name.focus=(focus mapping)
AssignmentEditorPanel.name.noTarget=(no target)
AssignmentEditorPanel.showMore=Show more
AssignmentEditorPanel.relation.notSpecified="Not specified"
AssignmentEditorPanel.member=Member
AssignmentEditorPanel.manager=Manager
AssignmentEditorPanel.targetError=Assignment target was not found. Either target oid is malformed or target object does not exist.
Expand Down
Expand Up @@ -149,7 +149,7 @@ protected IModel<String> createPageTitleModel(){

@Override
protected String load() {
if(!isEditing()){
if(!isEditingRole()){
return createStringResource("PageRoleEditor.title.newRole").getObject();
}

Expand All @@ -164,7 +164,7 @@ protected IModel<String> createPageSubTitleModel(){

@Override
protected String load() {
if(!isEditing()){
if(!isEditingRole()){
return createStringResource("PageRoleEditor.subtitle.newRole").getObject();
}

Expand All @@ -179,7 +179,7 @@ private PrismObject<RoleType> loadRole(){

PrismObject<RoleType> role = null;
try {
if (!isEditing()) {
if (!isEditingRole()) {
RoleType r = new RoleType();
ActivationType defaultActivation = new ActivationType();
defaultActivation.setAdministrativeStatus(ActivationStatusType.ENABLED);
Expand Down Expand Up @@ -211,7 +211,7 @@ private PrismObject<RoleType> loadRole(){

private ContainerWrapper loadRoleWrapper(){
OperationResult result = new OperationResult(OPERATION_CREATE_ROLE_WRAPPER);
ContainerStatus status = isEditing() ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
ContainerStatus status = isEditingRole() ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
ObjectWrapper wrapper = null;
ContainerWrapper extensionContainer = null;
PrismObject<RoleType> role = model.getObject();
Expand Down Expand Up @@ -241,7 +241,7 @@ private ContainerWrapper loadRoleWrapper(){
return extensionContainer;
}

private boolean isEditing(){
private boolean isEditingRole(){
StringValue oid = getPageParameters().get(OnePageParameterEncoder.PARAMETER);
return oid != null && StringUtils.isNotEmpty(oid.toString());
}
Expand Down Expand Up @@ -440,7 +440,7 @@ private void savePerformed(AjaxRequestTarget target){
PrismObject<RoleType> newRole = model.getObject();

delta = null;
if (!isEditing()) {
if (!isEditingRole()) {

//handle assignments
PrismObjectDefinition orgDef = newRole.getDefinition();
Expand Down Expand Up @@ -478,7 +478,7 @@ private void savePerformed(AjaxRequestTarget target){
ObjectDelta extDelta = null;

if(extensionDelta != null){
if(isEditing()){
if(isEditingRole()){
extDelta = extensionDelta;
} else {
extDelta = delta.getObjectToAdd().diff(extensionDelta.getObjectToAdd());
Expand Down
Expand Up @@ -206,7 +206,7 @@ protected ContainerWrapper load() {
}
};

//status = isEditing() ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
//status = isEditingOrgUnit() ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;

initLayout();
}
Expand All @@ -217,7 +217,7 @@ protected IModel<String> createPageTitleModel() {

@Override
protected String load() {
if (!isEditing()) {
if (!isEditingOrgUnit()) {
return PageOrgUnit.super.createPageTitleModel().getObject();
}

Expand All @@ -229,7 +229,7 @@ protected String load() {

private ContainerWrapper loadExtensionWrapper(){
OperationResult result = new OperationResult(OPERATION_LOAD_EXTENSION_WRAPPER);
ContainerStatus status = isEditing() ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
ContainerStatus status = isEditingOrgUnit() ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
ObjectWrapper wrapper;
ContainerWrapper extensionWrapper = null;
PrismObject<OrgType> org = orgModel.getObject();
Expand Down Expand Up @@ -376,7 +376,7 @@ protected ObjectQuery createChooseQuery(){
}
}

if(isEditing()){
if(isEditingOrgUnit()){
oidList.add(orgModel.getObject().asObjectable().getOid());
}

Expand Down Expand Up @@ -533,7 +533,7 @@ public void onClick(AjaxRequestTarget target) {
form.add(new ExecuteChangeOptionsPanel(ID_EXECUTE_OPTIONS, executeOptionsModel, true, false)); // TODO add "show reconcile affected" when implemented for Orgs
}

private boolean isEditing() {
private boolean isEditingOrgUnit() {
StringValue oid = getPageParameters().get(OnePageParameterEncoder.PARAMETER);
return oid != null && StringUtils.isNotEmpty(oid.toString());
}
Expand Down Expand Up @@ -595,7 +595,7 @@ private PrismObject<OrgType> buildUnitFromModel(List<ObjectReferenceType> parent
}

//Delete parentOrgUnits from edited OrgUnit
if(isEditing()){
if(isEditingOrgUnit()){
if(parentOrgUnitsModel != null && parentOrgUnitsModel.getObject() != null){
for(ObjectReferenceType parent: parentOrgList){
if(!isRefInParentOrgModel(parent)){
Expand Down Expand Up @@ -636,7 +636,7 @@ private void savePerformed(AjaxRequestTarget target) {
reviveModels();
delta = null;

if (!isEditing()) {
if (!isEditingOrgUnit()) {
newOrgUnit = buildUnitFromModel(null);

//handle assignments
Expand Down Expand Up @@ -674,7 +674,7 @@ private void savePerformed(AjaxRequestTarget target) {
ObjectDelta extDelta = null;

if(extensionDelta != null){
if(isEditing()){
if(isEditingOrgUnit()){
extDelta = extensionDelta;
} else {
extDelta = delta.getObjectToAdd().diff(extensionDelta.getObjectToAdd());
Expand Down Expand Up @@ -748,7 +748,7 @@ private PrismObject<OrgType> loadOrgUnit(PrismObject<OrgType> unitToEdit) {

PrismObject<OrgType> org = null;
try {
if (!isEditing()) {
if (!isEditingOrgUnit()) {
if (unitToEdit == null) {
OrgType o = new OrgType();
ActivationType defaultActivation = new ActivationType();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2015 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceActivationDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectAssociationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
Expand Down Expand Up @@ -615,8 +616,13 @@ public void add(RefinedAttributeDefinition refinedAttributeDefinition) {
public void parseAssociations(RefinedResourceSchema rSchema) {
throw new UnsupportedOperationException();
}

@Override
public ResourceObjectReferenceType getBaseContext() {
return refinedObjectClassDefinition.getBaseContext();
}

@Override
protected String debugDump(int indent, LayerType layer) {
return refinedObjectClassDefinition.debugDump(indent, layer);
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2015 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,9 @@
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.Trace;
Expand Down Expand Up @@ -69,6 +71,7 @@ public class RefinedObjectClassDefinition extends ObjectClassComplexTypeDefiniti
private Collection<ResourceObjectPattern> protectedObjectPatterns;
private List<RefinedAttributeDefinition> attributeDefinitions;
private Collection<RefinedAssociationDefinition> associations = new ArrayList<RefinedAssociationDefinition>();
private ResourceObjectReferenceType baseContext;

/**
* Refined object definition. The "any" parts are replaced with appropriate schema (e.g. resource schema)
Expand Down Expand Up @@ -352,7 +355,15 @@ public PrismObjectDefinition<ShadowType> getObjectDefinition() {
return objectDefinition;
}

private void constructObjectDefinition() {
public ResourceObjectReferenceType getBaseContext() {
return baseContext;
}

public void setBaseContext(ResourceObjectReferenceType baseContext) {
this.baseContext = baseContext;
}

private void constructObjectDefinition() {
// Almost-shallow clone of object definition and complex type
PrismObjectDefinition<ShadowType> originalObjectDefinition =
getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class);
Expand Down Expand Up @@ -537,6 +548,10 @@ private static RefinedObjectClassDefinition parseRefinedObjectClass(ResourceObje
rOcDef.setDefault(objectClassDef.isDefaultInAKind());
}

if (schemaHandlingObjDefType.getBaseContext() != null) {
rOcDef.setBaseContext(schemaHandlingObjDefType.getBaseContext());
}

for (ResourceAttributeDefinition road : objectClassDef.getAttributeDefinitions()) {
String attrContextDescription = road.getName() + ", in " + contextDescription;
ResourceAttributeDefinitionType attrDefType = findAttributeDefinitionType(road.getName(), schemaHandlingObjDefType,
Expand Down Expand Up @@ -761,6 +776,37 @@ public AttributeFetchStrategyType getActivationFetchStrategy(QName propertyName)
return biType.getFetchStrategy();
}

public static RefinedObjectClassDefinition determineObjectClassDefinition(PrismObject<ShadowType> shadow, ResourceType resource) throws SchemaException, ConfigurationException {
ShadowType shadowType = shadow.asObjectable();
RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource, resource.asPrismObject().getPrismContext());
if (refinedSchema == null) {
throw new ConfigurationException("No schema defined for "+resource);
}


RefinedObjectClassDefinition objectClassDefinition = null;
ShadowKindType kind = shadowType.getKind();
String intent = shadowType.getIntent();
QName objectClass = shadow.asObjectable().getObjectClass();
if (kind != null) {
objectClassDefinition = refinedSchema.getRefinedDefinition(kind, intent);
}
if (objectClassDefinition == null) {
// Fallback to objectclass only
if (objectClass == null) {
throw new SchemaException("No kind nor objectclass definied in "+shadow);
}
objectClassDefinition = refinedSchema.findRefinedDefinitionByObjectClassQName(kind, objectClass);
}

if (objectClassDefinition == null) {
throw new SchemaException("Definition for "+shadow+" not found (objectClass=" + PrettyPrinter.prettyPrint(objectClass) +
", kind="+kind+", intent='"+intent+"') in schema of " + resource);
}

return objectClassDefinition;
}

public boolean matches(ShadowType shadowType) {
if (shadowType == null) {
return false;
Expand Down
@@ -0,0 +1,43 @@
/**
* Copyright (c) 2015 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.schema.processor;

import java.util.Collection;

/**
* @author semancik
*
*/
public class ResourceObjectIdentification {

private ObjectClassComplexTypeDefinition objectClassDefinition;
private Collection<? extends ResourceAttribute<?>> identifiers;
// TODO: identification strategy

public ResourceObjectIdentification(ObjectClassComplexTypeDefinition objectClassDefinition, Collection<? extends ResourceAttribute<?>> identifiers) {
this.objectClassDefinition = objectClassDefinition;
this.identifiers = identifiers;
}

public Collection<? extends ResourceAttribute<?>> getIdentifiers() {
return identifiers;
}

public ObjectClassComplexTypeDefinition getObjectClassDefinition() {
return objectClassDefinition;
}

}

0 comments on commit 47675e3

Please sign in to comment.