summaryrefslogtreecommitdiff
path: root/transex3/java/receditor/java/transex3/model/SdfString.java
blob: 7419aeb5578be31aefc1e03bf7d82ffd65811572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package transex3.model;
import java.util.*;
import java.io.*;
public class SdfString {
    private SdfEntity sourceString                  = null;
    //private java.util.HashMap languageStrings     = new HashMap();
    private Vector languageList                     = new Vector();
    private String id                               = null;
    private String fileid                           = null;
    private String filename                         = null;
    private String modulename                       = null;
    private String filepath                         = null;

    /*public HashMap getLanguageStrings() {
        return languageStrings;
    }*/
    public Vector getLanguageStrings() {
        return languageList;
    }

    public void setLanguageStrings(Vector languageStrings) {
        this.languageList = languageStrings;
    }

    public void addSourceString( SdfEntity aSdfEntity )
    {
        if( id == null )
            id = aSdfEntity.getId();
        if ( fileid == null )
            fileid = aSdfEntity.getFileId();
        if( modulename == null )
            modulename = aSdfEntity.getProject();
        if( filename == null )
            filename = aSdfEntity.getSource_file();
        if( filepath == null )
            filepath = aSdfEntity.getResourcePath();
        setSourceString( aSdfEntity );
    }
    public void addLanguageString( SdfEntity aSdfEntity ){
        if( !aSdfEntity.getLangid().equals( "en-US" ) )
        {
            if( id == null )
                id = aSdfEntity.getId();
            if ( fileid == null )
                fileid = aSdfEntity.getFileId();
            if( modulename == null )
                modulename = aSdfEntity.getProject();
            if( filename == null )
                filename = aSdfEntity.getSource_file();
            if( filepath == null )
                filepath = aSdfEntity.getResourcePath();

            //if( aSdfEntity.getLangid().equals( "en-US" ) )
            //{
            //    setSourceString( aSdfEntity );
            //}
            //else
            //{
            //languageStrings.put( aSdfEntity.getLangid() , aSdfEntity );
            languageList.add( aSdfEntity );
            //}
        id = aSdfEntity.getId();
        }
    }

    public SdfEntity getSourceString() {
        return sourceString;
    }

    public void setSourceString(SdfEntity sourceString) {
        this.sourceString = sourceString;
        id = sourceString.getId();
    }
    public String getFilePath(){
        return filepath;
    }
    public String getId(){
        //return id;
        return sourceString.getId();
    }
    public String getFileId(){
        return fileid;
    }

    public String getFileName() {
        return filename;
    }

    public void setFileName(String filename) {
        this.filename = filename;
    }

    public String getModuleName() {
        return modulename;
    }

    public void setModuleName(String modulename) {
        this.modulename = modulename;
    }
    /*
    public String getRealFileName(){
        //String srcroot   = "U:\\cws01\\l10ncleanup\\SRC680\\src.m213";//java.lang.System.getProperty( "SOLARSRC");
        //String isWindows = "4nt";//java.lang.System.getProperty( "USE_SHELL");
        String srcroot   = java.lang.System.getProperty( "SOLARSRC" );
        String isWindows = java.lang.System.getProperty( "USE_SHELL" );

        //System.out.println("srcroot="+srcroot+" isWindows="+isWindows );
        //if( true ) return;
        //String relpath   = sourceString.getFileId().substring( sourceString.getFileId().lastIndexOf("\\")
        //                                                   , sourceString.getFileId().length() );
        String filename;
        if( isWindows != null && isWindows.compareTo( "4nt") == 0 )
        {
            filename = srcroot + "\\" + //sourceString.getProject() + "\\" +
                       sourceString.getFileId() +".recommand";
        }
        else
        {
            String filepart = sourceString.getFileId();
            filepart = filepart.replaceAll( "\\\\" , "/" );
            filename = srcroot + "/" + //sourceString.getProject() + "//" +
                       filepart +".recommand";
        }
        return filename;
    }*/
    public String getRealFileName(){
        String filepart = sourceString.getFileId();
        filepart = filepart.replaceAll( "\\\\" , "_" );
        String filename = "/so/ws/merge/In/" +  java.lang.System.getProperty( "WORK_STAMP" ) + "/" + filepart + ".sdf";
        return filename;
    }
    public void removeFile(){
        String filename = getRealFileName();
        File aFile = new File( filename );
        if( aFile.exists() ){
            if( ! aFile.delete() )
            {
                System.out.println("Can't delete File "+filename+"\nWrong access rights?\n");
            }
        }
    }
    public void writeString(){
        String filename = getRealFileName();
        try {
            if( languageList.size() > 0 )
            {
                System.out.print("\nWrite to "+filename );
                BufferedWriter aBW = new BufferedWriter( new FileWriter( filename , true) );
                aBW.write( sourceString + "\n" );
                Iterator aIter = languageList.iterator();
                while( aIter.hasNext() ){
                    SdfEntity aEntity = (SdfEntity)aIter.next();
                    aBW.write( sourceString.getProject()+"\t"   );
                    aBW.write( sourceString.getSource_file()+"\t"   );
                    aBW.write( sourceString.getDummy1()+"\t"    );
                    aBW.write( sourceString.getResource_type()+"\t" );
                    aBW.write( sourceString.getGid()+"\t"       );
                    aBW.write( sourceString.getLid()+"\t"       );
                    aBW.write( sourceString.getHelpid()+"\t"    );
                    aBW.write( sourceString.getPlatform()+"\t"  );
                    aBW.write( sourceString.getDummy2()+"\t"    );
                    if( aEntity.getLangid() == null )
                        aBW.write( "\t"  );
                    else
                        aBW.write( aEntity.getLangid()+"\t"    );
                    if( aEntity.getText() == null )
                        aBW.write( "\t"  );
                    else
                        aBW.write( aEntity.getText()+"\t"           );
                    if( aEntity.getHelptext() == null )
                        aBW.write( "\t"  );
                    else
                        aBW.write( aEntity.getHelptext()+"\t"       );
                    if( aEntity.getQuickhelptext() == null )
                        aBW.write( "\t"  );
                    else
                        aBW.write( aEntity.getQuickhelptext()+"\t"  );
                    if( aEntity.getTitle() == null )
                        aBW.write( "\t"  );
                    else
                        aBW.write( aEntity.getTitle()+"\t"          );
                    aBW.write( "2002-02-02 02:02:02\n"          );
                }
                aBW.close();
            }
        } catch (IOException e) {
                // TODO Auto-generated catch block
                //e.printStackTrace();
                System.out.println("\nERROR: Can't write to file '"+filename+"'\nPlease contact RE/Tooling!");
        }
    }
}