Skip to content

Commit

Permalink
Habilitada la descarga de FeatureIDE
Browse files Browse the repository at this point in the history
  • Loading branch information
Enriquelp committed Jan 31, 2024
1 parent dcfe862 commit 28cd896
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from .glencoe_reader import GlencoeReader
from .json_reader import JSONReader
from .json_writer import JSONWriter
from .featureide_writer import FeatureIDEWriter


__all__ = ['GlencoeReader',
'JSONReader',
'JSONWriter']
'JSONWriter',
'FeatureIDEWriter']
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ def __init__(self, path: str, source_model: FeatureModel) -> None:
self.source_model = source_model

def transform(self) -> str:
return _to_featureidexml(self.source_model).write(self.path)
# xml_str = _to_featureidexml(self.source_model).__str__()
# print(xml_str)
# if self.path is not None:
# with open(self.path, 'w', encoding='utf8') as file:
# file.write(xml_str,indent=4)
# return xml_str
# return _to_featureidexml(self.source_model).write(self.path)


if self.path is not None:
et = _to_featureidexml(self.source_model).getroot()
xml_str = ET.tostring(et, encoding='unicode', method='xml')
# with open(self.path, 'w', encoding='utf8') as file:
# file.write(xml_str)

return xml_str


def _to_featureidexml(feature_model: FeatureModel):
Expand Down
7 changes: 6 additions & 1 deletion rhea-backend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
SPLOTWriter
)

from rhea.metamodels.fm_metamodel.transformations import JSONWriter, JSONReader
from rhea.metamodels.fm_metamodel.transformations import JSONWriter, JSONReader, FeatureIDEWriter
from rhea.refactorings import utils
from rhea import refactorings

Expand Down Expand Up @@ -174,6 +174,9 @@ def write_fm_file(fm: FeatureModel, format: str) -> str:
result = SPLOTWriter(source_model=fm, path=temporal_filepath).transform()
elif format == 'json':
result = JSONWriter(source_model=fm, path=None).transform()
elif format == 'xml':
temporal_filepath = tempfile.NamedTemporaryFile(mode='w', encoding='utf8').name
result = FeatureIDEWriter(source_model=fm, path=temporal_filepath).transform()
return result

@app.route('/api/getExampleFMs', methods=['GET'])
Expand Down Expand Up @@ -322,9 +325,11 @@ def download_feature_model():
print('FM expired.')
return jsonify({'error': f'FM expired for hash "{fm_hash}"'}), 404
fm_str = write_fm_file(fm, fm_format)
# print(fm_str)
if fm_str is None:
return jsonify({'error': 'Object not found'}), 404
response = make_response(fm_str)
print(response.data)
return response


