當前位置: 首頁>>代碼示例>>Java>>正文


Java XsdTypeMapper.toXsdType方法代碼示例

本文整理匯總了Java中com.evolveum.midpoint.prism.xml.XsdTypeMapper.toXsdType方法的典型用法代碼示例。如果您正苦於以下問題:Java XsdTypeMapper.toXsdType方法的具體用法?Java XsdTypeMapper.toXsdType怎麽用?Java XsdTypeMapper.toXsdType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.evolveum.midpoint.prism.xml.XsdTypeMapper的用法示例。


在下文中一共展示了XsdTypeMapper.toXsdType方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createPropertyDefinition

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
private ItemDefinition<?> createPropertyDefinition(PrismContainerDefinitionImpl<?> configurationContainerDef,
		PropertyDescriptor prop) {
	String propName = prop.getName();
	Class<?> propertyType = prop.getPropertyType();
	Class<?> baseType = propertyType;
	int minOccurs = 1;
	int maxOccurs = 1;
	if (propertyType.isArray()) {
		maxOccurs = -1;
		baseType = propertyType.getComponentType();
	}
	// TODO: minOccurs: define which properties are optional/mandatory
	// TODO: display names, ordering, help texts
	QName propType = XsdTypeMapper.toXsdType(baseType);
	return configurationContainerDef.createPropertyDefinition(new QName(configurationContainerDef.getName().getNamespaceURI(), propName),
			propType, minOccurs, maxOccurs);
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:18,代碼來源:ConnectorFactoryBuiltinImpl.java

示例2: evaluateExpression

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
private <T> List<T> evaluateExpression(Class<T> resultClass, ExpressionType expressionType, ExpressionVariables expressionVariables,
        String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException {

    QName xsdType = XsdTypeMapper.toXsdType(resultClass);

    QName resultName = new QName(SchemaConstants.NS_C, "result");
    PrismPropertyDefinition<T> resultDef = new PrismPropertyDefinitionImpl<>(resultName, xsdType, prismContext);

    Expression<PrismPropertyValue<T>,PrismPropertyDefinition<T>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result);
    ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result);

    PrismValueDeltaSetTriple<PrismPropertyValue<T>> exprResult = ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result);

    List<T> retval = new ArrayList<>();
    for (PrismPropertyValue<T> item : exprResult.getZeroSet()) {
        retval.add(item.getValue());
    }
    return retval;
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:20,代碼來源:AccCertExpressionHelper.java

示例3: marshallBeanToPrimitive

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
/**
 * For cases when XSD complex type has a simple content. In that case the resulting class has @XmlValue annotation. 
 */
private <T> PrimitiveXNode<T> marshallBeanToPrimitive(Object bean, SerializationContext ctx, Field valueField) throws SchemaException {
	if (!valueField.isAccessible()) {
		valueField.setAccessible(true);
	}
	T value;
	try {
		value = (T) valueField.get(bean);
	} catch (IllegalArgumentException | IllegalAccessException e) {
		throw new SchemaException("Cannot get primitive value from field " + valueField.getName() + " of bean " + bean + ": "+e.getMessage(), e);
	}
	PrimitiveXNode<T> xnode = new PrimitiveXNode<>(value);
	Class<?> fieldType = valueField.getType();
	QName xsdType = XsdTypeMapper.toXsdType(fieldType);
	xnode.setTypeQName(xsdType);
	return xnode;
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:20,代碼來源:BeanMarshaller.java

示例4: marshalProtectedDataType

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
public <T> MapXNode marshalProtectedDataType(Object o, SerializationContext sc) throws SchemaException {
ProtectedDataType<T> protectedType = (ProtectedDataType<T>) o;
      MapXNode xmap = new MapXNode();
      if (protectedType.getEncryptedDataType() != null) {
          EncryptedDataType encryptedDataType = protectedType.getEncryptedDataType();
          MapXNode xEncryptedDataType = (MapXNode) marshall(encryptedDataType);
          xmap.put(ProtectedDataType.F_ENCRYPTED_DATA, xEncryptedDataType);
      } else if (protectedType.getHashedDataType() != null) {
          HashedDataType hashedDataType = protectedType.getHashedDataType();
          MapXNode xHashedDataType = (MapXNode) marshall(hashedDataType);
          xmap.put(ProtectedDataType.F_HASHED_DATA, xHashedDataType);
      } else if (protectedType.getClearValue() != null){
          QName type = XsdTypeMapper.toXsdType(protectedType.getClearValue().getClass());
          PrimitiveXNode xClearValue = createPrimitiveXNode(protectedType.getClearValue(), type);
          xmap.put(ProtectedDataType.F_CLEAR_VALUE, xClearValue);
      }
      // TODO: clearValue
      return xmap;
  }
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:20,代碼來源:BeanMarshaller.java

示例5: evaluateExpression

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
private <T> List<T> evaluateExpression(Class<T> resultClass, ExpressionType expressionType, ExpressionVariables expressionVariables,
        String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {

    QName xsdType = XsdTypeMapper.toXsdType(resultClass);

    QName resultName = new QName(SchemaConstants.NS_C, "result");
    PrismPropertyDefinition<T> resultDef = new PrismPropertyDefinitionImpl<>(resultName, xsdType, prismContext);

    Expression<PrismPropertyValue<T>,PrismPropertyDefinition<T>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result);
    ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result);

    PrismValueDeltaSetTriple<PrismPropertyValue<T>> exprResult = ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result);

    List<T> retval = new ArrayList<>();
    for (PrismPropertyValue<T> item : exprResult.getZeroSet()) {
        retval.add(item.getValue());
    }
    return retval;
}
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:20,代碼來源:AccCertExpressionHelper.java

