Exemplo n.º 1
0
void SSHTables::CreateDomain(string path, const Table& table) const {
	ofstream fp;
	path += table.objectName +".java";
	fp.open(path);

	if (!fp.is_open()) {
		cout << "Could not create file:" + path + ". The directory doesn't exist?\n\n";
		return;
	}

	Template *t = new DomainTemplate(table.columns.size());
	t->Update("package", package)->Update("name", table.name)->Update("schema", table.schema)->Update("objectName", table.objectName);
	for (int i = 0; i < table.columns.size(); i++) {
		char index[25];
		itoa(i, index, 10);
		string column = "column" + string(index);
		string type = column + "_type", name = column + "_name_s", Name = column + "_name";
		t->Update(type, table.columns[i].type);
		
		string s = table.columns[i].name;
		t->Update(name, s);
		if (s[0] >= 'a' && s[0] <= 'z') {
			s[0] -= 32;
		}
		t->Update(Name, s);
	}

	string code = t->GetCode();
	delete t;
	Write(fp, code);
	fp.flush();
	fp.clear();
	fp.close();
}
Exemplo n.º 2
0
void SSHTables::CreateServiceImpl(string path, const Table& table) const {
	ofstream fp;
	path += table.objectName +"ServiceImpl.java";
	fp.open(path);

	if (!fp.is_open()) {
		cout << "Could not create file:" + path + ". The directory doesn't exist?\n\n";
		return;
	}

	Template *t = new ServiceImplTemplate(table.columns.size());
	string s = table.objectName;
	s[0] += 32;
	t->Update("package", package)->Update("objectName", table.objectName)->Update("sobjectName", s);
	string code = t->GetCode();
	delete t;
	Write(fp, code);
	fp.flush();
	fp.clear();
	fp.close();
}