public override void WriteAttributeContent(PhaidraFile file, Dictionary <string, string> values)
        {
            string phaidraId = GetStringValue(values, CONST_phaidraid);

            if (!string.IsNullOrEmpty(phaidraId))
            {
                file.PhaidraId = phaidraId;
            }
        }
Пример #2
0
        public override void WriteAttributeContent(PhaidraFile file, Dictionary <string, string> values)
        {
            string collection = GetStringValue(values, CONST_collection);

            if (!string.IsNullOrEmpty(collection))
            {
                file.CollectionPath = collection.Replace("\\", "/");
            }
            else
            {
                file.Errors.Add("no collection set");
            }
        }
Пример #3
0
        public override void WriteAttributeContent(PhaidraFile file, Dictionary <string, string> values)
        {
            string organization = GetStringValue(values, CONST_organizationname);

            var metadata = GetOrCreateProperty <JObject>(file.Metadata, "metadata");

            if (!string.IsNullOrEmpty(organization))
            {
                if (PhaidraAttributesCache.OrganizationName2OrganizazionDict.TryGetValue(organization, out JObject orgObj))
                {
                    JValue oracleIdVal = orgObj.SelectToken("oracle_id") as JValue;

                    if (oracleIdVal != null)
                    {
                        if (oracleIdVal.Value <string>().Equals("A-1"))
                        {
                            metadata.Add(new JProperty("rights", new JObject
                                                       (
                                                           new JProperty("faculty", new JArray
                                                                         (
                                                                             new JObject(new JProperty("value", oracleIdVal.Value <string>()))
                                                                         )
                                                                         ))));
                        }
                        else
                        {
                            metadata.Add(new JProperty("rights", new JObject
                                                       (
                                                           new JProperty("department", new JArray
                                                                         (
                                                                             new JObject(new JProperty("value", oracleIdVal.Value <string>()))
                                                                         )
                                                                         ))));
                        }
                    }

                    /*
                     * "rights": {
                     * "department": [
                     *  {
                     *    "value": "12345"
                     *  }
                     * ]
                     * }
                     *
                     */
                }
            }
        }
        public override void WriteAttributeContent(PhaidraFile file, Dictionary <string, string> values)
        {
            string organization = GetStringValue(values, CONST_organizationname);

            var jsonLd = GetJsonLd(file.Metadata);

            if (!string.IsNullOrEmpty(organization))
            {
                JArray associationArray = GetOrCreateProperty <JArray>(jsonLd, "rdax:P00009");

                JObject associationObj = new JObject
                                         (
                    new JProperty("@type", "foaf:Organization"),
                    new JProperty("skos:prefLabel", new JArray(new JObject(new JProperty("@value", organization), new JProperty("@language", "deu"))))
                                         );

                if (PhaidraAttributesCache.OrganizationName2OrganizazionDict.TryGetValue(organization, out JObject orgObj))
                {
                    JValue idVal = orgObj.SelectToken("id") as JValue;
                    //JValue oracleIdVal = orgObj.SelectToken("oracle_id") as JValue;

                    if (idVal != null)
                    {
                        associationObj.Add(new JProperty("skos:exactMatch", new JArray(idVal.Value <string>())));
                    }
                }
                associationArray.Add(associationObj);
            }

            /*
             *
             * "rdax:P00009": [
             * {
             * "@type": "foaf:Organization",
             * "skos:prefLabel": [
             *  {
             *    "@value": "Institut 13 Ethnomusikologie",
             *    "@language": "deu"
             *  }
             * ],
             * "skos:exactMatch": [
             *  "https://pid.phaidra.org/kug-org/N3RC-0W64"
             * ]
             * }
             * ]
             *
             */
        }