示例6: marshallBeanToPrimitive

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
/**
 * For cases when XSD complex type has a simple content. In that case the resulting class has @XmlValue annotation.
 */
private <T> PrimitiveXNode<T> marshallBeanToPrimitive(Object bean, SerializationContext ctx, Field valueField) throws SchemaException {
	if (!valueField.isAccessible()) {
		valueField.setAccessible(true);
	}
	T value;
	try {
		value = (T) valueField.get(bean);
	} catch (IllegalArgumentException | IllegalAccessException e) {
		throw new SchemaException("Cannot get primitive value from field " + valueField.getName() + " of bean " + bean + ": "+e.getMessage(), e);
	}
	PrimitiveXNode<T> xnode = new PrimitiveXNode<>(value);
	Class<?> fieldType = valueField.getType();
	QName xsdType = XsdTypeMapper.toXsdType(fieldType);
	xnode.setTypeQName(xsdType);
	return xnode;
}
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:20,代碼來源:BeanMarshaller.java

示例7: icfTypeToXsdType

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
public static QName icfTypeToXsdType(Class<?> type, boolean isConfidential) {
		// For arrays we are only interested in the component type
		if (isMultivaluedType(type)) {
			type = type.getComponentType();
		}
		QName propXsdType = null;
		if (GuardedString.class.equals(type) || 
				(String.class.equals(type) && isConfidential)) {
			// GuardedString is a special case. It is a ICF-specific
			// type
			// implementing Potemkin-like security. Use a temporary
			// "nonsense" type for now, so this will fail in tests and
			// will be fixed later
//			propXsdType = SchemaConstants.T_PROTECTED_STRING_TYPE;
			propXsdType = ProtectedStringType.COMPLEX_TYPE;
		} else if (GuardedByteArray.class.equals(type) || 
				(Byte.class.equals(type) && isConfidential)) {
			// GuardedString is a special case. It is a ICF-specific
			// type
			// implementing Potemkin-like security. Use a temporary
			// "nonsense" type for now, so this will fail in tests and
			// will be fixed later
//			propXsdType = SchemaConstants.T_PROTECTED_BYTE_ARRAY_TYPE;
			propXsdType = ProtectedByteArrayType.COMPLEX_TYPE;
		} else {
			propXsdType = XsdTypeMapper.toXsdType(type);
		}
		return propXsdType;
	}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:30,代碼來源:ConnIdUtil.java

