모델 컨텍스트

Model Context

each(visitor)

클로져 수행.
Runs closure.
visitor : 클로져 : Closure
동작을 담은 클로져.
Closure that puts in procedure.
반환값 : 모델 컨텍스트
현재 모델 컨텍스트.
Context of the current model.
return : Model Context
현재 모델 컨텍스트.
Context of the current model.
클로져 수행. 현재 컨텍스트에 속한 모델들이 각각 주어진 특정 동작을 수행하게 합니다.
Runs closure. perform a specific action that models belonging to the current context given respectively.

선택된 모델들의 이름을 출력하는 예제:

selection.each(function(it){
	log(it.get("name"));
});

Example to print the name of the selected model:

selection.each(function(it){
	log(it.get("name"));
});

filter(rule)

현재 모델 컨텍스트 내에서 주어진 조건을 만족하는 모델만 남깁니다.
Filters and gets the only models that satisfy the given condition in the current model context.
rule : 클로져 : Closure
남길 모델을 평가하는 클로져. 이 클로져는 모델을 인자로 하여, true 또는 false를 리턴해야 합니다.
Closure that evaluates the model to leave. This closure should return true/false by using the model as a parameter.
반환값 : 모델 컨텍스트
평가식을 통과한 모델들만 담은 모델 컨텍스트.
Model context containing only the models that passed the evaluation.
return : Model Context
평가식을 통과한 모델들만 담은 모델 컨텍스트.
Model context containing only the models that passed the evaluation.
현재 모델 컨텍스트 내에서 주어진 조건을 만족하는 모델만 남깁니다.
Filters and gets the only models that satisfy the given condition in the current model context.

get(attrName)

속성을 얻습니다.
Gets the attribute of the given name.
attrName : String : String
얻을 속성의 이름.
Gets name of attribute.
반환값 : Object
속성 값.
Attribute value.
return : Object
속성 값.
Attribute value.
속성을 얻습니다. 만약 이 모델 컨텍스트가 여러 모델을 담고 있는 경우, 첫 번째 모델의 속성을 얻습니다.
Gets the attribute of the given name. If the context of this model contains more than one model, obtains the attributes of the first model.
// 논리명 얻기
var logicalName = context.get("logical-name");
// Get logical name
var logicalName = context.get("logical-name");

getUserProperty(key)

사용자 정의 속성을 얻습니다.
Get the custom attributes.
key : String : String
사용자 정의 속성 키.
Properties of user-defined keys.
반환값 : String
주어진 속성 키에 대한 값.
Value of the specified property key.
return : String
주어진 속성 키에 대한 값.
Value of the specified property key.
사용자 정의 속성을 얻습니다.
Get the custom attributes.
setUserProperty()를 통해 사용자 정의 속성을 지정할 수 있습니다.
You can specify a user-defined attribute using setUserProperty().

has(attrName)

현재 컨텍스트의 첫번째 모델이 특정 속성을 가지고 있는지 여부를 반환합니다.
Checks whether the first model of the current context has the specified attribute.
attrName : String : String
속성.
Attribute.
반환값 : boolean
속성의 존재 여부.
Whether the attribute exists or not.
return : boolean
속성의 존재 여부.
Whether the attribute exists or not.
현재 컨텍스트의 첫번째 모델이 특정 속성을 가지고 있는지 여부를 반환합니다.
Checks whether the first model of the current context has the specified attribute.
현재 컨텍스트가 비어있는 경우 항상 false가 리턴됩니다. 현재 컨텍스트가 여러 모델을 갖고 있는 경우 첫 번째 모델의 속성 존재 여부를 리턴합니다.

예제:

// 물리명을 소유한 모든 모델에 대한 컨텍스트 얻기
select(function(it){
	return it.has("physical-name");
});
If the current context is null, it always returns false. In case of the current context has multiple model, it returns whether the first model has the attribute.

Example:

// Get the context for all the models having physical name.
select(function(it){
	return it.has("physical-name");
});

head()

현재 모델 컨텍스트에 포함된 첫 번째 모델만을 담은 컨텍스트를 얻습니다.
Gets the context containing only the first model in the current context.
반환값 : 모델 컨텍스트
첫번째 모델이 담긴 모델 컨텍스트.
Context of the model that contain the first models.
return : Model Context
첫번째 모델이 담긴 모델 컨텍스트.
Context of the model that contain the first models.
현재 모델 컨텍스트에 포함된 첫 번째 모델만을 담은 컨텍스트를 얻습니다.
Gets the context containing only the first model in the current context.

isEmpty()

이 모델 컨텍스트가 비어있는지 여부를 얻습니다.
Whether this model context is empty or not.
반환값 : boolean
모델 컨텍스트가 비어 있는 경우 true, 비어있지 않은 경우 true.
If context of the model is empty is true, and if it is not not empty is true.
return : boolean
모델 컨텍스트가 비어 있는 경우 true, 비어있지 않은 경우 true.
If context of the model is empty is true, and if it is not not empty is true.
이 모델 컨텍스트가 비어있는지 여부를 얻습니다.
Whether this model context is empty or not.

