Changeset 1838


Ignore:
Timestamp:
04/02/12 21:09:37 (12 years ago)
Author:
gaba
Message:

comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/model/WorkspaceProfile.java

    r1835 r1838  
    1111import java.text.SimpleDateFormat;
    1212import java.util.Date;
    13 import java.util.HashMap;
    1413
    1514import javax.xml.namespace.QName;
     
    4544
    4645/**
    47  
     46 * Main WorkspaceProfile functionality, it means loading data from file to DOM Document,
     47 * retrieving data or  data parts  as XMLStream and possibilities of save changed or
     48 * new XML elements.
     49 * 
     50 * @author gaba
    4851 */
    4952
     
    7376        public static String SERVER = "server";
    7477       
     78        // xpaths definitions for lookup in workspaceprofile
    7579        public static String XPATH_EXPR_WORKSPACE = "//Profiles/WorkspaceProfiles/WorkspaceProfile[@user='dummy']";
    7680        public static String XPATH_EXPR_REPOSITORIES = "//Profiles/WorkspaceProfiles/WorkspaceProfile[@user='server']/Repositories";
     
    116120        }
    117121
     122        /**
     123         * Contructor provides initialisation.
     124         *
     125         * @return
     126         */
    118127        public WorkspaceProfile() {
    119128                Init();
    120129        }
    121130       
     131        /**
     132         * Instance of WorkspaceProfile is created.
     133         *
     134         * @return
     135         */
    122136        public static WorkspaceProfile getWorkspaceProfile() {
    123137                if (singleton == null) {
     
    127141        }
    128142       
     143        /**
     144         * Initialisation constists of
     145         * a) loading configuration
     146         * b) setting up the filename of workspaceprofile.xml
     147         * c) calling the document initialisation
     148         *
     149         */
    129150        public void Init(){
    130151                //configure
     
    138159        }
    139160       
     161        /**
     162         * Initialisation of the DOM Document, representation  of the XML file.
     163         * If none workspaceprofile.xml exists, the new  DOM document containig profile data is
     164         * created and saved as WorkspaceProfile.xml
     165         *
     166         */
    140167        public void initDocument() {
    141168               
     
    201228                }
    202229
     230        /**
     231         * Saving DOM Document representing workspace data into WorkspaceProfile.xml
     232         */
    203233        public void saveDocument() {
    204234                //public void writeQuerycounter (Integer i) {           
     
    250280        }
    251281       
     282        /**
     283         * Creates the XPath expression text from constant-defined text by replacing the 'dummy'
     284         *
     285         * @param xpath_expr
     286         * @param new_dummy
     287         * @return
     288         */
    252289        public String getXPathExpressionDummy(String xpath_expr, String new_dummy){
    253290
     
    255292        }
    256293
     294        /**
     295         * TODO Utils ?
     296         * Apply the xpath expression to retrieve the particular data from the workspace.
     297         *
     298         * @param xpath_str
     299         * @param type
     300         * @return
     301         * @throws XPathExpressionException
     302         */
    257303        public Object getWorkspaceData(String xpath_str, QName type) throws XPathExpressionException{
    258304                XPathFactory factory = XPathFactory.newInstance();
     
    270316             return result;
    271317        }
    272        
     318        /*
     319         * Creates new workspaceprofile structure.
     320         *
     321         */
    273322        public void addWorkspaceToDocument(){
    274323                //{'WorkspaceProfile':{'CustomTermsets':'null',
     
    311360        }
    312361       
     362        /**
     363         *
     364         * Creates the XMLStream from the particular part of the workspaceprofile
     365         * according the xpath expression text.
     366         * If document is empty, none data is retrieved the new document is created.
     367         */
    313368        public InputStream getXMLStream(String xpath_expr) throws XPathExpressionException, TransformerConfigurationException, TransformerException, TransformerFactoryConfigurationError{
    314369                InputStream is;
     
    368423        }
    369424       
     425        /**
     426         * Save the data of the profile element defined in  json structure into DOM document , which
     427         * represents the workspaceprofile.
     428         *
     429         * @param jsonData
     430         * @return
     431         * @throws ParserConfigurationException
     432         * @throws SAXException
     433         * @throws IOException
     434         * @throws DOMException
     435         * @throws XPathExpressionException
     436         * @throws TransformerException
     437         * @throws TransformerFactoryConfigurationError
     438         */
    370439        public  String save(String jsonData) throws ParserConfigurationException, SAXException, IOException, DOMException, XPathExpressionException, TransformerException, TransformerFactoryConfigurationError{
    371440               
     
    401470        }
    402471       
     472        /**
     473         * Appends or replace the profile element (new_doc) into workspaceprofile DOM Document.
     474         *
     475         * @param new_doc
     476         * @return
     477         * @throws XPathExpressionException
     478         */
    403479        public  String  DocumentReplaceNewElement(Document new_doc) throws XPathExpressionException{
    404480                String newid = "";
Note: See TracChangeset for help on using the changeset viewer.