示例8: createTokenProperty

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
private <T> PrismProperty<T> createTokenProperty(T object) {
	QName type = XsdTypeMapper.toXsdType(object.getClass());

	Set<PrismPropertyValue<T>> syncTokenValues = new HashSet<PrismPropertyValue<T>>();
	syncTokenValues.add(new PrismPropertyValue<T>(object));
	PrismPropertyDefinitionImpl propDef = new PrismPropertyDefinitionImpl(SchemaConstants.SYNC_TOKEN,
			type, prismContext);
	propDef.setDynamic(true);
	propDef.setMaxOccurs(1);
	PrismProperty<T> property = propDef.instantiate();
	property.addValues(syncTokenValues);
	return property;
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:14,代碼來源:ConnectorInstanceConnIdImpl.java

示例9: unmarshallPrimitive

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
/**
 * For cases when XSD complex type has a simple content. In that case the resulting class has @XmlValue annotation.
 */
private <T> T unmarshallPrimitive(PrimitiveXNode<T> prim, Class<T> beanClass, ParsingContext pc) throws SchemaException {
	if (prim.isEmpty()) {
		return instantiate(beanClass);		// Special case. Just return empty object
	} 
	
	Field valueField = XNodeProcessorUtil.findXmlValueField(beanClass);
	
	if (valueField == null) {
		throw new SchemaException("Cannot convert primitive value to bean of type " + beanClass);
	}
	
	T instance = instantiate(beanClass);
	
	if (!valueField.isAccessible()) {
		valueField.setAccessible(true);
	}
	
	T value;
	if (prim.isParsed()) {
		value = prim.getValue();	
	} else {
		Class<?> fieldType = valueField.getType();
		QName xsdType = XsdTypeMapper.toXsdType(fieldType);
		value = prim.getParsedValue(xsdType, (Class<T>) fieldType);
	}
	
	try {
		valueField.set(instance, value);
	} catch (IllegalArgumentException | IllegalAccessException e) {
		throw new SchemaException("Cannot set primitive value to field " + valueField.getName() + " of bean " + beanClass + ": "+e.getMessage(), e);
	}
	
	return instance;
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:38,代碼來源:BeanUnmarshaller.java

示例10: locateItemDefinition

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
private <T extends Containerable> ItemDefinition locateItemDefinition(
			PrismContainerDefinition<T> containerDefinition, QName elementQName, Object valueElements)
			throws SchemaException {
		ItemDefinition def = containerDefinition.findItemDefinition(elementQName);
		if (def != null) {
			return def;
		}

		if (valueElements instanceof Element) {
			// Try to locate xsi:type definition in the element
			def = resolveDynamicItemDefinition(containerDefinition, elementQName, (Element) valueElements,
					prismContext);
		} 
		
		if (valueElements instanceof List){
			List elements = (List) valueElements;
			if (elements.size() == 1){
				Object element = elements.get(0);
				if (element instanceof JAXBElement){
					Object val = ((JAXBElement) element).getValue();
					if (val.getClass().isPrimitive()){
						QName typeName = XsdTypeMapper.toXsdType(val.getClass());
						PrismPropertyDefinitionImpl propDef = new PrismPropertyDefinitionImpl(elementQName, typeName, prismContext);
//						propDef.setMaxOccurs(maxOccurs);
						propDef.setDynamic(true);
						return propDef;
					}
				}
			}
		}
		if (def != null) {
			return def;
		}

		if (containerDefinition.isRuntimeSchema()) {
			// Try to locate global definition in any of the schemas
			def = resolveGlobalItemDefinition(containerDefinition, elementQName);
		}
		return def;
	}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:41,代碼來源:JaxbDomHack.java

示例11: determineTypeForClass

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
@Override
public QName determineTypeForClass(Class<?> clazz) {
	if (XmlTypeConverter.canConvert(clazz)) {
		return XsdTypeMapper.toXsdType(clazz);
	} else {
		return ((PrismContextImpl) prismContext).getBeanMarshaller().determineTypeForClass(clazz);
	}
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:9,代碼來源:SchemaRegistryImpl.java

示例12: icfTypeToXsdType

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
public static QName icfTypeToXsdType(Class<?> type, boolean isConfidential) {
		// For arrays we are only interested in the component type
		if (isMultivaluedType(type)) {
			type = type.getComponentType();
		}
		QName propXsdType = null;
		if (GuardedString.class.equals(type) ||
				(String.class.equals(type) && isConfidential)) {
			// GuardedString is a special case. It is a ICF-specific
			// type
			// implementing Potemkin-like security. Use a temporary
			// "nonsense" type for now, so this will fail in tests and
			// will be fixed later
//			propXsdType = SchemaConstants.T_PROTECTED_STRING_TYPE;
			propXsdType = ProtectedStringType.COMPLEX_TYPE;
		} else if (GuardedByteArray.class.equals(type) ||
				(Byte.class.equals(type) && isConfidential)) {
			// GuardedString is a special case. It is a ICF-specific
			// type
			// implementing Potemkin-like security. Use a temporary
			// "nonsense" type for now, so this will fail in tests and
			// will be fixed later
//			propXsdType = SchemaConstants.T_PROTECTED_BYTE_ARRAY_TYPE;
			propXsdType = ProtectedByteArrayType.COMPLEX_TYPE;
		} else {
			propXsdType = XsdTypeMapper.toXsdType(type);
		}
		return propXsdType;
	}
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:30,代碼來源:ConnIdUtil.java

示例13: locateItemDefinition

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
private <T extends Containerable> ItemDefinition locateItemDefinition(
			PrismContainerDefinition<T> containerDefinition, QName elementQName, Object valueElements)
			throws SchemaException {
		ItemDefinition def = containerDefinition.findItemDefinition(elementQName);
		if (def != null) {
			return def;
		}

		if (valueElements instanceof Element) {
			// Try to locate xsi:type definition in the element
			def = resolveDynamicItemDefinition(containerDefinition, elementQName, (Element) valueElements,
					prismContext);
		}

		if (valueElements instanceof List){
			List elements = (List) valueElements;
			if (elements.size() == 1){
				Object element = elements.get(0);
				if (element instanceof JAXBElement){
					Object val = ((JAXBElement) element).getValue();
					if (val.getClass().isPrimitive()){
						QName typeName = XsdTypeMapper.toXsdType(val.getClass());
						PrismPropertyDefinitionImpl propDef = new PrismPropertyDefinitionImpl(elementQName, typeName, prismContext);
//						propDef.setMaxOccurs(maxOccurs);
						propDef.setDynamic(true);
						return propDef;
					}
				}
			}
		}
		if (def != null) {
			return def;
		}

		if (containerDefinition.isRuntimeSchema()) {
			// Try to locate global definition in any of the schemas
			def = resolveGlobalItemDefinition(containerDefinition, elementQName);
		}
		return def;
	}
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:41,代碼來源:JaxbDomHack.java

示例14: unmarshallPrimitive

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
/**
 * For cases when XSD complex type has a simple content. In that case the resulting class has @XmlValue annotation.
 */
private <T> T unmarshallPrimitive(PrimitiveXNode<T> prim, Class<T> beanClass, ParsingContext pc) throws SchemaException {
	if (prim.isEmpty()) {
		return instantiateWithSubtypeGuess(beanClass, emptySet());		// Special case. Just return empty object
	}

	Field valueField = XNodeProcessorUtil.findXmlValueField(beanClass);

	if (valueField == null) {
		ParsingMigrator parsingMigrator = prismContext.getParsingMigrator();
		if (parsingMigrator != null) {
			T bean = parsingMigrator.tryParsingPrimitiveAsBean(prim, beanClass, pc);
			if (bean != null) {
				return bean;
			}
		}
		throw new SchemaException("Cannot convert primitive value to bean of type " + beanClass);
	}

	T instance = instantiate(beanClass);

	if (!valueField.isAccessible()) {
		valueField.setAccessible(true);
	}

	T value;
	if (prim.isParsed()) {
		value = prim.getValue();
	} else {
		Class<?> fieldType = valueField.getType();
		QName xsdType = XsdTypeMapper.toXsdType(fieldType);
		value = prim.getParsedValue(xsdType, (Class<T>) fieldType);
	}

	try {
		valueField.set(instance, value);
	} catch (IllegalArgumentException | IllegalAccessException e) {
		throw new SchemaException("Cannot set primitive value to field " + valueField.getName() + " of bean " + beanClass + ": "+e.getMessage(), e);
	}

	return instance;
}
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:45,代碼來源:BeanUnmarshaller.java


注:本文中的com.evolveum.midpoint.prism.xml.XsdTypeMapper.toXsdType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。