join(separator, transformer)

현재 모델 컨텍스트에 포함된 모델들을 스트링 형태로 변경하고 연결합니다.
Coverts and connects the models included in the current model context into string format.
separator : String : String
각 모델 사이의 구분자.
Conversion function that converts each model into strings.
transformer : 클로져 : Closure
각 모델을 문자열로 변환하는 변환 함수.
Conversion function that convert to string each model.
반환값 : String
각 모델이 주어진 변환 함수로 변환된 뒤 연결된 문자열.
String.
return : String
각 모델이 주어진 변환 함수로 변환된 뒤 연결된 문자열.
String.
현재 모델 컨텍스트에 포함된 모델들을 스트링 형태로 변경하고 연결합니다.
Coverts and connects the models included in the current model context into string format.

예를들어 Foo와 Bar라는 두개의 테이블이 담긴 모델컨텍스트가 있다고 할 때, "Foo, Bar"라는 문자열을 얻으려면 다음과 같이 할 수 있습니다.

var ctx = ...;

var result = ctx.join(", ", function(it){
	return it.get("name");
});

log(result);

For example, suppose that there is a model context containing two tables named Foo and Bar, to get the string of table name “Foo, Bar”, refer to codes below:

var ctx = ...;

var result = ctx.join(", ", function(it){
	return it.get("name");
});

log(result);

join(prefix, suffix, separator, transformer)

현재 모델 컨텍스트에 포함된 모델들을 스트링 형태로 변경하고 연결합니다.
Coverts and connects the models included in the current model context into string format.
prefix : String : String
결과물의 앞에 붙을 문자열.
String to add at the front of the result
suffix : String : String
결과물의 뒤에 붙을 문자열.
String to attach at the rear of the result
separator : String : String
각 모델 사이의 구분자.
Separator between each model.
transformer : 클로져 : Closure
각 모델이 주어진 변환 함수로 변환된 뒤 연결된 문자열.
The string that is converted and connected after each model is converted with the given conversion function.
반환값 : String
return : String
현재 모델 컨텍스트에 포함된 모델들을 스트링 형태로 변경하고 연결합니다.
Coverts and connects the models included in the current model context into string format.

예를들어 Foo와 Bar라는 두개의 테이블이 담긴 모델컨텍스트가 있다고 할 때, "[Foo, Bar]"라는 문자열을 얻으려면 다음과 같이 할 수 있습니다.

var ctx = ...;

var result = ctx.join("[", "]", ", ", function(it){
	return it.get("name");
});

log(result);

For example, suppose that there is a model context containing two tables named Foo and Bar, to get the string of table name “[Foo, Bar]”, refer to codes below:

var ctx = ...;

var result = ctx.join("[", "]", ", ", function(it){
	return it.get("name");
});

log(result);

last()

현재 모델 컨텍스에 담긴 마지막 모델만을 담은 컨텍스트를 얻습니다.
Get the context that contain the last model only which was in the context of the current model.
반환값 : 모델 컨텍스트
마지막 모델이 담긴 컨텍스트.
last model is the contained context.
return : Model Context
마지막 모델이 담긴 컨텍스트.
last model is the contained context.
현재 모델 컨텍스에 담긴 마지막 모델만을 담은 컨텍스트를 얻습니다.
Get the context that contain the last model only which was in the context of the current model.

map(mapper)

현재 모델 컨텍스트에 담긴 각각의 모델을 다른 형태로 변환합니다.
Converts each model contained in the current model context into other format.
mapper : 클로져 : Closure
변환 함수. 이 변환 함수는 모델을 인자로 하여 변형된 값을 리턴하는 형태이어야 합니다.
Conversion function. Must be in a form that returns the converted value using the model as a parameter.
반환값 : Object
변환된 모델 컨텍스트 또는 자바 스크립트 배열.
The transformed model context or JavaScript array.
return : Object
변환된 모델 컨텍스트 또는 자바 스크립트 배열.
The transformed model context or JavaScript array.
현재 모델 컨텍스트에 담긴 각각의 모델을 다른 형태로 변환합니다.
Converts each model contained in the current model context into other format.
// 모델들을 논리명 배열로 변경하는 예제
var nameArray = selection.map(function(it){
	return it.get("logical-name");
});

for(i in nameArray){
	log(nameArray[i]);
}
// Example the model to change into array of logical name.
var nameArray = selection.map(function(it){
	return it.get("logical-name");
});

for(i in nameArray){
	log(nameArray[i]);
}

mapAndPack(mapper)

map()과 유사하지만, 변형 후 중복되는 요소가 제거 됩니다.
is similar to map(), but duplicate elements after deformation is removed.
mapper : 클로져 : Closure
변환 함수. 이 변환 함수는 모델을 인자로 하여 변형된 값을 리턴하는 형태이어야 합니다.
Conversion function. Should have a form that returns a value that is deformed by passing a model.
반환값 : Object
변환된 모델 컨텍스트 또는 자바 스크립트 배열.
The transformed model context or JavaScript array.
return : Object
변환된 모델 컨텍스트 또는 자바 스크립트 배열.
The transformed model context or JavaScript array.
map()과 유사하지만, 변형 후 중복되는 요소가 제거 됩니다.
is similar to map(), but duplicate elements after deformation is removed.