Пример #5
0
        public override void WriteAttributeContent(PhaidraFile file, Dictionary <string, string> values)
        {
            string owner = GetStringValue(values, CONST_owner);

            var metadata = GetOrCreateProperty <JObject>(file.Metadata, "metadata");

            if (!string.IsNullOrEmpty(owner))
            {
                metadata.Add(new JProperty("ownerid", owner));

                /*
                 * "rights": {
                 *   "department": [
                 *     {
                 *       "value": "12345"
                 *     }
                 *   ]
                 * }
                 */
            }
        }
        public override void WriteAttributeContent(PhaidraFile file, Dictionary <string, string> values)
        {
            JObject jsonLd = GetJsonLd(file.Metadata);

            string fullPathToFile;
            string absolutefilepath      = GetStringValue(values, CONST_absolutefilepath);
            string relativefilepath      = GetStringValue(values, CONST_relativefilepath);
            string absolutedirectorypath = GetStringValue(values, CONST_absolutedirectorypath);
            string relativedirectorypath = GetStringValue(values, CONST_relativedirectorypath);
            string filename = GetStringValue(values, CONST_filename);

            if (!string.IsNullOrEmpty(absolutefilepath))
            {
                fullPathToFile = absolutefilepath;
            }
            else if (!string.IsNullOrEmpty(file.BaseDirectory) && !string.IsNullOrEmpty(relativefilepath))
            {
                fullPathToFile = System.IO.Path.Combine(file.BaseDirectory, absolutefilepath);
            }
            else if (!string.IsNullOrEmpty(absolutedirectorypath) && !string.IsNullOrEmpty(filename))
            {
                fullPathToFile = System.IO.Path.Combine(absolutedirectorypath, filename);
            }
            else if (!string.IsNullOrEmpty(file.BaseDirectory) && !string.IsNullOrEmpty(relativedirectorypath) && !string.IsNullOrEmpty(filename))
            {
                fullPathToFile = System.IO.Path.Combine(file.BaseDirectory, relativedirectorypath, filename);
            }
            else
            {
                file.Errors.Add("no file name specified");
                return;
            }

            file.Fullfilename = fullPathToFile;

            if (!System.IO.File.Exists(file.Fullfilename))
            {
                Logger.LogE($"File not found ({file.Fullfilename}).");
                file.Errors.Add("file not found");
                return;
                //System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file.Fullfilename));
                //System.IO.File.WriteAllText(file.Fullfilename, "test");
            }

            filename = System.IO.Path.GetFileName(file.Fullfilename);
            jsonLd.Add(new JProperty("ebucore:filename", new JArray(filename)));

            string extension = System.IO.Path.GetExtension(filename).ToLower();

            if (PhaidraAttributesCache.Extension2MimeTypeDict.TryGetValue(extension, out string mimeType))
            {
                file.MimeType = mimeType;
                jsonLd.Add(new JProperty("ebucore:hasMimeType", new JArray(mimeType)));
                string phaidraType;
                if (!PhaidraAttributesCache.MimeType2PhaidraTypeDict.TryGetValue(mimeType, out phaidraType))
                {
                    phaidraType = PhaidraAttributesCache.MimeType2PhaidraTypeDict["default"];
                }
                file.PhaidraType = phaidraType;
                if (PhaidraAttributesCache.PhaidraType2DctermsTypeDict.TryGetValue(phaidraType, out JArray dctermsType))
                {
                    jsonLd.Add(new JProperty("dcterms:type", (JArray)dctermsType.DeepClone()));
                }
            }

            /*
             * "ebucore:filename": [ "file.jpg" ],
             * "ebucore:hasMimeType": [ "image/jpeg" ],
             * "dcterms:type": [
             * {
             *   "skos:prefLabel": [ { "@language": "eng", "@value": "image" } ],
             *   "skos:exactMatch": [ "https://pid.phaidra.org/vocabulary/44TN-P1S0" ],
             *   "@type": "skos:Concept"
             * }
             * ]
             */
        }
Пример #7
0
 public virtual void WriteAttributeContentToCSV(PhaidraFile file, Dictionary <string, string> values)
 {
 }
Пример #8
0
 public abstract void WriteAttributeContent(PhaidraFile file, Dictionary <string, string> values);
 public override void WriteAttributeContentToCSV(PhaidraFile file, Dictionary <string, string> values)
 {
     values[CONST_phaidraid] = file.PhaidraId;
 }