示例#1
0
文件: create.go 项目: m1028639/xld
func translateProp(ciType *metadata.CIType, prop intf.Argument) (result interface{}, err error) {
	key := prop.Name()
	kind := ciType.Prop(key).Kind

	if kind == "" {
		return "error", errors.New("Unknown property type " + ciType.Type + "->" + key)
	}

	switch kind {

	case "BOOLEAN", "INTEGER", "STRING", "ENUM":
		return prop.Value(), nil

	case "CI":
		return mapRef(prop.Value()), nil

	case "MAP_STRING_STRING":
		return mapStringString(prop.Map()), nil

	case "SET_OF_STRING", "LIST_OF_STRING":
		return mapSetOfStrings(prop.Values()), nil

	case "SET_OF_CI", "LIST_OF_CI":
		return mapSetOfCis(prop.Values()), nil

	default:
		return "error", errors.New("Unknown property kind " + kind + " --> XLD server newer than client?")

	}
}
示例#2
0
文件: read.go 项目: m1028639/xld
func readProperty(key string, value interface{}, ciType *metadata.CIType) (result interface{}, err error) {
	kind := ciType.Prop(key).Kind

	switch kind {

	case "BOOLEAN", "INTEGER", "STRING", "ENUM":
		result = value.(string)

	case "CI":
		result = cleanRef(value)

	case "MAP_STRING_STRING":
		result = cleanStringString(value)

	case "SET_OF_STRING", "LIST_OF_STRING":
		result = cleanSetOfStrings(value)

	case "SET_OF_CI", "LIST_OF_CI":
		result = cleanSetOfCis(value)

	default:
		return "error", errors.New("Unknown property kind " + kind + " --> XLD server newer than client?")
	}

	return
}
示例#3
0
文件: modify.go 项目: m1028639/xld
func handleDefault(mapContent map[string]interface{}, key string, prop intf.Argument, ciType *metadata.CIType) error {
	kind := ciType.Prop(key).Kind

	switch kind {
	case "MAP_STRING_STRING":
		mapContent[key] = prop.Map()
	case "SET_OF_STRING", "LIST_OF_STRING", "SET_OF_CI", "LIST_OF_CI":
		mapContent[key] = prop.Values()
	case "BOOLEAN", "INTEGER", "STRING", "ENUM", "CI":
		mapContent[key] = prop.Value()
	default:
		return errors.New("Unexpected value type read from repository; does it exist?")
	}
	return nil
}