pack()

컨텍스트 내에 중복되는 요소를 제거합니다.
Removes the elements that are duplicated in the context.
반환값 : 모델 컨텍스트
중복된 요소가 제거된 모델 컨텍스트.
The model context that duplicate element is deleted.
return : Model Context
중복된 요소가 제거된 모델 컨텍스트.
The model context that duplicate element is deleted.
컨텍스트 내에 중복되는 요소를 제거합니다.
Removes the elements that are duplicated in the context.

select(rule)

현재 컨텍스트에 선택된 모델 및, 하위 모델들을 대상으로 검색을 수행합니다.
Searches through the selected models of current context and the sub models.
rule : 클로져 : Closure
검색 조건을 담은 클로져.
Closure that contain the search condition.
반환값 : 모델 컨텍스트
주어진 검색 조건을 만족하는 모델이 담긴 모델 컨텍스트.
Model context that satisfies the search condition.
return : Model Context
주어진 검색 조건을 만족하는 모델이 담긴 모델 컨텍스트.
Model context that satisfies the search condition.
현재 컨텍스트에 선택된 모델 및, 하위 모델들을 대상으로 검색을 수행합니다.
Searches through the selected models of current context and the sub models.
var tables = select(function(it){
	return it.get("type") == "table";
}).each(function(it){
	// 각 테이블 내의 모든 컬럼을 다시 검색
	var columns = it.select(function(it){
		return it.get("type") == "columns";
	});
});
var tables = select(function(it){
	return it.get("type") == "table";
}).each(function(it){
	// Search all columns in each table
	var columns = it.select(function(it){
		return it.get("type") == "columns";
	});
});

selectInEditor()

현재 컨텍스트에 포함된 요소를 다이어그램 에디터에서 선택합니다.
Select the contained element in the current context from diagram editor.
현재 컨텍스트에 포함된 요소를 다이어그램 에디터에서 선택합니다. 만약 현재 선택된 모델이 활성 다이어그램 내에 존재 하지 않는 경우 선택되지 않습니다.
Select the contained element in the current context from diagram editor. Not select If current selected model is not exist within active diagram.

set(json)

JSON을 이용해 복수의 속성을 한번에 지정합니다.
Specifies multiple properties using JSON.
json : NativeObject : NativeObject
속성 이름/값을 담은 JSON 객체.
JSON object that contains the attribute name / value.
반환값 : 모델 컨텍스트
현재 모델 컨텍스트.
Current model context.
return : Model Context
현재 모델 컨텍스트.
Current model context.
JSON을 이용해 복수의 속성을 한번에 지정합니다.
Specifies multiple properties using JSON.
var template = {
	"datatype" : "varchar(10)",
	"color-tag" : "red"
};

select(function(it){
	return it.get("type") == "column" && it.get("logical-name").endsWith("이름");
}).each(function(it){
	it.set(template);
});
var template = {
	"datatype" : "varchar(10)",
	"color-tag" : "red"
};

select(function(it){
	return it.get("type") == "column" && it.get("logical-name").endsWith("Name");
}).each(function(it){
	it.set(template);
});

set(attrName, value)

속성을 지정합니다.
Sets the value of the attribute.
attrName : String : String
지정할 속성 이름.
The attribute name to set a value
value : Object : Object
속성 값.
The value to set.
반환값 : 모델 컨텍스트
현재 모델 컨텍스트.
Current model context.
return : Model Context
현재 모델 컨텍스트.
Current model context.
속성을 지정합니다.
Sets the value of the attribute.

setUserProperty(key, value)

사용자 정의 속성을 지정합니다.
Specifies user defined attribute.
key : String : String
지정할 속성 키.
The key of the attribute to set a value.
value : String : String
값. 값은 String 으로만 저장됩니다. 값이 null이면 속성을 지웁니다.
The value to set. The value is saved only in string. If the value is null, it deletes the property.
반환값 : 모델 컨텍스트
현재 모델 컨텍스트.
Current model context.
return : Model Context
현재 모델 컨텍스트.
Current model context.
사용자 정의 속성을 지정합니다.
Specifies user defined attribute.
getUserProperty()를 통해 사용자 정의 속성을 지정할 수 있습니다.
You can specify a user-defined attribute through getUserProperty().

size()

이 컨텍스트에 속한 모델의 개수를 얻습니다.
Gets the number of models that belong to this context.
반환값 : int
컨텍스트에 포함된 모델의 개수.
Number of models that are included in the context.
return : int
컨텍스트에 포함된 모델의 개수.
Number of models that are included in the context.
이 컨텍스트에 속한 모델의 개수를 얻습니다.
Gets the number of models that belong to this context.