コード例 #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
}