List of usage examples for javax.xml.namespace QName getLocalPart
public String getLocalPart()
Get the local part of this QName
.
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public <C extends Containerable> PrismContainerDefinition<C> findContainerDefinitionByElementName( QName elementName) { if (StringUtils.isEmpty(elementName.getNamespaceURI())) { return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), PrismContainerDefinition.class); }// w w w .j a v a2 s . c o m PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI()); if (schema == null) { return null; } return schema.findContainerDefinitionByElementName(elementName); }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public ItemDefinition findItemDefinitionByType(QName typeName) { if (StringUtils.isEmpty(typeName.getNamespaceURI())) { ComplexTypeDefinition ctd = resolveGlobalTypeDefinitionWithoutNamespace(typeName.getLocalPart()); typeName = ctd.getTypeName();// w w w . jav a 2 s . c om } PrismSchema schema = findSchemaByNamespace(typeName.getNamespaceURI()); if (schema == null) { return null; } return schema.findItemDefinitionByType(typeName, ItemDefinition.class); }
From source file:com.evolveum.midpoint.web.component.wizard.resource.SchemaHandlingStep.java
private Iterator<String> getObjectClassChoices(String input) { List<QName> resourceObjectClassList = schemaHandlingDtoModel.getObject().getObjectClassList(); List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE); if (Strings.isEmpty(input)) { for (QName q : resourceObjectClassList) { choices.add(q.getLocalPart()); if (choices.size() == AUTO_COMPLETE_LIST_SIZE) { break; }/*from w ww .j a va 2s.c o m*/ } return choices.iterator(); } for (QName q : resourceObjectClassList) { if (q.getLocalPart().toLowerCase().startsWith(input.toLowerCase())) { choices.add(q.getLocalPart()); if (choices.size() == AUTO_COMPLETE_LIST_SIZE) { break; } } } return choices.iterator(); }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public <T> Class<T> determineCompileTimeClass(QName typeName) { if (StringUtils.isEmpty(typeName.getNamespaceURI())) { ComplexTypeDefinition ctd = resolveGlobalTypeDefinitionWithoutNamespace(typeName.getLocalPart()); return (Class) ctd.getCompileTimeClass(); }//from w ww .ja v a2 s . co m SchemaDescription desc = findSchemaDescriptionByNamespace(typeName.getNamespaceURI()); if (desc == null) { return null; } Package pkg = desc.getCompileTimeClassesPackage(); if (pkg == null) { return null; } Class<T> compileTimeClass = JAXBUtil.findClassForType(typeName, pkg); return compileTimeClass; }
From source file:com.evolveum.midpoint.web.component.wizard.resource.SchemaHandlingStep.java
@NotNull private String getExpression(QName property) { return SchemaHandlingDto.F_SELECTED_OBJECT_TYPE_DTO + ".objectType." + property.getLocalPart(); }
From source file:com.collabnet.ccf.teamforge.TFTrackerHandler.java
/** * Updates the artifact if conflict resolution priority allows it * //from ww w .ja v a2 s. c o m * @param ga * generic artifact passed to the update method * @param sessionId * @param trackerId * @param description * @param category * @param group * @param status * @param statusClass * @param customer * @param priority * @param estimatedEfforts * @param actualEfforts * @param closeDate * @param assignedTo * @param reportedReleaseId * @param resolvedReleaseId * @param flexFieldNames * @param flexFieldValues * @param flexFieldTypes * @param flexFieldPreserve * @param title * @param Id * @param comments * @param newParentId * @param associateWithParent * @param currentParentId * @param deleteOldParentAssociation * @param packageReleaseSeparatorString * @param conflictResolutionPriority * @return updated artifact or null if conflict resolution has decided not * to update the artifact * @throws RemoteException * @throws PlanningFolderRuleViolationException */ public ArtifactDO updateArtifact(GenericArtifact ga, Connection connection, GenericArtifactField trackerId, GenericArtifactField description, GenericArtifactField category, GenericArtifactField group, GenericArtifactField status, GenericArtifactField statusClass, GenericArtifactField customer, GenericArtifactField priority, GenericArtifactField estimatedEfforts, GenericArtifactField actualEfforts, GenericArtifactField closeDate, GenericArtifactField assignedTo, GenericArtifactField reportedReleaseId, GenericArtifactField resolvedReleaseId, List<String> flexFieldNames, List<Object> flexFieldValues, List<String> flexFieldTypes, Set<String> overriddenFlexFields, GenericArtifactField title, String Id, String[] comments, boolean translateTechnicalReleaseIds, GenericArtifactField remainingEfforts, GenericArtifactField autosumming, GenericArtifactField storyPoints, GenericArtifactField planningFolderId, boolean deleteOldParentAssociation, String currentParentId, boolean associateWithParent, String newParentId, String packageReleaseSeparatorString) throws RemoteException, PlanningFolderRuleViolationException { boolean mainArtifactNotUpdated = true; boolean oldParentRemoved = false; ArtifactDO artifactData = null; while (mainArtifactNotUpdated) { try { mainArtifactNotUpdated = false; artifactData = connection.getTrackerClient().getArtifactData(Id); // do conflict resolution if (!AbstractWriter.handleConflicts(artifactData.getVersion(), ga)) { return null; } if (deleteOldParentAssociation && !oldParentRemoved) { removeArtifactDependency(connection, currentParentId, Id); oldParentRemoved = true; } // here we store the values which will be really sent ArrayList<String> finalFlexFieldNames = new ArrayList<String>(); ArrayList<String> finalFlexFieldTypes = new ArrayList<String>(); ArrayList<Object> finalFlexFieldValues = new ArrayList<Object>(); FieldValues currentFlexFields = artifactData.getFlexFields(); String[] currentFlexFieldNames = currentFlexFields.getNames(); Object[] currentFlexFieldValues = currentFlexFields.getValues(); String[] currentFlexFieldTypes = currentFlexFields.getTypes(); // first we filter out all current flex fields that should be // overridden for (int i = 0; i < currentFlexFieldNames.length; ++i) { if (!overriddenFlexFields.contains(currentFlexFieldNames[i])) { finalFlexFieldNames.add(currentFlexFieldNames[i]); finalFlexFieldTypes.add(currentFlexFieldTypes[i]); finalFlexFieldValues.add(currentFlexFieldValues[i]); } } // now we have to add all anticipated flex fields finalFlexFieldNames.addAll(flexFieldNames); finalFlexFieldValues.addAll(flexFieldValues); finalFlexFieldTypes.addAll(flexFieldTypes); FieldValues flexFields = new FieldValues(); flexFields.setNames(finalFlexFieldNames.toArray(new String[0])); flexFields.setValues(finalFlexFieldValues.toArray()); flexFields.setTypes(finalFlexFieldTypes.toArray(new String[0])); // we need this property to determine whether we may update the // efforts fields boolean autoSummingTurnedOn = artifactData.getAutosumming(); if (autosumming != null && autosumming.getFieldValueHasChanged()) { Object fieldValueObj = autosumming.getFieldValue(); Boolean fieldValue = false; if (fieldValueObj instanceof String) { String fieldValueString = (String) fieldValueObj; fieldValue = Boolean.parseBoolean(fieldValueString); } else if (fieldValueObj instanceof Boolean) { fieldValue = (Boolean) fieldValueObj; } autoSummingTurnedOn = fieldValue; artifactData.setAutosumming(fieldValue); } // check if we do not support the autosumming flag at all if (!connection.supports53()) { autoSummingTurnedOn = false; } String folderIdString = artifactData.getFolderId(); if (trackerId != null && trackerId.getFieldValueHasChanged()) { folderIdString = (String) trackerId.getFieldValue(); artifactData.setFolderId(folderIdString); } if (title != null && title.getFieldValueHasChanged()) { artifactData.setTitle((String) title.getFieldValue()); } if (description != null && description.getFieldValueHasChanged()) { artifactData.setDescription((String) description.getFieldValue()); } if (group != null && group.getFieldValueHasChanged()) { artifactData.setGroup((String) group.getFieldValue()); } if (category != null && category.getFieldValueHasChanged()) { artifactData.setCategory((String) category.getFieldValue()); } if (status != null && status.getFieldValueHasChanged()) { artifactData.setStatus((String) status.getFieldValue()); } if (customer != null && customer.getFieldValueHasChanged()) { artifactData.setCustomer((String) customer.getFieldValue()); } if (priority != null && priority.getFieldValueHasChanged()) { Object fieldValueObj = priority.getFieldValue(); int fieldValue = 0; if (fieldValueObj instanceof String) { String fieldValueString = (String) fieldValueObj; try { fieldValue = Integer.parseInt(fieldValueString); } catch (NumberFormatException e) { throw new CCFRuntimeException( "Could not parse value of mandatory field priority: " + e.getMessage(), e); } } else if (fieldValueObj instanceof Integer) { fieldValue = ((Integer) fieldValueObj).intValue(); } artifactData.setPriority(fieldValue); } if (!autoSummingTurnedOn && estimatedEfforts != null && estimatedEfforts.getFieldValueHasChanged()) { Object fieldValueObj = estimatedEfforts.getFieldValue(); int fieldValue = 0; if (fieldValueObj instanceof String) { String fieldValueString = (String) fieldValueObj; try { fieldValue = Integer.parseInt(fieldValueString); } catch (NumberFormatException e) { throw new CCFRuntimeException( "Could not parse value of mandatory field estimatedEffort: " + e.getMessage(), e); } } else if (fieldValueObj instanceof Integer) { fieldValue = ((Integer) fieldValueObj).intValue(); } artifactData.setEstimatedEffort(fieldValue); } if (!autoSummingTurnedOn && actualEfforts != null && actualEfforts.getFieldValueHasChanged()) { Object fieldValueObj = actualEfforts.getFieldValue(); int fieldValue = 0; if (fieldValueObj instanceof String) { String fieldValueString = (String) fieldValueObj; try { fieldValue = Integer.parseInt(fieldValueString); } catch (NumberFormatException e) { throw new CCFRuntimeException( "Could not parse value of mandatory field actualEffort: " + e.getMessage(), e); } } else if (fieldValueObj instanceof Integer) { fieldValue = ((Integer) fieldValueObj).intValue(); } artifactData.setActualEffort(fieldValue); } if (!autoSummingTurnedOn && remainingEfforts != null && remainingEfforts.getFieldValueHasChanged()) { Object fieldValueObj = remainingEfforts.getFieldValue(); int fieldValue = 0; if (fieldValueObj instanceof String) { String fieldValueString = (String) fieldValueObj; try { fieldValue = Integer.parseInt(fieldValueString); } catch (NumberFormatException e) { throw new CCFRuntimeException( "Could not parse value of mandatory field remainingEffort: " + e.getMessage(), e); } } else if (fieldValueObj instanceof Integer) { fieldValue = ((Integer) fieldValueObj).intValue(); } artifactData.setRemainingEffort(fieldValue); } if (assignedTo != null && assignedTo.getFieldValueHasChanged()) { artifactData.setAssignedTo((String) assignedTo.getFieldValue()); } if (planningFolderId != null && planningFolderId.getFieldValueHasChanged()) { artifactData.setPlanningFolderId((String) planningFolderId.getFieldValue()); } if (statusClass != null && statusClass.getFieldValueHasChanged()) { artifactData.setStatusClass((String) statusClass.getFieldValue()); } if (closeDate != null && closeDate.getFieldValueHasChanged()) { Object fieldValueObj = closeDate.getFieldValue(); Date fieldValue = null; if (fieldValueObj instanceof String) { String fieldValueString = (String) fieldValueObj; fieldValue = DateUtil.parse(fieldValueString); } else if (fieldValueObj instanceof Date) { fieldValue = (Date) fieldValueObj; } artifactData.setCloseDate(fieldValue); } if (reportedReleaseId != null && reportedReleaseId.getFieldValueHasChanged()) { String reportedReleaseIdString = (String) reportedReleaseId.getFieldValue(); if (translateTechnicalReleaseIds) { reportedReleaseIdString = convertReleaseId(connection, reportedReleaseIdString, folderIdString, packageReleaseSeparatorString); } artifactData.setReportedReleaseId(reportedReleaseIdString); } if (resolvedReleaseId != null && resolvedReleaseId.getFieldValueHasChanged()) { String resolvedReleaseIdString = (String) resolvedReleaseId.getFieldValue(); if (translateTechnicalReleaseIds) { resolvedReleaseIdString = convertReleaseId(connection, resolvedReleaseIdString, folderIdString, packageReleaseSeparatorString); } artifactData.setResolvedReleaseId(resolvedReleaseIdString); } if (storyPoints != null && storyPoints.getFieldValueHasChanged()) { Object fieldValueObj = storyPoints.getFieldValue(); int fieldValue = 0; if (fieldValueObj instanceof String) { String fieldValueString = (String) fieldValueObj; try { fieldValue = Integer.parseInt(fieldValueString); } catch (NumberFormatException e) { throw new CCFRuntimeException( "Could not parse value of mandatory field points: " + e.getMessage(), e); } } else if (fieldValueObj instanceof Integer) { fieldValue = ((Integer) fieldValueObj).intValue(); } artifactData.setPoints(fieldValue); } artifactData.setFlexFields(flexFields); String firstComment = comments.length > 0 ? comments[0] : null; connection.getTrackerClient().setArtifactData(artifactData, firstComment, null, null, null); } catch (AxisFault e) { javax.xml.namespace.QName faultCode = e.getFaultCode(); if (!faultCode.getLocalPart().equals("VersionMismatchFault")) { throw e; } logConflictResolutor.warn("Stale update for TF tracker item " + Id + " in tracker " + trackerId + ". Trying again ...", e); mainArtifactNotUpdated = true; } } // increase version number for comment updates if (comments.length != 0) { artifactData.setVersion(artifactData.getVersion() + 1); } boolean first = true; for (String comment : comments) { if (first) { // we already processed the first comment above. first = false; continue; } boolean commentNotUpdated = true; while (commentNotUpdated) { try { commentNotUpdated = false; if (StringUtils.isEmpty(comment)) { continue; } connection.getTrackerClient().setArtifactData(artifactData, comment, null, null, null); artifactData.setVersion(artifactData.getVersion() + 1); } catch (AxisFault e) { javax.xml.namespace.QName faultCode = e.getFaultCode(); if (!faultCode.getLocalPart().equals("VersionMismatchFault")) { throw e; } logConflictResolutor.warn("Stale comment update, trying again ...:", e); artifactData = connection.getTrackerClient().getArtifactData(Id); commentNotUpdated = true; } } } // it looks as if since TF 5.3, not every update call automatically // increases the version number // hence we retrieve the artifact version here again //if (comments.length == 0) { // artifactData.setVersion(artifactData.getVersion() + 1); artifactData = connection.getTrackerClient().getArtifactData(Id); //} if (associateWithParent) { createArtifactDependency(connection, newParentId, Id, "CCF generated parent-child relationship"); } log.info("Artifact updated id: " + artifactData.getId() + " in " + artifactData.getFolderId()); return artifactData; }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public QName resolveUnqualifiedTypeName(QName type) throws SchemaException { QName typeFound = null;/*from ww w . j a va 2 s .c o m*/ for (SchemaDescription desc : schemaDescriptions) { QName typeInSchema = new QName(desc.getNamespace(), type.getLocalPart()); if (desc.getSchema() != null && desc.getSchema().findComplexTypeDefinition(typeInSchema) != null) { if (typeFound != null) { throw new SchemaException("Ambiguous type name: " + type); } else { typeFound = typeInSchema; } } } if (typeFound == null) { throw new SchemaException("Unknown type: " + type); } else { return typeFound; } }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
/** * Looks for a top-level definition for the specified element name (in all schemas). *//*from w ww . ja va 2 s . com*/ public ItemDefinition resolveGlobalItemDefinition(QName elementQName) throws SchemaException { String elementNamespace = elementQName.getNamespaceURI(); if (StringUtils.isEmpty(elementNamespace)) { return resolveGlobalItemDefinitionWithoutNamespace(elementQName.getLocalPart(), ItemDefinition.class); } PrismSchema schema = findSchemaByNamespace(elementNamespace); if (schema == null) { return null; } ItemDefinition itemDefinition = schema.findItemDefinition(elementQName, ItemDefinition.class); return itemDefinition; }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public <T extends Objectable> PrismObjectDefinition<T> findObjectDefinitionByType(QName typeName) { if (StringUtils.isEmpty(typeName.getNamespaceURI())) { // a quick hack (todo do it seriously) ComplexTypeDefinition ctd = resolveGlobalTypeDefinitionWithoutNamespace(typeName.getLocalPart()); if (ctd == null) { return null; }/*from w w w.j a va 2s . c o m*/ typeName = ctd.getTypeName(); } PrismSchema schema = findSchemaByNamespace(typeName.getNamespaceURI()); if (schema == null) { //TODO: check for confilicted objects // Iterator<PrismSchema> schemaIterator = getSchemas().iterator(); // while (schemaIterator.hasNext()){ // schema = schemaIterator.next(); // if (schema == null){ // continue; // } // PrismObjectDefinition<T> def = schema.findObjectDefinitionByTypeAssumeNs(typeName); // if (def != null){ // return def; // } // // } return null; } return schema.findObjectDefinitionByType(typeName); }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
private QName resolveElementNameIfNeeded(QName elementName, boolean exceptionIfAmbiguous) { if (StringUtils.isNotEmpty(elementName.getNamespaceURI())) { return elementName; }/*from w w w . j av a 2s .co m*/ ItemDefinition itemDef = resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), ItemDefinition.class, exceptionIfAmbiguous); if (itemDef != null) { return itemDef.getName(); } else { return null; } }