Merge branch 'main' of https://git.istt.kz/locust/org.ccalm.main
# Conflicts: # org_ccalm_main.yml
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
/src/main/resources/static/resources
|
||||
/src/main/java/tctable
|
||||
/logs/
|
||||
|
||||
HELP.md
|
||||
|
||||
@ -10,9 +10,9 @@ spring:
|
||||
application:
|
||||
name: org.ccalm.main
|
||||
datasource:
|
||||
url: jdbc:postgresql://ccalm.org:5432/CCALM
|
||||
url: jdbc:postgresql://91.201.214.156:5432/CCALM?ApplicationName=org_ccalm_main&ssl=true&sslmode=require&connectTimeout=10000&socketTimeout=10000
|
||||
username: postgres
|
||||
password: PasSecrKey1
|
||||
password: 309A86FF65A78FB428F4E38DFE35F730
|
||||
driver-class-name: org.postgresql.Driver
|
||||
hikari:
|
||||
maximum-pool-size: 10
|
||||
|
||||
@ -35,6 +35,7 @@ import org.json.JSONObject;
|
||||
//import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
//import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -60,6 +61,15 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
private static final Logger logger = LoggerFactory.getLogger(AcceptASDCController.class);
|
||||
private ServletContext context;
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
@Value("${data.dir}")
|
||||
String data_dir = "";
|
||||
|
||||
public static final String md5(final String str)
|
||||
{
|
||||
try {
|
||||
@ -131,22 +141,6 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
result.put("error_code", 0);
|
||||
result.put("error_message", "");
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",ex);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -246,22 +240,6 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
result.put("error_code", 0);
|
||||
result.put("error_message", "");
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",ex);
|
||||
}
|
||||
|
||||
String uid=null;
|
||||
Connection conn = null;
|
||||
try {
|
||||
@ -919,22 +897,6 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
result.put("error_code", 0);
|
||||
result.put("error_message", "");
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",ex);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -1100,23 +1062,6 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
String result="<metadata fn=\"-1\"><![CDATA[Request not processed!]]></metadata>";
|
||||
//boolean error=false;
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",ex);
|
||||
}
|
||||
|
||||
//Create temporary directory
|
||||
String dataDir = data_dir;
|
||||
String tmpDir = "temp"+File.separator;
|
||||
@ -2567,25 +2512,6 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
return result;
|
||||
}
|
||||
|
||||
//String metadata_file = "";
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",ex);
|
||||
}
|
||||
|
||||
|
||||
//Connect to database
|
||||
Connection conn = null;
|
||||
try {
|
||||
@ -2794,25 +2720,6 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
if(reqData==null)
|
||||
return "OK";
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Error:",ex);
|
||||
result.put("error_code",1);
|
||||
result.put("error_message", ex.getMessage());
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -2955,10 +2862,11 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
Map<String, String> col = TCTableTools.getTableSchema(conn, "main", tbl.name);
|
||||
for(int i=0;i<tbl.fields.size();i++)
|
||||
{
|
||||
fb[i] = new ExistsType();
|
||||
Iterator<Map.Entry<String, String>> iterator = col.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, String> entry = iterator.next();
|
||||
if (entry.getKey().equalsIgnoreCase(col.get(i))) {
|
||||
if(tbl.fields.get(i).name.equalsIgnoreCase(entry.getKey())){
|
||||
fb[i].exists=true;
|
||||
fb[i].type=entry.getValue();
|
||||
break;
|
||||
@ -3168,23 +3076,6 @@ public class AcceptASDCController implements ServletContextAware {
|
||||
|
||||
String result="<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"></head><body>Результат<br>";
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",ex);
|
||||
}
|
||||
|
||||
//Connect to database
|
||||
Connection conn = null;
|
||||
try {
|
||||
|
||||
@ -24,6 +24,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
//import org.apache.commons.io.FileUtils;
|
||||
//import org.springframework.core.io.FileSystemResource;
|
||||
@ -50,6 +51,15 @@ public class AcceptEXCEL implements ServletContextAware {
|
||||
|
||||
private ServletContext context;
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
@Value("${data.dir}")
|
||||
String data_dir = "";
|
||||
|
||||
@Override
|
||||
public void setServletContext(ServletContext context) {
|
||||
this.context=context;
|
||||
@ -58,23 +68,6 @@ public class AcceptEXCEL implements ServletContextAware {
|
||||
@RequestMapping(value = "/AcceptCSV", method = { RequestMethod.GET, RequestMethod.POST })
|
||||
public String acceptCSV(@ModelAttribute User user, Model model,@RequestParam(required=false,name="file") MultipartFile file,@RequestParam(required=false,name="skip",defaultValue = "0") Boolean skip) {
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
|
||||
@ -38,6 +38,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@ -67,6 +68,15 @@ public class AcceptJSON implements ServletContextAware {
|
||||
private ServletContext context;
|
||||
private static final int BUFFER_SIZE = 4096;
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
@Value("${data.dir}")
|
||||
String data_dir = "";
|
||||
|
||||
//If not created object "user", create him.
|
||||
//@ModelAttribute("user")
|
||||
//public User populatePerson() {
|
||||
@ -95,22 +105,6 @@ public class AcceptJSON implements ServletContextAware {
|
||||
if(user.id==null || user.id.equals("null") || user.id.isBlank())
|
||||
return "Please log in!";
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -413,22 +407,6 @@ public class AcceptJSON implements ServletContextAware {
|
||||
@RequestMapping(value = "/AcceptJSON_RUS", method = { RequestMethod.GET, RequestMethod.POST })
|
||||
public String acceptCSV(@ModelAttribute User user, Model model,@RequestParam(required=false,name="file") MultipartFile file,@RequestParam(required=false,name="skip",defaultValue = "0") Boolean skip) {
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
|
||||
@ -24,6 +24,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@ -47,7 +48,16 @@ public class DataJSON implements ServletContextAware {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DataJSON.class);
|
||||
private ServletContext context;
|
||||
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
@Value("${data.dir}")
|
||||
String data_dir = "";
|
||||
|
||||
//If not created object "user", create him.
|
||||
//@ModelAttribute("user")
|
||||
//public User populatePerson() {
|
||||
@ -61,23 +71,6 @@ public class DataJSON implements ServletContextAware {
|
||||
int errorCode=0;
|
||||
String errorMessage="";
|
||||
|
||||
//Load configuration
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
|
||||
@ -16,6 +16,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -40,7 +41,16 @@ public class DownloadWeather implements ServletContextAware {
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(DownloadWeather.class);
|
||||
|
||||
private ServletContext context;
|
||||
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
@Value("${data.dir}")
|
||||
String data_dir = "";
|
||||
|
||||
@RequestMapping(value = "/DownloadWeather",method = RequestMethod.GET,produces = "text/html;charset=UTF-8")
|
||||
@ResponseBody
|
||||
public Object ajaxTamer(@RequestParam(required=false,name="forecast") String forecast,@RequestParam(required=false,name="date") String date) {
|
||||
@ -52,26 +62,10 @@ public class DownloadWeather implements ServletContextAware {
|
||||
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
|
||||
|
||||
//Load DB configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
String tmp_dir=data_dir+"temp"+File.separator;
|
||||
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
data_dir+="temp"+File.separator;
|
||||
|
||||
File dir = new File(data_dir);
|
||||
File dir = new File(tmp_dir);
|
||||
if (!dir.exists()) dir.mkdirs();
|
||||
|
||||
//response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
@ -111,7 +105,7 @@ public class DownloadWeather implements ServletContextAware {
|
||||
//Build URL to download
|
||||
String URL = "https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs."+date+"/"+time+"/atmos/gfs.t"+time+"z.pgrb2.0p25.f"+forecast;
|
||||
|
||||
File f = new File(data_dir+"text.idx");
|
||||
File f = new File(tmp_dir+"text.idx");
|
||||
if(f.exists()) {
|
||||
if (!f.delete()) {
|
||||
System.out.println("Failed to delete the file.");
|
||||
@ -119,15 +113,15 @@ public class DownloadWeather implements ServletContextAware {
|
||||
}
|
||||
|
||||
WeatherDownload wd = new WeatherDownload();
|
||||
if(wd.download(URL+".idx", data_dir+"text.idx", "0", ""))
|
||||
if(wd.download(URL+".idx", tmp_dir+"text.idx", "0", ""))
|
||||
{
|
||||
result+="Download "+URL+".idx"+" to "+data_dir+"text.idx"+"<br>";
|
||||
result+="Download "+URL+".idx"+" to "+tmp_dir+"text.idx"+"<br>";
|
||||
|
||||
String strPos1="";
|
||||
String strPos2="";
|
||||
//Read file and find required line.
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader(data_dir+"text.idx"));
|
||||
BufferedReader br = new BufferedReader(new FileReader(tmp_dir+"text.idx"));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
@ -159,11 +153,11 @@ public class DownloadWeather implements ServletContextAware {
|
||||
posEnd=String.valueOf(Long.parseLong(posEnd)-1);
|
||||
}
|
||||
|
||||
wd.download(URL, data_dir+"text.f000", String.valueOf(posStart), String.valueOf(posEnd));
|
||||
wd.download(URL, tmp_dir+"text.f000", String.valueOf(posStart), String.valueOf(posEnd));
|
||||
}
|
||||
}else
|
||||
{
|
||||
result+="Not download "+URL+".idx"+" to "+data_dir+"text.idx"+"<br>";
|
||||
result+="Not download "+URL+".idx"+" to "+tmp_dir+"text.idx"+"<br>";
|
||||
}
|
||||
|
||||
Array dataArrayLat=null;
|
||||
@ -172,7 +166,7 @@ public class DownloadWeather implements ServletContextAware {
|
||||
|
||||
try {
|
||||
// open netcdf/grib/grib2 file from argument
|
||||
NetcdfDataset gid = NetcdfDataset.openDataset(data_dir+"text.f000");
|
||||
NetcdfDataset gid = NetcdfDataset.openDataset(tmp_dir+"text.f000");
|
||||
|
||||
//logger.info("Desc: " + gid.getDescription());
|
||||
logger.info(gid.getDetailInfo());
|
||||
@ -366,23 +360,6 @@ public class DownloadWeather implements ServletContextAware {
|
||||
boolean error=false;
|
||||
String result="";
|
||||
|
||||
//Load DB configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
|
||||
@ -17,6 +17,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -36,7 +37,16 @@ public class GeoGSON implements ServletContextAware {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GeoGSON.class);
|
||||
private ServletContext context;
|
||||
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
@Value("${data.dir}")
|
||||
String data_dir = "";
|
||||
|
||||
@RequestMapping(value = "/geojson", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object home(@RequestParam(required=false,name="table") String table,@RequestParam(required=false,name="id") String id)
|
||||
@ -44,22 +54,6 @@ public class GeoGSON implements ServletContextAware {
|
||||
boolean error=false;
|
||||
String result="";
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -123,22 +117,6 @@ public class GeoGSON implements ServletContextAware {
|
||||
boolean error=false;
|
||||
String result="OK<br>";
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
|
||||
@ -24,6 +24,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -48,6 +49,15 @@ public class Integration implements ServletContextAware {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Integration.class);
|
||||
private ServletContext context;
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
@Value("${data.dir}")
|
||||
String data_dir = "";
|
||||
|
||||
@RequestMapping(value = "/integration/getByTime", method = RequestMethod.GET,produces = "application/json; charset=utf-8")
|
||||
@ResponseBody
|
||||
public Object getByTime(@RequestParam(required=true,name="token") String token,@RequestParam(required=true,name="timeBegin") String timeBegin,@RequestParam(required=false,name="timeEnd") String timeEnd,@RequestParam(required=false,name="type") String type)
|
||||
@ -86,22 +96,6 @@ public class Integration implements ServletContextAware {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -318,22 +312,6 @@ public class Integration implements ServletContextAware {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -569,23 +547,6 @@ public class Integration implements ServletContextAware {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
|
||||
data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
|
||||
@ -21,6 +21,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@ -48,7 +49,16 @@ public class Products implements ServletContextAware {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Products.class);
|
||||
private ServletContext context;
|
||||
|
||||
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
|
||||
|
||||
//If not created object "user", create him.
|
||||
//@ModelAttribute("user")
|
||||
//public User populatePerson() {
|
||||
@ -62,21 +72,6 @@ public class Products implements ServletContextAware {
|
||||
int errorCode=0;
|
||||
String errorMessage="";
|
||||
|
||||
//Load configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -390,21 +385,6 @@ public class Products implements ServletContextAware {
|
||||
int errorCode=0;
|
||||
String errorMessage="";
|
||||
|
||||
//Load configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -683,23 +663,6 @@ public class Products implements ServletContextAware {
|
||||
int errorCode=0;
|
||||
String errorMessage="";
|
||||
|
||||
//Load configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -842,23 +805,6 @@ public class Products implements ServletContextAware {
|
||||
int errorCode=0;
|
||||
String errorMessage="";
|
||||
|
||||
//Load configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -949,23 +895,6 @@ public class Products implements ServletContextAware {
|
||||
int errorCode=0;
|
||||
String errorMessage="";
|
||||
|
||||
//Load configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
|
||||
@ -23,6 +23,7 @@ import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.HttpEntity;
|
||||
@ -51,7 +52,14 @@ public class QGIS implements ServletContextAware {
|
||||
private Properties m_props=null;
|
||||
private String m_props_loc="";
|
||||
public String m_locale="ru";
|
||||
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
|
||||
//If not created object "user", create him.
|
||||
//@ModelAttribute("user")
|
||||
//public User populatePerson() {
|
||||
@ -66,22 +74,6 @@ public class QGIS implements ServletContextAware {
|
||||
logger.info("user.id="+user.id+" user.name="+user.name+" user.language_id="+user.language_id);
|
||||
m_locale=user.language_id;
|
||||
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -414,7 +406,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
|
||||
//Send data
|
||||
fileAsString=getText(conn,fileAsString,user);
|
||||
fileAsString=trts(conn,fileAsString,user);
|
||||
return new HttpEntity<byte[]>(fileAsString.getBytes(), headers);
|
||||
}
|
||||
|
||||
@ -473,7 +465,7 @@ public class QGIS implements ServletContextAware {
|
||||
}
|
||||
|
||||
//Translate text by patterns
|
||||
public String getText(Connection conn,String text,User user) {
|
||||
public String trts(Connection conn,String text,User user) {
|
||||
int pos1 = 0;
|
||||
while (true) {
|
||||
pos1 = text.indexOf("trt('", pos1);
|
||||
|
||||
@ -10,6 +10,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
@ -42,6 +43,22 @@ public class SendMail implements ServletContextAware {
|
||||
//private Properties m_props=null;
|
||||
public String m_locale="en";
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
String db_url="";
|
||||
@Value("${spring.datasource.username}")
|
||||
String db_login="";
|
||||
@Value("${spring.datasource.password}")
|
||||
String db_password="";
|
||||
|
||||
@Value("${mail.host}")
|
||||
String mail_host = "";
|
||||
@Value("${mail.port}")
|
||||
String mail_port = "";
|
||||
@Value("${mail.login}")
|
||||
String mail_login = "";
|
||||
@Value("${mail.password}")
|
||||
String mail_password = "";
|
||||
|
||||
//private HashMap<String, Properties> m_props = new HashMap< String, Properties>();
|
||||
|
||||
//If not created object "user", create him.
|
||||
@ -61,31 +78,6 @@ public class SendMail implements ServletContextAware {
|
||||
|
||||
String result="";
|
||||
|
||||
//Load DB configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
//String data_dir = "";
|
||||
String mail_host = "";
|
||||
String mail_port = "";
|
||||
String mail_login = "";
|
||||
String mail_password = "";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
//data_dir = prop.getProperty("data.dir");
|
||||
mail_host = prop.getProperty("mail.host");
|
||||
mail_port = prop.getProperty("mail.port");
|
||||
mail_login = prop.getProperty("mail.login");
|
||||
mail_password = prop.getProperty("mail.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
//Connect to database
|
||||
try{
|
||||
Class.forName("org.postgresql.Driver");
|
||||
@ -461,7 +453,7 @@ public class SendMail implements ServletContextAware {
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
//Translate text by patterns
|
||||
public String getText(String text) {
|
||||
public String trts(String text) {
|
||||
int pos1 = 0;
|
||||
while (true) {
|
||||
pos1 = text.indexOf("trt('", pos1);
|
||||
|
||||
@ -39,7 +39,7 @@ public class TestFiles implements ServletContextAware {
|
||||
{
|
||||
String result="";
|
||||
|
||||
//Load DB configuration from "config.xml"
|
||||
/*//Load DB configuration from "config.xml"
|
||||
String db_url="";
|
||||
String db_login="";
|
||||
String db_password="";
|
||||
@ -171,7 +171,7 @@ public class TestFiles implements ServletContextAware {
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: igor
|
||||
* Date: 09.03.2007
|
||||
* Time: 0:53:45
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
package tctable;
|
||||
|
||||
public class Point
|
||||
{
|
||||
public double x=0;
|
||||
public double y=0;
|
||||
}
|
||||
@ -1,574 +0,0 @@
|
||||
package tctable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class TCField
|
||||
{
|
||||
//Типы данных
|
||||
public static final int BD_NULL = 1000; //Столбец со значением всегда NULL
|
||||
public static final int BD_UINT1 = 0; //1 байт без знаковый
|
||||
public static final int BD_UINT2 = 1; //2 байта без знаковый
|
||||
public static final int BD_UINT4 = 3; //4 байта без знаковый
|
||||
public static final int BD_UINT8 = 23; //8 байта без знаковый
|
||||
public static final int BD_SUINT8 = 24; //Почти тоже самое что и BD_UTF8_1 но с строке передаётся число
|
||||
public static final int BD_INT1 = 10; //1 байт со знаковый
|
||||
public static final int BD_INT2 = 11; //2 байта со знаковый
|
||||
public static final int BD_INT4 = 13; //4 байта со знаковый
|
||||
public static final int BD_INT8 = 17; //8 байт со знаковый
|
||||
public static final int BD_SINT8 = 25; //Почти тоже самое что и BD_UTF8_1 но с строке передаётся число
|
||||
public static final int BD_FLOAT4 = 20; //4 байта
|
||||
public static final int BD_FLOAT8 = 22; //8 байт double
|
||||
public static final int BD_SFLOAT8 = 26; //Почти тоже самое что и BD_UTF8_1 но с строке передаётся число
|
||||
public static final int BD_UTF8_1 = 100; //100 - utf8_1 string 1й байт размер строки в байтах
|
||||
public static final int BD_UTF8_2 = 101; //101 - utf8_2 string 1х 2 байта размер строки в байтах
|
||||
public static final int BD_UTF8_4 = 102; //102 - utf8_4 string 1х 4 байта размер строки в байтах
|
||||
public static final int BD_BLOB_2 = 141;
|
||||
public static final int BD_BLOB_4 = 143; //Двоичные данные uint4 количество байт
|
||||
|
||||
public String name=""; //Название столбца
|
||||
public int type=-1; //Тип данных
|
||||
public byte[] value=null; //Запакованые данные
|
||||
|
||||
public TCField(String name, int type)
|
||||
{
|
||||
this.name=name;
|
||||
this.type=type;
|
||||
}
|
||||
|
||||
public TCField(String name, String type)
|
||||
{
|
||||
this.name=name;
|
||||
//this.type=type;
|
||||
|
||||
this.type= TCField.BD_UTF8_2; //Defalt type
|
||||
//From PostgreSQL and MySQL
|
||||
if(type.equals("null")) { this.type= TCField.BD_NULL; } else
|
||||
if(type.equals("bool") || type.equals("tinyint")) { this.type= TCField.BD_UINT1; } else
|
||||
if(type.equals("int4") || type.equals("int") || type.equals("serial") || type.equals("bigint")) { this.type= TCField.BD_INT4; } else //bigint немного неправильно потому что это 64 бита но для андрод приложения не сделал
|
||||
if(type.equals("int8")) { this.type= TCField.BD_INT8; } else
|
||||
if(type.equals("float4") || type.equals("float")) { this.type= TCField.BD_FLOAT4; } else
|
||||
if(type.equals("float8") || type.equals("NUMBER")) { this.type= TCField.BD_FLOAT8; } else
|
||||
if(type.equals("varchar") || type.equals("VARCHAR2")) { this.type= TCField.BD_UTF8_2; } else
|
||||
if(type.equals("text")) { this.type= TCField.BD_UTF8_4; } else
|
||||
if(type.equals("bytea") || type.equals("longblob")) { this.type= TCField.BD_BLOB_4; } else
|
||||
if(type.equals("timestamptz")) { this.type= TCField.BD_UTF8_1; } else
|
||||
if(type.equals("timestamp")) { this.type= TCField.BD_UTF8_1; } else
|
||||
if(type.equals("date")) { this.type= TCField.BD_UTF8_1; }
|
||||
}
|
||||
|
||||
private int byteArrayToInt(byte[] b, int start, int length)
|
||||
{
|
||||
int dt = 0;
|
||||
if ((b[start] & 0x80) != 0)
|
||||
dt = Integer.MAX_VALUE;
|
||||
for (int i = 0; i < length; i++)
|
||||
dt = (dt << 8) + (b[start++] & 255);
|
||||
return dt;
|
||||
}
|
||||
|
||||
/*
|
||||
private byte[] intToByteArray(int n, int byteCount)
|
||||
{
|
||||
byte[] res = new byte[byteCount];
|
||||
for (int i = 0; i < byteCount; i++)
|
||||
res[byteCount - i - 1] = (byte) ((n >> i * 8) & 255);
|
||||
return res;
|
||||
}
|
||||
*/
|
||||
|
||||
//Прочитать значение из потока в соответствии с типом
|
||||
public void ReadValue(InputStream fileHandle) throws IOException
|
||||
{
|
||||
if(this.type== TCField.BD_UINT1)
|
||||
{
|
||||
value=new byte[1];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_UINT2)
|
||||
{
|
||||
value=new byte[2];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_UINT4)
|
||||
{
|
||||
value=new byte[4];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_UINT8)
|
||||
{
|
||||
value=new byte[8];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_INT1)
|
||||
{
|
||||
value=new byte[1];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_INT2)
|
||||
{
|
||||
value=new byte[2];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_INT4)
|
||||
{
|
||||
value=new byte[4];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_INT8)
|
||||
{
|
||||
value=new byte[8];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_FLOAT4)
|
||||
{
|
||||
value=new byte[4];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_FLOAT8)
|
||||
{
|
||||
value=new byte[8];
|
||||
fileHandle.read(value);
|
||||
}else
|
||||
if(this.type== TCField.BD_UTF8_1 || this.type== TCField.BD_SUINT8 || this.type== TCField.BD_SINT8 || this.type== TCField.BD_SFLOAT8)
|
||||
{
|
||||
byte[] s=new byte[1];
|
||||
fileHandle.read(s);
|
||||
if(s[0]==0) value=null;
|
||||
else
|
||||
{
|
||||
value=new byte[s[0]];
|
||||
fileHandle.read(value);
|
||||
}
|
||||
}else
|
||||
if(this.type== TCField.BD_UTF8_2)
|
||||
{
|
||||
int s=Tools.readUShort(fileHandle);
|
||||
if(s==0) value=null;
|
||||
else
|
||||
{
|
||||
value=new byte[s];
|
||||
fileHandle.read(value);
|
||||
}
|
||||
}else
|
||||
if(this.type== TCField.BD_UTF8_4)
|
||||
{
|
||||
long s=Tools.readUInt(fileHandle);
|
||||
if(s==0) value=null;
|
||||
else
|
||||
{
|
||||
value=new byte[(int)s];
|
||||
fileHandle.read(value);
|
||||
}
|
||||
}else
|
||||
if(this.type== TCField.BD_BLOB_4)
|
||||
{
|
||||
byte[] ss=new byte[4];
|
||||
fileHandle.read(ss);
|
||||
int s=byteArrayToInt(ss, 0, 4);
|
||||
if(s==0) value=null;
|
||||
else
|
||||
{
|
||||
value=new byte[s];
|
||||
fileHandle.read(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getStrVal()
|
||||
{
|
||||
String result=null;
|
||||
try
|
||||
{
|
||||
if(value==null) result = "";
|
||||
if(type== TCField.BD_UINT1) result = String.valueOf(getUByteVal());
|
||||
if(type== TCField.BD_UINT4) result = String.valueOf(getUIntVal());
|
||||
if(type== TCField.BD_UINT8) result = String.valueOf(getULongVal());
|
||||
if(type== TCField.BD_INT4) result = String.valueOf(getIntVal());
|
||||
if(type== TCField.BD_INT8) result = String.valueOf(getLongVal());
|
||||
if(type== TCField.BD_FLOAT4) result = String.valueOf(getFloatVal());
|
||||
if(type== TCField.BD_FLOAT8) result = String.valueOf(getDoubleVal());
|
||||
if(type== TCField.BD_UTF8_1 || type== TCField.BD_UTF8_2 || type== TCField.BD_UTF8_4 || type== TCField.BD_SUINT8 || type== TCField.BD_SINT8 || type== TCField.BD_SFLOAT8)
|
||||
{
|
||||
result = new String(value, "UTF8");
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean getBoolVal(){
|
||||
String result=getStrVal();
|
||||
if(result==null)
|
||||
return false;
|
||||
else {
|
||||
result=result.toLowerCase();
|
||||
if (result.equals("1") || result.equals("true") || result.equals("t"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public int getIntVal()
|
||||
{
|
||||
int val=0;
|
||||
if(type==BD_INT4) {
|
||||
int i1 = value[0] & 0xff;
|
||||
int i2 = value[1] & 0xff;
|
||||
int i3 = value[2] & 0xff;
|
||||
int i4 = value[3] & 0xff;
|
||||
val = i4 << 24 | i3 << 16 | i2 << 8 | i1;
|
||||
}else{
|
||||
String sVal = getStrVal();
|
||||
if(sVal!=null) {
|
||||
try {
|
||||
val = Integer.valueOf(sVal);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public long getLongVal()
|
||||
{
|
||||
long val=0;
|
||||
if(type==BD_INT8) {
|
||||
long ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8;
|
||||
ch1 = value[0] & 0xff;
|
||||
ch2 = value[1] & 0xff;
|
||||
ch3 = value[2] & 0xff;
|
||||
ch4 = value[3] & 0xff;
|
||||
ch5 = value[4] & 0xff;
|
||||
ch6 = value[5] & 0xff;
|
||||
ch7 = value[6] & 0xff;
|
||||
ch8 = value[7] & 0xff;
|
||||
val = (ch8 << 56) | (ch7 << 48) | (ch6 << 40) | (ch5 << 32) | (ch4 << 24) | (ch3 << 16) | (ch2 << 8) | ch1;
|
||||
}else{
|
||||
String sVal = getStrVal();
|
||||
if(sVal!=null) {
|
||||
try {
|
||||
val = Long.valueOf(sVal);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/** Пока не использую но если буду использовать протестировать с большими числами */
|
||||
public long getUIntVal()
|
||||
{
|
||||
long val=0;
|
||||
if(type==BD_UINT4) {
|
||||
long ch1, ch2, ch3, ch4;
|
||||
ch1 = value[0] & 0xff;
|
||||
ch2 = value[1] & 0xff;
|
||||
ch3 = value[2] & 0xff;
|
||||
ch4 = value[3] & 0xff;
|
||||
val = (ch4 << 24) | (ch3 << 16) | (ch2 << 8) | ch1;
|
||||
}else{
|
||||
String sVal = getStrVal();
|
||||
if(sVal!=null) {
|
||||
try {
|
||||
val = Long.valueOf(sVal);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public long getULongVal()
|
||||
{
|
||||
long val=0;
|
||||
if(type==BD_UINT8) {
|
||||
long ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8;
|
||||
ch1 = value[0] & 0xff;
|
||||
ch2 = value[1] & 0xff;
|
||||
ch3 = value[2] & 0xff;
|
||||
ch4 = value[3] & 0xff;
|
||||
ch5 = value[4] & 0xff;
|
||||
ch6 = value[5] & 0xff;
|
||||
ch7 = value[6] & 0xff;
|
||||
ch8 = value[7] & 0xff;
|
||||
val = (ch8 << 56) | (ch7 << 48) | (ch6 << 40) | (ch5 << 32) | (ch4 << 24) | (ch3 << 16) | (ch2 << 8) | ch1;
|
||||
}else{
|
||||
String sVal = getStrVal();
|
||||
if(sVal!=null) {
|
||||
try {
|
||||
val = Long.valueOf(sVal);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public short getUByteVal()
|
||||
{
|
||||
short val=0;
|
||||
if(type==BD_UINT1) {
|
||||
val = (short) (value[0] & 0xff);
|
||||
}else{
|
||||
String sVal = getStrVal();
|
||||
if(sVal!=null) {
|
||||
try {
|
||||
val = Short.valueOf(sVal);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public float getFloatVal()
|
||||
{
|
||||
float val=0;
|
||||
if(type==BD_FLOAT4) {
|
||||
int ch1, ch2, ch3, ch4, count;
|
||||
ch1 = value[0] & 0xFF;
|
||||
ch2 = value[1] & 0xFF;
|
||||
ch3 = value[2] & 0xFF;
|
||||
ch4 = value[3] & 0xFF;
|
||||
|
||||
count = (ch4 << 24) | (ch3 << 16) | (ch2 << 8) | ch1;
|
||||
val = Float.intBitsToFloat(count);
|
||||
}else{
|
||||
String sVal = getStrVal();
|
||||
if(sVal!=null) {
|
||||
try {
|
||||
val = Float.valueOf(sVal);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public double getDoubleVal()
|
||||
{
|
||||
double val=0;
|
||||
if(type==BD_FLOAT8) {
|
||||
int ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8;
|
||||
long count;
|
||||
ch1 = value[0] & 0xFF;
|
||||
ch2 = value[1] & 0xFF;
|
||||
ch3 = value[2] & 0xFF;
|
||||
ch4 = value[3] & 0xFF;
|
||||
ch5 = value[4] & 0xFF;
|
||||
ch6 = value[5] & 0xFF;
|
||||
ch7 = value[6] & 0xFF;
|
||||
ch8 = value[7] & 0xFF;
|
||||
count = ((long) ch8 << 56) |
|
||||
((long) ch7 << 48) |
|
||||
((long) ch6 << 40) |
|
||||
((long) ch5 << 32) |
|
||||
((long) ch4 << 24) |
|
||||
((long) ch3 << 16) |
|
||||
((long) ch2 << 8) |
|
||||
ch1;
|
||||
val = Double.longBitsToDouble(count);
|
||||
}else{
|
||||
String sVal = getStrVal();
|
||||
if(sVal!=null) {
|
||||
try {
|
||||
val = Double.valueOf(sVal);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public boolean setDoubleVal(Double v){
|
||||
long iv= Double.doubleToLongBits(v);
|
||||
value=new byte[8];
|
||||
value[0] = (byte)((iv & 0x00000000000000ffl));
|
||||
value[1] = (byte)((iv & 0x000000000000ff00l) >> 8);
|
||||
value[2] = (byte)((iv & 0x0000000000ff0000l) >> 16);
|
||||
value[3] = (byte)((iv & 0x00000000ff000000l) >> 24);
|
||||
value[4] = (byte)((iv & 0x000000ff00000000l) >> 32);
|
||||
value[5] = (byte)((iv & 0x0000ff0000000000l) >> 40);
|
||||
value[6] = (byte)((iv & 0x00ff000000000000l) >> 48);
|
||||
value[7] = (byte)((iv & 0xff00000000000000l) >> 56);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setValue(String val)
|
||||
{
|
||||
boolean result=true;
|
||||
if(val==null)
|
||||
{ value=null;
|
||||
}else if(type== TCField.BD_UINT1)
|
||||
{
|
||||
if(val.equals("f") || val.equals("false")) val="0";
|
||||
else if(val.equals("t") || val.equals("true")) val="1";
|
||||
|
||||
int v= Integer.parseInt(val);
|
||||
if(v<0 || v>255) result=false;
|
||||
value=new byte[1];
|
||||
value[0]=(byte)v;
|
||||
}else if(type== TCField.BD_UINT2)
|
||||
{
|
||||
int v= Integer.parseInt(val);
|
||||
if(v<0 || v>65535) result=false;
|
||||
value=new byte[2];
|
||||
value[0] = (byte)((v & 0x000000ff));
|
||||
value[1] = (byte)((v & 0x0000ff00) >> 8);
|
||||
}else if(type== TCField.BD_UINT4)
|
||||
{
|
||||
long v= Long.parseLong(val);
|
||||
value=new byte[4];
|
||||
value[0] = (byte)((v & 0x000000ff));
|
||||
value[1] = (byte)((v & 0x0000ff00) >> 8);
|
||||
value[2] = (byte)((v & 0x00ff0000) >> 16);
|
||||
value[3] = (byte)((v & 0xff000000) >> 24);
|
||||
}else if(type== TCField.BD_UINT8)
|
||||
{
|
||||
long v= Long.parseLong(val);
|
||||
value=new byte[8];
|
||||
value[0] = (byte) (v & 0x00000000000000ffl);
|
||||
value[1] = (byte)((v & 0x000000000000ff00l) >> 8);
|
||||
value[2] = (byte)((v & 0x0000000000ff0000l) >> 16);
|
||||
value[3] = (byte)((v & 0x00000000ff000000l) >> 24);
|
||||
value[4] = (byte)((v & 0x000000ff00000000l) >> 32);
|
||||
value[5] = (byte)((v & 0x0000ff0000000000l) >> 40);
|
||||
value[6] = (byte)((v & 0x00ff000000000000l) >> 48);
|
||||
value[7] = (byte)((v & 0xff00000000000000l) >> 56);
|
||||
}else if(type== TCField.BD_INT1)
|
||||
{
|
||||
int v= Integer.parseInt(val);
|
||||
value=new byte[1];
|
||||
value[0]=(byte)v;
|
||||
}else if(type== TCField.BD_INT2)
|
||||
{
|
||||
int v= Integer.parseInt(val);
|
||||
value=new byte[2];
|
||||
value[0] = (byte)((v & 0x000000ff));
|
||||
value[1] = (byte)((v & 0x0000ff00) >> 8);
|
||||
}else if(type== TCField.BD_INT4)
|
||||
{
|
||||
long v= Long.parseLong(val);
|
||||
value=new byte[4];
|
||||
value[0] = (byte)((v & 0x000000ff));
|
||||
value[1] = (byte)((v & 0x0000ff00) >> 8);
|
||||
value[2] = (byte)((v & 0x00ff0000) >> 16);
|
||||
value[3] = (byte)((v & 0xff000000) >> 24);
|
||||
}else if(type== TCField.BD_INT8)
|
||||
{
|
||||
long v= Long.parseLong(val);
|
||||
value=new byte[8];
|
||||
value[0] = (byte) (v & 0x00000000000000ffl);
|
||||
value[1] = (byte)((v & 0x000000000000ff00l) >> 8);
|
||||
value[2] = (byte)((v & 0x0000000000ff0000l) >> 16);
|
||||
value[3] = (byte)((v & 0x00000000ff000000l) >> 24);
|
||||
value[4] = (byte)((v & 0x000000ff00000000l) >> 32);
|
||||
value[5] = (byte)((v & 0x0000ff0000000000l) >> 40);
|
||||
value[6] = (byte)((v & 0x00ff000000000000l) >> 48);
|
||||
value[7] = (byte)((v & 0xff00000000000000l) >> 56);
|
||||
}else if(type== TCField.BD_FLOAT4)
|
||||
{
|
||||
Float v= Float.parseFloat(val);
|
||||
int iv= Float.floatToIntBits(v);
|
||||
|
||||
value=new byte[4];
|
||||
value[0] = (byte)((iv & 0x000000ff));
|
||||
value[1] = (byte)((iv & 0x0000ff00) >> 8);
|
||||
value[2] = (byte)((iv & 0x00ff0000) >> 16);
|
||||
value[3] = (byte)((iv & 0xff000000) >> 24);
|
||||
}else if(type== TCField.BD_FLOAT8)
|
||||
{
|
||||
setDoubleVal(Double.parseDouble(val));
|
||||
}else if(type== TCField.BD_UTF8_1 || this.type== TCField.BD_SUINT8 || this.type== TCField.BD_SINT8 || this.type== TCField.BD_SFLOAT8)
|
||||
{
|
||||
value=null;
|
||||
if(val!=null && !val.equals(""))
|
||||
{
|
||||
byte[] b=null;
|
||||
try {
|
||||
b = val.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
result=false;
|
||||
}
|
||||
if(b!=null)
|
||||
{
|
||||
int len=b.length;
|
||||
if(len>255) len=255;
|
||||
value=new byte[len+1];
|
||||
value[0]=(byte)len;
|
||||
for(int i=0;i<len;i++)
|
||||
{
|
||||
value[i+1]=b[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(type== TCField.BD_UTF8_2)
|
||||
{
|
||||
value=null;
|
||||
if(val!=null && !val.equals(""))
|
||||
{
|
||||
byte[] b=null;
|
||||
try {
|
||||
b = val.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
result=false;
|
||||
}
|
||||
if(b!=null)
|
||||
{
|
||||
int len=b.length;
|
||||
if(len>65535) len=65535;
|
||||
value=new byte[len+2];
|
||||
value[0]=(byte) (len & 0x000000ff);
|
||||
value[1]=(byte)((len & 0x0000ff00) >> 8);
|
||||
for(int i=0;i<len;i++)
|
||||
{
|
||||
value[i+2]=b[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(type== TCField.BD_UTF8_4)
|
||||
{
|
||||
value=null;
|
||||
if(val!=null && !val.equals(""))
|
||||
{
|
||||
byte[] b=null;
|
||||
try {
|
||||
b = val.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
result=false;
|
||||
}
|
||||
if(b!=null)
|
||||
{
|
||||
int len=b.length;
|
||||
value=new byte[len+4];
|
||||
value[0]=(byte) (len & 0x000000ff);
|
||||
value[1]=(byte)((len & 0x0000ff00) >> 8);
|
||||
value[2]=(byte)((len & 0x00ff0000) >> 16);
|
||||
value[3]=(byte)((len & 0xff000000) >> 24);
|
||||
for(int i=0;i<len;i++)
|
||||
{
|
||||
value[i+4]=b[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public boolean isNull() {
|
||||
return value==null;
|
||||
}
|
||||
|
||||
public BigDecimal getBigDecimalVal() {
|
||||
BigDecimal val=new BigDecimal("0");
|
||||
String sVal = getStrVal();
|
||||
if(sVal!=null) {
|
||||
try {
|
||||
val = new BigDecimal(sVal);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@ -1,200 +0,0 @@
|
||||
package tctable;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class TCTable
|
||||
{
|
||||
public int id=0; //Идентификатор таблицы
|
||||
public String name=""; //Название таблицы
|
||||
public List<TCField> fields=new ArrayList<TCField>(); //Список полей
|
||||
|
||||
private int nc=0; //Байтов под NULL значения
|
||||
private byte[] m_NULL=null; //NULL значения
|
||||
private InputStream m_file;
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
* @param Строка name Название таблицы
|
||||
* @param Целое id Идентификатор таблицы (обычно уникальный)
|
||||
*/
|
||||
public TCTable(String name, int id)
|
||||
{ this.name=name;
|
||||
this.id=id;
|
||||
}
|
||||
|
||||
//Открыть таблицу по названию файла
|
||||
/*function OpenTableF(file)
|
||||
{
|
||||
if(file_exists(file))
|
||||
{
|
||||
this.OpenTableH(fopen(file,'r'));
|
||||
}
|
||||
}*/
|
||||
|
||||
//Открыть таблицу из потока HANDLE
|
||||
public boolean OpenTableH(InputStream handle) throws IOException
|
||||
{
|
||||
this.m_file=handle;
|
||||
DataInputStream dis = new DataInputStream(handle);
|
||||
|
||||
if(Tools.readUShort(dis)!=65500) return false; //id файла
|
||||
if(Tools.readUShort(dis)!=1) return false; //Версия файла
|
||||
this.id= Tools.readInt(dis); //ID таблицы или запроса (4 байта можно сделать 2)
|
||||
if(dis.readByte()!=0) return false; //Только плотные таблицы
|
||||
//Считываем название таблицы
|
||||
this.name = Tools.readUTF8_1(dis);
|
||||
|
||||
//Считываем столбцы
|
||||
int count=dis.readUnsignedByte(); //Количество столбцов
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
TCField field=new TCField(Tools.readUTF8_1(dis), dis.readUnsignedByte());
|
||||
this.addField(field);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//Открыть таблицу из потока
|
||||
//OpenTable
|
||||
|
||||
//Прочитать следующую запись из потока
|
||||
public boolean ReadNextRecord()
|
||||
{
|
||||
Boolean result=true;
|
||||
try
|
||||
{
|
||||
DataInputStream dis = new DataInputStream(m_file);
|
||||
//if(m_file.available()) return false; //Неработает
|
||||
|
||||
if(dis.available()==0)
|
||||
return false;
|
||||
|
||||
//Считываем NULL значения
|
||||
if(m_NULL==null) m_NULL = new byte[nc];
|
||||
for(int i=0;i<nc;i++)
|
||||
{
|
||||
m_NULL[i]=(byte)dis.readUnsignedByte();
|
||||
}
|
||||
|
||||
clearRows();
|
||||
for(int i=0;i<fields.size();i++)
|
||||
{
|
||||
if(Tools.getBit(m_NULL,i))
|
||||
{
|
||||
fields.get(i).ReadValue(m_file);
|
||||
}
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
result=false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//Добавить поле к таблице
|
||||
public void addField(TCField field)
|
||||
{ if(field!=null)
|
||||
{ fields.add(field);
|
||||
this.nc=(int) Math.ceil(fields.size()/8.0); //Байтов под NULL
|
||||
m_NULL=new byte[nc];
|
||||
}
|
||||
}
|
||||
|
||||
//Получить заголовок плотной таблицы в виде двоичной строки
|
||||
public boolean getHeader(OutputStream os)
|
||||
{
|
||||
boolean result=true;
|
||||
try {
|
||||
//File ID: 2 bytes.
|
||||
os.write((65500 & 0x000000ff));
|
||||
os.write((65500 & 0x0000ff00) >> 8);
|
||||
//File version: 2 bytes.
|
||||
os.write((1 & 0x000000ff));
|
||||
os.write((1 & 0x0000ff00) >> 8);
|
||||
//Table ID (or Request ID): 4 bytes.
|
||||
os.write((this.id & 0x000000ff));
|
||||
os.write((this.id & 0x0000ff00) >> 8);
|
||||
os.write((this.id & 0x00ff0000) >> 16);
|
||||
os.write((this.id & 0xff000000) >> 24);
|
||||
//Table type: 1 byte (0- "Dense" 1- "Loose")
|
||||
os.write(0);
|
||||
//UTF8_1 String
|
||||
byte[] ba = this.name.getBytes("UTF-8");
|
||||
os.write(ba.length);
|
||||
os.write(ba);
|
||||
//Count of fields: 1 byte.
|
||||
os.write(this.fields.size());
|
||||
//Write name and type id
|
||||
for(int i=0;i<this.fields.size();i++)
|
||||
{
|
||||
ba = this.fields.get(i).name.getBytes("UTF-8");
|
||||
os.write(ba.length);
|
||||
os.write(ba);
|
||||
os.write(this.fields.get(i).type);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
result=false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//Получить данные 1 записи в виде строки
|
||||
public boolean getCol(OutputStream os)
|
||||
{
|
||||
boolean result=true;
|
||||
//Запишем NULL значения побайтно (1-есть данные 0-нету данных)
|
||||
int nc=(int) Math.ceil(fields.size()/8.0); //Байтов под NULL
|
||||
byte[] fNULL=new byte[nc];
|
||||
for(int i=0;i<nc*8;i++)
|
||||
{
|
||||
if(i<this.fields.size() && this.fields.get(i).value!=null)
|
||||
{
|
||||
Tools.setBit(fNULL,i);
|
||||
}
|
||||
}
|
||||
//Write NULL fields
|
||||
try {
|
||||
os.write(fNULL);
|
||||
} catch (IOException e1) {
|
||||
result=false;
|
||||
}
|
||||
//Запишем сами данные в строку
|
||||
for(int i=0;i<fields.size();i++)
|
||||
{
|
||||
try {
|
||||
if(fields.get(i).value!=null)
|
||||
os.write(fields.get(i).value);
|
||||
} catch (IOException e) {
|
||||
result=false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//Row очистить запись
|
||||
void clearRows()
|
||||
{ for(int i=0;i<fields.size();i++)
|
||||
{
|
||||
fields.get(i).value=null;
|
||||
}
|
||||
}
|
||||
|
||||
//Получить обьект столбца по имени
|
||||
public TCField getRowByName(String name)
|
||||
{ for(int i=0;i<fields.size();i++)
|
||||
{ if(fields.get(i).name.toUpperCase().equals(name.toUpperCase())) return fields.get(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Получить объект столбца по номеру
|
||||
TCField getRowByNum(int num)
|
||||
{ return fields.get(num);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
package tctable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.sql.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
//В андроид не используется данный класс
|
||||
public class TCTableTools {
|
||||
|
||||
//Записать таблицу в OutputStream
|
||||
public static boolean getTCTableFromResultSet(String name, int id, ResultSet rs, OutputStream os){
|
||||
TCTable tbl=new TCTable(name,id);
|
||||
try {
|
||||
ResultSetMetaData rsmd = rs.getMetaData();
|
||||
for(int i=1;i<=rsmd.getColumnCount();i++)
|
||||
{
|
||||
TCField field = new TCField(rsmd.getColumnName(i), rsmd.getColumnTypeName(i));
|
||||
tbl.addField(field);
|
||||
}
|
||||
tbl.getHeader(os);
|
||||
while (rs.next())
|
||||
{
|
||||
for(int i=1;i<=rsmd.getColumnCount();i++)
|
||||
{
|
||||
if(rsmd.getColumnTypeName(i).equals("geometry")) { //Геометрию не сохраняю пока не знаю как лучьше сохранять
|
||||
tbl.fields.get(i - 1).setValue(null);
|
||||
}else {
|
||||
tbl.fields.get(i - 1).setValue(rs.getString(i));
|
||||
}
|
||||
}
|
||||
tbl.getCol(os);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Напиши функцию: Получить ассоциативный массив название полей таблицы и их тип
|
||||
public static Map<String, String> getTableSchema(Connection connection, String schemaName, String tableName) {
|
||||
Map<String, String> schemaMap = new HashMap<>();
|
||||
String query = """
|
||||
SELECT c.column_name,
|
||||
CASE
|
||||
WHEN t.typtype = 'e' THEN 'enum'
|
||||
WHEN t.typname = 'USER-DEFINED' THEN
|
||||
(SELECT pt.typname FROM pg_type pt WHERE pt.oid = c.udt_name::regtype::oid)
|
||||
ELSE t.typname
|
||||
END as data_type
|
||||
FROM information_schema.columns c
|
||||
JOIN pg_type t ON c.udt_name = t.typname
|
||||
WHERE c.table_schema = ?
|
||||
AND c.table_name = ?
|
||||
""";
|
||||
try (PreparedStatement statement = connection.prepareStatement(query)) {
|
||||
statement.setString(1, schemaName);
|
||||
statement.setString(2, tableName);
|
||||
try (ResultSet resultSet = statement.executeQuery()) {
|
||||
while (resultSet.next()) {
|
||||
String columnName = resultSet.getString("column_name");
|
||||
String columnType = resultSet.getString("data_type");
|
||||
schemaMap.put(columnName, columnType);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return schemaMap;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -189,6 +189,10 @@ var g_user=null;
|
||||
//var m_FrmLocustDel=null;
|
||||
var g_FrmCheckpoints=null;
|
||||
|
||||
var g_WeaLegend=null; //Legends
|
||||
var g_AirLegend=null;
|
||||
var g_PreLegend=null;
|
||||
var g_HTCLegend=null;
|
||||
|
||||
//Decode URL parameters.
|
||||
var GET = {};
|
||||
@ -376,7 +380,7 @@ function onLoadPage()
|
||||
<option value="11">Armenian Հայերեն</option>
|
||||
<option value="5">Georgian ქართული </option>
|
||||
<option value="6">Kyrgyz Кыргыз</option>
|
||||
<option value="2">kk (test)</option>
|
||||
<option value="2">Kazakh Қазақ</option>
|
||||
<option value="10">Dari دری</option>
|
||||
<option value="7">Tajik Тоҷикӣ</option>
|
||||
<option value="8">Turkman Türkmen</option>
|
||||
@ -403,14 +407,12 @@ function onLoadPage()
|
||||
|
||||
<div style="position: relative; padding-bottom:10px;">
|
||||
<b style="text-align:left; font-weight:bold;" th:text="${Substrate}"></b>
|
||||
|
||||
<table border="0" style="width: 100%;"><tr><td style="padding: 2px;">
|
||||
<select id="SubstrateID" style="width:100%;" onchange="changeMap();">
|
||||
<option value="OpenStreetMap">OpenStreetMap</option>
|
||||
<option value="BingAerial">Bing aerial</option>
|
||||
<!--option value="yandex">Yandex maps</option-->
|
||||
<option value="StamenTerrain">Thunderforest Landscape</option>
|
||||
<span th:text="${Substrate_head}">Substrate_head</span>
|
||||
</select>
|
||||
</td><td style="padding: 2px; width: 30px;">
|
||||
<button class="main" style="width:30px;" onclick="openLayoutsWin();">...</button><br>
|
||||
@ -438,7 +440,7 @@ function onLoadPage()
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 1px; white-space: nowrap;" th:text="${Method_filling_form}">Method_filling_form</td>
|
||||
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="filter_X1_device_id"><option value=""><span th:text="${From_PDA}">From_PDA</span> & <span th:text="${From_WEB_interface}">From_WEB_interface</span></option><option value="1" th:text="${From_PDA}">From_PDA</option><option value="0" th:text="${From_WEB_interface}">From_WEB_interface</option><option value="2" th:text="${Test_questionnaires}">Test_questionnaires</option></select></td>
|
||||
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="filter_X1_device_id"><option value="" th:text="${From_PDA} + ' & ' + ${From_WEB_interface}">From_PDA & From_WEB_interface</option><option value="1" th:text="${From_PDA}">From_PDA</option><option value="0" th:text="${From_WEB_interface}">From_WEB_interface</option><option value="2" th:text="${Test_questionnaires}">Test_questionnaires</option></select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 1px; white-space: nowrap;" th:text="${PDA_registered}">PDA_registered</td>
|
||||
@ -574,7 +576,7 @@ if(field!=null)
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 1px; white-space: nowrap;" th:text="${Method_filling_form}">Method_filling_form</td>
|
||||
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="filter_X2_device_id"><option value=""><span th:text="${From_PDA}">From_PDA</span> & <span th:text="${From_WEB_interface}">From_WEB_interface</span></option><option value="1" th:text="${From_PDA}">From_PDA</option><option value="0" th:text="${From_WEB_interface}">From_WEB_interface</option><option value="2" th:text="${Test_questionnaires}">Test_questionnaires</option></select></td>
|
||||
<td style="padding: 1px; width: 100%;"><select style="width: 100%;" id="filter_X2_device_id"><option value="" th:text="${From_PDA} + ' & ' + ${From_WEB_interface}">From_PDA & From_WEB_interface</option><option value="1" th:text="${From_PDA}">From_PDA</option><option value="0" th:text="${From_WEB_interface}">From_WEB_interface</option><option value="2" th:text="${Test_questionnaires}">Test_questionnaires</option></select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 1px; white-space: nowrap;" th:text="${PDA_registered}">PDA_registered</td>
|
||||
@ -1164,15 +1166,16 @@ new Calendar({
|
||||
<tr>
|
||||
<td style="padding: 1px; width: 158px; white-space: nowrap;" th:text="${Year}">Year</td>
|
||||
<td style="padding: 1px;">
|
||||
<select style="width: 100%;" id="filter_ivi_year">
|
||||
<option value="2023_03_05">2023 (<span th:text="${month}">month<span> 03..05)</option>
|
||||
<option value="2023_02_04">2023 (<span th:text="${month}">month<span> 02..04)</option>
|
||||
<select style="width: 100%;" id="filter_ivi_year">
|
||||
<option value="2023_03_05">2023 (03..05)</option>
|
||||
<option value="2023_02_04">2023 (02..04)</option>
|
||||
|
||||
<option value="2022_02_04">2022 (<span th:text="${month}">month<span> 02..04)</option>
|
||||
<option value="2022_03_05">2022 (<span th:text="${month}">month<span> 03..05)</option>
|
||||
<option value="2022_04_06">2022 (<span th:text="${month}">month<span> 04..06)</option>
|
||||
<option value="2022_05_07">2022 (<span th:text="${month}">month<span> 05..07)</option>
|
||||
<option value="2022_02_04">2022 (02..04)</option>
|
||||
<option value="2022_03_05">2022 (03..05)</option>
|
||||
<option value="2022_04_06">2022 (04..06)</option>
|
||||
<option value="2022_05_07">2022 (05..07)</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -1825,6 +1828,16 @@ map.on('singleclick', function(evt){ //map.on('click', function(evt){
|
||||
//$(element).popover('destroy');
|
||||
//popup.setPosition(coordinate);
|
||||
//$(popup.getElement()).show();
|
||||
|
||||
{
|
||||
let center = ol.proj.transform(coordinate, 'EPSG:3857', 'EPSG:4326')
|
||||
if (g_WeaLegend!=null && g_WeaLegend.visible) alert("g_WeaLegend");
|
||||
if (g_AirLegend!=null && g_AirLegend.visible) alert("g_AirLegend");
|
||||
if (g_PreLegend!=null && g_PreLegend.visible) alert("g_PreLegend");
|
||||
|
||||
|
||||
//alert("lat = "+center[1]+" lon = "+center[0])
|
||||
}
|
||||
|
||||
if(g_FrmCheckpoints!=null){
|
||||
let center = ol.proj.transform(coordinate, 'EPSG:3857', 'EPSG:4326')
|
||||
|
||||
Reference in New Issue
Block a user