Expand Down
50 changes: 23 additions & 27 deletions rhea-web/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,31 @@ export class AppComponent {



// urldownload="http://127.0.0.1:5000/api/downloadFM"
// urldocuments="http://127.0.0.1:5000/api/getExampleFMs"
// urluploadExampleFM="http://127.0.0.1:5000/api/uploadExampleFM"
// urlupload="http://127.0.0.1:5000/api/uploadFM"
// urlrefactor="http://127.0.0.1:5000/api/refactor"
// urlupdate="http://127.0.0.1:5000/api/updateFM"
// urlcur="http://127.0.0.1:5000/api/getCur" //<---"https://rhea.caosd.lcc.uma.es/getCur"
// urlinsertcur="http://127.0.0.1:5000/api/insertIntoRepository" //<---"https://rhea.caosd.lcc.uma.es/insertIntoRepository"
// urlgetfile="http://127.0.0.1:5000/api/getFile"
// urltextcons="http://127.0.0.1:5000/api/checktextcons" //<--- "https://rhea.caosd.lcc.uma.es/checktextcons"
// urlnewcons="http://127.0.0.1:5000/api/createcons" //<--- https://rhea.caosd.lcc.uma.es/
urldownload="http://127.0.0.1:5000/api/downloadFM"
urldocuments="http://127.0.0.1:5000/api/getExampleFMs"
urluploadExampleFM="http://127.0.0.1:5000/api/uploadExampleFM"
urlupload="http://127.0.0.1:5000/api/uploadFM"
urlrefactor="http://127.0.0.1:5000/api/refactor"
urlupdate="http://127.0.0.1:5000/api/updateFM"
urlcur="http://127.0.0.1:5000/api/getCur" //<---"https://rhea.caosd.lcc.uma.es/getCur"
urlinsertcur="http://127.0.0.1:5000/api/insertIntoRepository" //<---"https://rhea.caosd.lcc.uma.es/insertIntoRepository"
urlgetfile="http://127.0.0.1:5000/api/getFile"
urltextcons="http://127.0.0.1:5000/api/checktextcons" //<--- "https://rhea.caosd.lcc.uma.es/checktextcons"
urlnewcons="http://127.0.0.1:5000/api/createcons" //<--- https://rhea.caosd.lcc.uma.es/

// FOR DEVELOPER: for any new url the backend get , it must be update in the apache2 file for the web to work in de sites-available domain.conf, then restart apache, and the frontend and backend"

urldownload="https://rhea.caosd.lcc.uma.es/api/downloadFM"
urldocuments="https://rhea.caosd.lcc.uma.es/api/getExampleFMs"
urluploadExampleFM="https://rhea.caosd.lcc.uma.es/api/uploadExampleFM"
urlupload="https://rhea.caosd.lcc.uma.es/api/uploadFM"
urlrefactor="https://rhea.caosd.lcc.uma.es/api/refactor"
urlupdate="https://rhea.caosd.lcc.uma.es/api/updateFM"
urlcur="https://rhea.caosd.lcc.uma.es/api/getCur" //404
urlinsertcur="https://rhea.caosd.lcc.uma.es/api/insertIntoRepository" //404
urlgetfile="https://rhea.caosd.lcc.uma.es/api/getFile"
urltextcons="https://rhea.caosd.lcc.uma.es/api/checktextcons" //404
urlnewcons="https://rhea.caosd.lcc.uma.es/api/createcons" //404
// urldownload="https://rhea.caosd.lcc.uma.es/api/downloadFM"
// urldocuments="https://rhea.caosd.lcc.uma.es/api/getExampleFMs"
// urluploadExampleFM="https://rhea.caosd.lcc.uma.es/api/uploadExampleFM"
// urlupload="https://rhea.caosd.lcc.uma.es/api/uploadFM"
// urlrefactor="https://rhea.caosd.lcc.uma.es/api/refactor"
// urlupdate="https://rhea.caosd.lcc.uma.es/api/updateFM"
// urlcur="https://rhea.caosd.lcc.uma.es/api/getCur" //404
// urlinsertcur="https://rhea.caosd.lcc.uma.es/api/insertIntoRepository" //404
// urlgetfile="https://rhea.caosd.lcc.uma.es/api/getFile"
// urltextcons="https://rhea.caosd.lcc.uma.es/api/checktextcons" //404
// urlnewcons="https://rhea.caosd.lcc.uma.es/api/createcons" //404

declare actual:FMTree
declare actualfather:FMTree
Expand Down Expand Up @@ -311,10 +311,6 @@ Save(text:number){
if(this.myfile_name==""){
this.myfile_name=this.title
}
if(this.jsonLanguageextension[text].extension=="xml"){
alert("This langauge is not available yet")
}
else{
console.log(this.myfile_name)
this.loglist.unshift("File "+this.myfile_name+" download as ."+this.jsonLanguageextension[text].extension)
this.loadingmodal=false
Expand All @@ -328,7 +324,7 @@ Save(text:number){
saveAs(file, this.myfile_name+ "."+this.jsonLanguageextension[text].extension)
}
)
}

}

sendFile(uvl:any){
Expand Down

0 comments on commit 28cd896

Please sign in to comment.